Add Emergency Button (sos) device support to Tuya (#57794)

This commit is contained in:
Franck Nijhof 2021-10-15 21:32:12 +02:00 committed by GitHub
parent 31ccaac865
commit 9be3278ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

View File

@ -8,6 +8,7 @@ from tuya_iot import TuyaDevice, TuyaDeviceManager
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_DOOR,
DEVICE_CLASS_MOTION,
DEVICE_CLASS_SAFETY,
BinarySensorEntity,
BinarySensorEntityDescription,
)
@ -61,6 +62,19 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
),
# Emergency Button
# https://developer.tuya.com/en/docs/iot/categorysos?id=Kaiuz3oi6agjy
"sos": (
TuyaBinarySensorEntityDescription(
key=DPCode.SOS_STATE,
device_class=DEVICE_CLASS_SAFETY,
),
TuyaBinarySensorEntityDescription(
key=DPCode.TEMPER_ALARM,
name="Tamper",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
),
}

View File

@ -45,6 +45,7 @@ TUYA_SUPPORTED_PRODUCT_CATEGORIES = (
"pc", # Power Strip
"pir", # PIR Detector
"qn", # Heater
"sos", # SOS Button
"wk", # Thermostat
"xdd", # Ceiling Light
"xxj", # Diffuser
@ -100,6 +101,8 @@ class DPCode(str, Enum):
POWDER_SET = "powder_set" # Powder
PUMP_RESET = "pump_reset" # Water pump reset
SHAKE = "shake" # Oscillating
SOS = "sos" # Emergency State
SOS_STATE = "sos_state" # Emergency mode
SPEED = "speed" # Speed level
START = "start" # Start
SWING = "swing" # Swing mode

View File

@ -92,6 +92,23 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
),
# Emergency Button
# https://developer.tuya.com/en/docs/iot/categorysos?id=Kaiuz3oi6agjy
"sos": (
SensorEntityDescription(
key=DPCode.BATTERY_PERCENTAGE,
name="Battery",
native_unit_of_measurement=PERCENTAGE,
device_class=DEVICE_CLASS_BATTERY,
state_class=STATE_CLASS_MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
SensorEntityDescription(
key=DPCode.BATTERY_STATE,
name="Battery State",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
),
}
# Socket (duplicate of `kg`)