ble_monitor: Error doing job: Fatal error: protocol.data_received() call failed

Updated to 4.0 and it broke my sensors. I have 3 LYWSD03MMC with custom ATC1441 firmware. In version 3.5 they still work. See logs below. Am I missing some breaking change?

Logger: homeassistant
Source: /usr/src/homeassistant/homeassistant/runner.py:87 
First occurred: 18:34:47 (2 occurrences) 
Last logged: 18:42:18

Error doing job: Fatal error: protocol.data_received() call failed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 870, in _read_ready__data_received
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.9/site-packages/aioblescan/aioblescan.py", line 1840, in data_received
    extra_data = ev.decode(packet)
  File "/usr/local/lib/python3.9/site-packages/aioblescan/aioblescan.py", line 1303, in decode
    data = ev.decode(data)
  File "/usr/local/lib/python3.9/site-packages/aioblescan/aioblescan.py", line 1350, in decode
    data = ev.decode(data)
  File "/usr/local/lib/python3.9/site-packages/aioblescan/aioblescan.py", line 833, in decode
    data = field.decode(data)
  File "/usr/local/lib/python3.9/site-packages/aioblescan/aioblescan.py", line 1379, in decode
    data = ad.decode(data)
  File "/usr/local/lib/python3.9/site-packages/aioblescan/aioblescan.py", line 1646, in decode
    val.decode(data[: length.val - len(type)])
  File "/usr/local/lib/python3.9/site-packages/aioblescan/aioblescan.py", line 664, in decode
    data = mynbyte.decode(data)
  File "/usr/local/lib/python3.9/site-packages/aioblescan/aioblescan.py", line 623, in decode
    self.val = unpack(">%ds" % self.length, data[: self.length])[0][::-1]
struct.error: unpack requires a buffer of 4 bytes

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 43

Most upvoted comments

@LEJOUI I have asked to have another look at your failing data again by the dev of aioblescan, see https://github.com/frawau/aioblescan/issues/44. Last time his conclusion was that it was a hardware related issue. But I asked him, if he still things this is hardware related, as the fix in aioblescan was applied to so called “extended BLE advertisements”, while your error is in a normal BLE advertisement. But I don’t see something wrong in that part of the code.

Good news (hopefully).

There has been an update of aioblescan, which probably fixes the issue from @LEJOUI, @lululombard and @aletzi1. I have added the new aioblescan to 7.0.0, hopefully this will solve it. Let me know

Fixed the KeyError in 6.9.1-beta. Next time, please open a new issue, as this is a completely different error.

Thanks, I’ll look into it. It will take some days, as the problem is in aioblescan, which is an external pypi package we use. This is not developed by ourselves, but I can try to have a look to find out what is wrong.

Bedankt,

I’m going to puzzle on it to see if I can find out what is wrong. Will take some time, but I’ll come back to you on it a.s.a.p.

No, just follow these instructions from my earlier post (https://github.com/custom-components/ble_monitor/issues/433#issuecomment-879900738) (I wrongly assumed you still had this code).

I’ve prepared a special version to do some debugging.

  • Please make sure you have 4.0.1 first.
  • Next, copy the content of the following file over the content of /config/custom_components/ble_monitor/__init__.py on your mini-pc.
  • In the same folder, create a file aioblescan_ext.py (so /config/custom_components/ble_monitor/aioblescan_ext.py) and copy the entire content of this file in it.
  • After that, restart your HA and wait till the error occurs.
  • An error should be in the HA log with a long data string. We need this error message to figure out what is wrong. It probably needs to be fixed in aioblescan, but we can take care of that later.

I’ve prepared a special version to do some debugging.