fix: use binary sensor class for door and windows sensor and water leak sensor

fix: use Binary sensor class for door&windows and water leak sensor

The original version uses a sensor class for various sensors, such as door and windows sensors, water leak sensors, occupancy sensors, motion sensors, etc., which prevents the HomeKit Bridge from generating corresponding entities.
This fix is to use binary sensor class for door andwindows sensor and water leak sensor.

Correspoding issue: https://github.com/XiaoMi/ha_xiaomi_home/issues/206
This commit is contained in:
Yi Zhai 2024-12-19 16:55:28 +08:00 committed by GitHub
parent bba8ba7f7b
commit 162f943924
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,6 +47,7 @@ Conversion rules of MIoT-Spec-V2 instance to Home Assistant entity.
"""
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.components.event import EventDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
# pylint: disable=pointless-string-statement
"""SPEC_DEVICE_TRANS_MAP
@ -391,6 +392,14 @@ SPEC_PROP_TRANS_MAP: dict[str, dict | str] = {
'device_class': SensorDeviceClass.DURATION,
'entity': 'sensor'
},
'submersion-state': {
'device_class': BinarySensorDeviceClass.MOISTURE,
'entity': 'binary_sensor'
},
'contact-state': {
'device_class': BinarySensorDeviceClass.DOOR,
'entity': 'binary_sensor'
},
'has-someone-duration': 'no-one-determine-time',
'no-one-duration': 'no-one-determine-time'
}