custom-components / ble_monitor

BLE monitor for passive BLE sensors

Home Page:https://community.home-assistant.io/t/passive-ble-monitor-integration/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Binary sensors don't work correctly after update to 12.6.0 and above

Olegz73 opened this issue · comments

What happened?

After version 12.5.1 any binary sensor doesn't work
Screenshot_2024-01-09-20-30-04-227_io homeassistant companion android

Sensor type

Binary sensor

Relevant log output

Эта ошибка возникла в пользовательской интеграции.

Logger: homeassistant
Source: custom_components/ble_monitor/binary_sensor.py:105
Integration: Passive BLE monitor (documentation, issues)
First occurred: 20:23:38 (1 occurrences)
Last logged: 20:23:38

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/ble_monitor/binary_sensor.py", line 157, in async_run
    sensors = await async_add_binary_sensor(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ble_monitor/binary_sensor.py", line 105, in async_add_binary_sensor
    entity_description = [item for item in BINARY_SENSOR_TYPES if item.key is measurement][0]
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Which BLE devices do you have?

Have trouble with this devices
mi window and door sensor 2: isa.magnet.dw2hl
Xiaomi Mijia Honeywell Smoke Detector: lumi.sensor_smoke.mcn02

Could you tell/check in which version it stopped working? Can you e.g try 12.6.x and 12.7.x?

I already try all, 12.6.x , 12.7.x, 12.8.x last good working it's 12.5.1

ok, thanks. That narrows it down for me to the difference between 12.6.x and 12.5.1. I'm looking further.

Could you do a test for me? Remove the device via the BLE monitor options (select the MAC of the sensor at the bottom of the options menu, Send, enable the option to delete the device, 2 send). Next restart HA and after that, add it again.

Have trouble with this devices mi window and door sensor 2: isa.magnet.dw2hl Xiaomi Mijia Honeywell Smoke Detector: lumi.sensor_smoke.mcn02

@Ernst79,

The bug additionally affects the following devices with similar behavior.

  1. JTYJGD03MI Smoke Detector
  2. SJWS01LM Smart Water Leak Sensor

It looks likes its an issue with the binary sensors that I changed the key in 12.6.0 of, (smoke and moisture (dry/wet). I'm debugging it

@ilshatms Could you do another wet/dry test. I understand why the moisture sensor isn't added on the first message. But after you have entered the encryption key, it should just add the binary sensor after it receives the next message (at least, that is what I see on my system).

@ilshatms Could you do another wet/dry test. I understand why the moisture sensor isn't added on the first message. But after you have entered the encryption key, it should just add the binary sensor after it receives the next message (at least, that is what I see on my system).

I tried this test yesterday. After adding the device, I waited for some time and then conducted a wet test hoping that the required sensor would appear. However, it did not show up.

I'm having a hard time finding the root cause of the issue, so I tried something else. I have moved the moisture and smoke sensor to the so called auto-binary sensors devices. These devices should add (binary)sensors as soon as they receive a broadcast of a specific sensortype. Hopefully this will fix the issue. I also added a try .. except statement around the error in the opening post, to find out what is causing the error, if it still occurs.

Can you try to install 12.8.2-beta (enable beta's in HACS for BLE monitor). It also contains some other (unrelated) changes, so hopefully it wont break other stuff. Thanks for testing and sorry for the inconvenience. Please report back your findings

ok, thanks. That narrows it down for me to the difference between 12.6.x and 12.5.1. I'm looking further.

After 12.5, such a problem with the opening sensors Xiaomi Mi Door and Window Sensor 2 MCCGQ02HL Opening/closing is simply not registered.

version 12.5.1 is very stable!

12.8.2-beta is only updated for smoke and moisture sensors. I can do a similar fix for the MCCGQ02HL, but I first need to get feedback if the fix worked or not.

Can you try to install 12.8.2-beta (enable beta's in HACS for BLE monitor). It also contains some other (unrelated) changes, so hopefully it wont break other stuff. Thanks for testing and sorry for the inconvenience. Please report back your findings

2.8.2-beta restored the operation of the SJWS01LM Smart Water Leak Sensor; everything is working perfectly.

JTYJGD03MI Smoke Detector - all sensors are accessible, but I'll be able to test with real smoke only tomorrow during the day; I will provide a separate update.

@Ernst79 , thank you for your prompt work!

Can you try to install 12.8.2-beta (enable beta's in HACS for BLE monitor). It also contains some other (unrelated) changes, so hopefully it wont break other stuff. Thanks for testing and sorry for the inconvenience. Please report back your findings

2.8.2-beta restored the operation of the SJWS01LM Smart Water Leak Sensor; everything is working perfectly.

JTYJGD03MI Smoke Detector - all sensors are accessible, but I'll be able to test with real smoke only tomorrow during the day; I will provide a separate update.

@Ernst79 , thank you for your prompt work!

JTYJGD03MI Smoke Detector is working. Bug fixed

Great, I’ll make a final release asap.

I have released 12.8.2 as final, which is the same as 12.8.2-beta. This should fix the issue for smoke, moisture and gas binary sensors.

@vsimanin @Olegz73 Can you do a check if this version (12.8.2) also fixes the issue for MCCGQ02HL (door/windows sensor)? I haven't made any changes to the door/window binary sensor, but it could be that the fixes for the other sensors has fixed the door/window sensor as well

I have released 12.8.2 as final, which is the same as 12.8.2-beta. This should fix the issue for smoke, moisture and gas binary sensors.

@vsimanin @Olegz73 Can you do a check if this version (12.8.2) also fixes the issue for MCCGQ02HL (door/windows sensor)? I haven't made any changes to the door/window binary sensor, but it could be that the fixes for the other sensors has fixed the door/window sensor as well

I'm updating the post. Version 12.8.2 has corrected the operation of opening sensors, motion sensors, smoke and water sensors. Thank you!

Great. Thanks for reporting back. Closing this issue.