home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.67k stars 30.42k forks source link

Xiaomi Water Leak Detection missing Moisture sensor #78147

Closed bstempien closed 2 years ago

bstempien commented 2 years ago

The problem

I have 10 Xiaomi SJWS01LM MI Flood Detectors. They are found in the Xiaomi BLE integration. I have entered the Bind_key for each detector. They show the Battery status and Voltage, and that is it. I have them also in the Passive BLE Add-on Integration. I have disabled that Add-on for the moment since it seems to conflict with the official Integration. In the Passive BLE the moisture sensor did populate and work.

What version of Home Assistant Core has the issue?

core-2022.9.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

xiaomi_ble

Link to integration documentation on our website

https://www.home-assistant.io/integrations/xiaomi_ble

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Prior to updating to 2022.9.1 I saw a number of these in the home-assistant.log

2022-09-09 10:54:21.116 ERROR (MainThread) [homeassistant.components.xiaomi_ble]
 Unexpected error updating Mi Flood Detector data: <BinarySensorDeviceClass.MOIS
TURE: 'moisture'>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/passive_update
_processor.py", line 276, in async_handle_update
    new_data = self.update_method(update)
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_ble/binary_sensor
.py", line 54, in sensor_update_to_bluetooth_data_update
    entity_descriptions={
  File "/usr/src/homeassistant/homeassistant/components/xiaomi_ble/binary_sensor
.py", line 55, in <dictcomp>
    device_key_to_bluetooth_entity_key(device_key): BINARY_SENSOR_DESCRIPTIONS[
KeyError: <BinarySensorDeviceClass.MOISTURE: 'moisture'>

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

Hey there @jc2k, @ernst79, mind taking a look at this issue as it has been labeled with an integration (xiaomi_ble) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)


xiaomi_ble documentation xiaomi_ble source (message by IssueLinks)

Jc2k commented 2 years ago

Cheers. I'll have a look at this asap. It looks like the device is being parsed properly but there is a mapping missing in HA.

bstempien commented 2 years ago

It took it a while for them to start showing up after I installed the core-2022.9.1 update, but now I am getting these in the logs.

2022-09-09 11:44:45.612 ERROR (MainThread) [homeassistant.components.xiaomi_ble] Unexpected error updating Mi Flood Detector data: <BinarySensorDeviceClass.MOIS TURE: 'moisture'> Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/bluetooth/passive_update _processor.py", line 276, in async_handle_update new_data = self.update_method(update) File "/usr/src/homeassistant/homeassistant/components/xiaomi_ble/binary_sensor .py", line 54, in sensor_update_to_bluetooth_data_update entity_descriptions={ File "/usr/src/homeassistant/homeassistant/components/xiaomi_ble/binary_sensor .py", line 55, in device_key_to_bluetooth_entity_key(device_key): BINARY_SENSOR_DESCRIPTIONS[ KeyError: <BinarySensorDeviceClass.MOISTURE: 'moisture'>

Ernst79 commented 2 years ago

Looks like we update a binary sensor moisture in xiaomi_ble

https://github.com/Bluetooth-Devices/xiaomi-ble/blob/3c99cb0743d2164c44e0519446e0ce62f3932626/src/xiaomi_ble/parser.py#L613

But this device class isn't added in Home Assistant in xiaomi_ble/binary_sensor.py

https://github.com/home-assistant/core/blob/167b9cb1a0f1083df0ed07e7f68b5b9cc2cbdc7c/homeassistant/components/xiaomi_ble/binary_sensor.py#L30-L40.

Note that the MOISTURE device class is only available in dev, not in the current release.

bstempien commented 2 years ago

Is there an idea on how long before Moisture will move into the mainstream release?

I ask because I am at the start of using these Flood sensors. I had just gotten all of the encryption keys out of the MI Home app when I put core-2022.9 on and the Xiaomi BLE Integration started to populate.

So I am at a crossroads right now. Do I enable Passive BLE monitor again and start building my automation, or hold off until Xiaomi BLE is updated to handle this sensor.

I have 10 of them, so not going to be a trival task to convert, but also not the end of the world.

On Fri, Sep 9, 2022, 1:31 PM Ernst Klamer @.***> wrote:

Looks like we update a binary sensor moisture in xiaomi_ble

https://github.com/Bluetooth-Devices/xiaomi-ble/blob/3c99cb0743d2164c44e0519446e0ce62f3932626/src/xiaomi_ble/parser.py#L609

But this device class isn't added in Home Assistant

https://github.com/home-assistant/core/blob/167b9cb1a0f1083df0ed07e7f68b5b9cc2cbdc7c/homeassistant/components/xiaomi_ble/binary_sensor.py#L30-L40 .

Note that the MOISTURE device class is only available in dev, not in the current release.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/78147#issuecomment-1242265788, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3TSEEGEICBBQ6WOMZHAKLV5NX6VANCNFSM6AAAAAAQIY5W2I . You are receiving this because you authored the thread.Message ID: @.***>

Jc2k commented 2 years ago

I plan to to try and fix it in a point release if I can. And then add the new device class in next months release.

Ernst79 commented 2 years ago

Probably adding the following will do the trick

 XiaomiBinarySensorDeviceClass.MOISTURE: BinarySensorEntityDescription( 
     key=XiaomiBinarySensorDeviceClass.MOISTURE, 
     device_class=None, 
 ), 
Jc2k commented 2 years ago

Yep. Replying from my phone so being terse 😅