diff --git a/homeassistant/components/tuya/binary_sensor.py b/homeassistant/components/tuya/binary_sensor.py index b992c24d07df94c5b5361928a98e9678b9bd9896..2d6d9b478c874627f1122392a9407b2a7917811e 100644 --- a/homeassistant/components/tuya/binary_sensor.py +++ b/homeassistant/components/tuya/binary_sensor.py @@ -190,6 +190,10 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { key=DPCode.DOORCONTACT_STATE, device_class=BinarySensorDeviceClass.DOOR, ), + TuyaBinarySensorEntityDescription( + key=DPCode.SWITCH, # Used by non-standard contact sensor implementations + device_class=BinarySensorDeviceClass.DOOR, + ), TAMPER_BINARY_SENSOR, ), # Access Control diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index a9c53d807bcda7a3e1a7a95f8de6c85e6b9c83b5..d731a93f85859aa9cb4ccee1982423d8849eda88 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -113,6 +113,7 @@ class DPCode(StrEnum): BASIC_OSD = "basic_osd" BASIC_PRIVATE = "basic_private" BASIC_WDR = "basic_wdr" + BATTERY = "battery" # Used by non-standard contact sensor implementations BATTERY_PERCENTAGE = "battery_percentage" # Battery percentage BATTERY_STATE = "battery_state" # Battery state BATTERY_VALUE = "battery_value" # Battery value diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index 9382059471d39badaf61414a8d92851030c96200..cd487a31d976f67df441e7d0333b5077e4c9ee64 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -55,6 +55,14 @@ BATTERY_SENSORS: tuple[TuyaSensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, ), + TuyaSensorEntityDescription( + key=DPCode.BATTERY, # Used by non-standard contact sensor implementations + translation_key="battery", + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + state_class=SensorStateClass.MEASUREMENT, + entity_category=EntityCategory.DIAGNOSTIC, + ), TuyaSensorEntityDescription( key=DPCode.BATTERY_STATE, translation_key="battery_state",