Complete Switch/Socket/Power Strip device support for Tuya (#58106)

This commit is contained in:
Franck Nijhof 2021-10-20 19:08:43 +02:00 committed by GitHub
parent 5fc2897c08
commit 3e57d0d3d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 81 additions and 1 deletions

View file

@ -15,7 +15,13 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import HomeAssistantTuyaData
from .base import EnumTypeData, TuyaEntity
from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode
from .const import (
DEVICE_CLASS_TUYA_LIGHT_MODE,
DEVICE_CLASS_TUYA_RELAY_STATUS,
DOMAIN,
TUYA_DISCOVERY_NEW,
DPCode,
)
# All descriptions can be found here. Mostly the Enum data types in the
# default instructions set of each category end up being a select.
@ -46,6 +52,22 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = {
icon="mdi:coffee",
),
),
# Switch
# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s
"kg": (
SelectEntityDescription(
key=DPCode.RELAY_STATUS,
name="Power on Behavior",
device_class=DEVICE_CLASS_TUYA_RELAY_STATUS,
entity_category=ENTITY_CATEGORY_CONFIG,
),
SelectEntityDescription(
key=DPCode.LIGHT_MODE,
name="Indicator Light Mode",
device_class=DEVICE_CLASS_TUYA_LIGHT_MODE,
entity_category=ENTITY_CATEGORY_CONFIG,
),
),
# Siren Alarm
# https://developer.tuya.com/en/docs/iot/categorysgbj?id=Kaiuz37tlpbnu
"sgbj": (
@ -63,6 +85,15 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = {
}
# Socket (duplicate of `kg`)
# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s
SELECTS["cz"] = SELECTS["kg"]
# Power Socket (duplicate of `kg`)
# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s
SELECTS["pc"] = SELECTS["kg"]
async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None: