-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug - struct.error: unpack requires a buffer of 4 bytes #233
Comments
Hi, thanks for reporting. This message indicates that the BLE message is recognized as Xiaomi Mi_Beacon message, 0d10 means that the message should contain temperature and humidity data in a 4 bytes long data message (2 for temperature, 2 for humidity), but apparently, the BLE data message is not 4 bytes long. So, to figure out what is wrong, first a couple of questions, what sensor do you have? |
Hello I have
Error occurred twice from yesterday. |
And did you change something (update of ble_monitor?). Did you had it with earlier installations/versions, or is it a new installation? |
Changes:
|
Ok, than we need to figure out what is wrong with the data. Unfortunately, we will need to get some more debug information. Could you add the 4 lines with
After that, please turn on debug logging by adding the following to
Now, restart Home Assistant and wait till the error occurs. Copy the info around the moment the error occurs from the log here. |
Hi I added Logger info but result is Logger: homeassistant.setup Traceback (most recent call last): |
Sound like you have an error in the indentation (number of tabs/spaces). Can you post a printscreen of your code? The lines should start at the same position. |
@perseus177 I thing there is something wrong with your installation. The above looks fine. I tried it myself and installed 0.9.4 and added the 4 lines. Runs fine. And the results in the log:
I suggest you reinstall |
@Ernst79 Ernst79
Same problem Logger: homeassistant.setup Traceback (most recent call last): |
I have really no idea why this doesn't work in your case. Perhaps try to remove the empty space before the _LOGGER and type spaces yourself. Perhaps it has tabs in stead of spaces. or try to remove the first 3 |
I will hope that error will not display again. You can close this ticket. |
ok, let us know it it does, than we try further |
@Ernst79 Still same problem on version Home Assistant 2021.1.5 and BLE Monitor 1.0.5 Logger: homeassistant Error doing job: Fatal error: protocol.data_received() call failed. |
I’ll prepare a version for you that catches the actual data in case an error occurs. Please give me a few days, I’m on holiday now |
Could you try the following: First, update to 1.1.0. Next, in the folder config/custom_components/ble_monitor, there is a file
Change this to
If the error occurs, it will display an error in the log. I think, ble_monitor will keep on working now, but it will display an error if it occurs. For a final fix, can you send me the error from the log. It will make me understand what data it is trying to unpack and why this doesn't work. |
Hi @Ernst79
I am waiting for error, when error will display I will add it here |
Logger: custom_components.ble_monitor
Logger: homeassistant Traceback (most recent call last): |
Thanks, I see these messages have 5 bytes in stead of 4. I'll will make a fix for this. |
Fixed in 1.1.3. |
@Ernst79 Logger: custom_components.ble_monitor
|
Please update to 1.1.4. This is solved in 1.1.4. |
@Ernst79 updated to 1.1.4 I dont know if this is new bug or still the same Logger: homeassistant Traceback (most recent call last): |
This is a new one, different BLE message (this one is Humidity only, the previous was temperature and humidity in one message. Strange thing is that you seem to be the only one that has this issue. Can't really explain it. Anyway, I will create a similar fix. |
I added the same fix (skip if the message doesn't have the correct length) for most messages. Is added in 1.2.0-beta. |
Environment
Passive BLE monitor integration (Xiaomi Mijia BLE MiBeacon monitor)
Installed version: 0.9.4
Logger: homeassistant
Source: custom_components/ble_monitor/init.py:366
First occurred: 10. januára 2021, 16:57:47 (1 occurrences)
Last logged: 10. januára 2021, 16:57:47
Error doing job: Fatal error: protocol.data_received() call failed.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received self._protocol.data_received(data) File "/config/custom_components/ble_monitor/aioblescan_ext.py", line 1497, in data_received self.process(packet) File "/config/custom_components/ble_monitor/__init__.py", line 483, in process_hci_events msg, binary, measuring = self.parse_raw_message(data) File "/config/custom_components/ble_monitor/__init__.py", line 736, in parse_raw_message result.update(resfunc(xvalue)) File "/config/custom_components/ble_monitor/__init__.py", line 366, in obj0d10 (temp, humi) = TH_STRUCT.unpack(xobj) struct.error: unpack requires a buffer of 4 bytes
The text was updated successfully, but these errors were encountered: