Add support for Tuya non-standard contact sensors (#115557)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Douglas Krahmer 2024-06-11 09:09:57 -07:00 committed by GitHub
parent c907912dd1
commit e6df0be072
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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",