diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index e3765e2d2ca..15849494602 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -103,7 +103,10 @@ class DeviceCategory(StrEnum): BGL = "bgl" """Wall-hung boiler""" BH = "bh" - """Smart kettle""" + """Smart kettle + + https://developer.tuya.com/en/docs/iot/fbh?id=K9gf484m21yq7 + """ BX = "bx" """Refrigerator""" BXX = "bxx" @@ -163,34 +166,58 @@ class DeviceCategory(StrEnum): https://developer.tuya.com/en/docs/iot/f?id=Kacpeobojffop """ DC = "dc" - """String lights""" + """String lights + + # https://developer.tuya.com/en/docs/iot/dc?id=Kaof7taxmvadu + """ DCL = "dcl" """Induction cooker""" DD = "dd" - """Strip lights""" + """Strip lights + + https://developer.tuya.com/en/docs/iot/dd?id=Kaof804aibg2l + """ DGNBJ = "dgnbj" """Multi-functional alarm https://developer.tuya.com/en/docs/iot/categorydgnbj?id=Kaiuz3yorvzg3 """ DJ = "dj" - """Light""" + """Light + + https://developer.tuya.com/en/docs/iot/categorydj?id=Kaiuyzy3eheyy + """ DLQ = "dlq" """Circuit breaker""" DR = "dr" - """Electric blanket""" + """Electric blanket + + https://developer.tuya.com/en/docs/iot/categorydr?id=Kaiuz22dyc66p + """ DS = "ds" """TV set""" FS = "fs" - """Fan""" + """Fan + + https://developer.tuya.com/en/docs/iot/categoryfs?id=Kaiuz1xweel1c + """ FSD = "fsd" - """Ceiling fan light""" + """Ceiling fan light + + https://developer.tuya.com/en/docs/iot/fsd?id=Kaof8eiei4c2v + """ FWD = "fwd" - """Ambiance light""" + """Ambiance light + + https://developer.tuya.com/en/docs/iot/ambient-light?id=Kaiuz06amhe6g + """ GGQ = "ggq" """Irrigator""" GYD = "gyd" - """Motion sensor light""" + """Motion sensor light + + https://developer.tuya.com/en/docs/iot/gyd?id=Kaof8a8hycfmy + """ GYMS = "gyms" """Business lock""" HOTELMS = "hotelms" @@ -203,7 +230,10 @@ class DeviceCategory(StrEnum): JS = "js" """Water purifier""" JSQ = "jsq" - """Humidifier""" + """Humidifier + + https://developer.tuya.com/en/docs/iot/categoryjsq?id=Kaiuz1smr440b + """ JTMSBH = "jtmsbh" """Smart lock (keep alive)""" JTMSPRO = "jtmspro" @@ -214,11 +244,20 @@ class DeviceCategory(StrEnum): https://developer.tuya.com/en/docs/iot/categoryjwbj?id=Kaiuz40u98lkm """ KFJ = "kfj" - """Coffee maker""" + """Coffee maker + + https://developer.tuya.com/en/docs/iot/categorykfj?id=Kaiuz2p12pc7f + """ KG = "kg" - """Switch""" + """Switch + + https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s + """ KJ = "kj" - """Air purifier""" + """Air purifier + + https://developer.tuya.com/en/docs/iot/f?id=K9gf46h2s6dzm + """ KQZG = "kqzg" """Air fryer""" KT = "kt" @@ -270,13 +309,19 @@ class DeviceCategory(StrEnum): MSP = "msp" """Cat toilet""" MZJ = "mzj" - """Sous vide cooker""" + """Sous vide cooker + + https://developer.tuya.com/en/docs/iot/categorymzj?id=Kaiuz2vy130ux + """ NNQ = "nnq" """Bottle warmer""" NTQ = "ntq" """HVAC""" PC = "pc" - """Power strip""" + """Power strip + + https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s + """ PHOTOLOCK = "photolock" """Audio and video lock""" PIR = "pir" @@ -292,7 +337,7 @@ class DeviceCategory(StrEnum): QN = "qn" """Heater - https://developer.tuya.com/en/docs/iot/f?id=K9gf46epy4j82 + https://developer.tuya.com/en/docs/iot/categoryqn?id=Kaiuz18kih0sm """ RQBJ = "rqbj" """Gas alarm @@ -331,14 +376,23 @@ class DeviceCategory(StrEnum): SP = "sp" """Smart camera - https://developer.tuya.com/en/docs/iot/categorysgbj?id=Kaiuz37tlpbnu + https://developer.tuya.com/en/docs/iot/categorysp?id=Kaiuz35leyo12 """ SZ = "sz" - """Smart indoor garden""" + """Smart indoor garden + + https://developer.tuya.com/en/docs/iot/categorysz?id=Kaiuz4e6h7up0 + """ TGKG = "tgkg" - """Dimmer switch""" + """Dimmer switch + + https://developer.tuya.com/en/docs/iot/categorytgkg?id=Kaiuz0ktx7m0o + """ TGQ = "tgq" - """Dimmer""" + """Dimmer + + https://developer.tuya.com/en/docs/iot/categorytgkg?id=Kaiuz0ktx7m0o + """ TNQ = "tnq" """Smart milk kettle""" TRACKER = "tracker" @@ -346,7 +400,10 @@ class DeviceCategory(StrEnum): TS = "ts" """Smart jump rope""" TYNDJ = "tyndj" - """Solar light""" + """Solar light + + https://developer.tuya.com/en/docs/iot/tynd?id=Kaof8j02e1t98 + """ TYY = "tyy" """Projector""" TZC1 = "tzc1" @@ -364,7 +421,10 @@ class DeviceCategory(StrEnum): https://developer.tuya.com/en/docs/iot/categorywsdcg?id=Kaiuz3hinij34 """ XDD = "xdd" - """Ceiling light""" + """Ceiling light + + https://developer.tuya.com/en/docs/iot/ceiling-light?id=Kaiuz03xxfc4r + """ XFJ = "xfj" """Ventilation system""" XXJ = "xxj" @@ -376,7 +436,10 @@ class DeviceCategory(StrEnum): YG = "yg" """Bathtub""" YKQ = "ykq" - """Remote control""" + """Remote control + + https://developer.tuya.com/en/docs/iot/ykq?id=Kaof8ljn81aov + """ YLCG = "ylcg" """Pressure sensor @@ -402,22 +465,65 @@ class DeviceCategory(StrEnum): """Smart pill box""" # Undocumented + BZYD = "bzyd" + """White noise machine (undocumented)""" + CWJWQ = "cwjwq" + """Smart Odor Eliminator-Pro (undocumented) + + see https://github.com/orgs/home-assistant/discussions/79 + """ DGHSXJ = "dghsxj" """Smart Camera - Low power consumption camera (undocumented) see https://github.com/home-assistant/core/issues/132844 """ + DSD = "dsd" + """Filament Light + + Based on data from https://github.com/home-assistant/core/issues/106703 + Product category mentioned in https://developer.tuya.com/en/docs/iot/oemapp-light?id=Kb77kja5woao6 + As at 30/12/23 not documented in https://developer.tuya.com/en/docs/iot/lighting?id=Kaiuyzxq30wmc + """ + FSKG = "fskg" + """Fan wall switch (undocumented)""" HXD = "hxd" """Wake Up Light II (undocumented)""" JDCLJQR = "jdcljqr" """Curtain Robot (undocumented)""" JQBJ = "jqbj" """Formaldehyde Detector (undocumented)""" + KS = "ks" + """Tower fan (undocumented) + + See https://github.com/orgs/home-assistant/discussions/329 + """ + MBD = "mbd" + """Unknown light product + + Found as VECINO RGBW as provided by diagnostics + """ + QJDCZ = "qjdcz" + """ Unknown product with light capabilities + + Found in some diffusers, plugs and PIR flood lights + """ QXJ = "qxj" """Temperature and Humidity Sensor with External Probe (undocumented) see https://github.com/home-assistant/core/issues/136472 """ + SFKZQ = "sfkzq" + """Smart Water Timer (undocumented)""" + SJZ = "sjz" + """Electric desk (undocumented)""" + SZJQR = "szjqr" + """Fingerbot (undocumented)""" + SWTZ = "swtz" + """Cooking thermometer (undocumented)""" + TDQ = "tdq" + """Dimmer (undocumented)""" + TYD = "tyd" + """Outdoor flood light (undocumented)""" VOC = "voc" """Volatile Organic Compound Sensor (undocumented)""" WG2 = "wg2" # Documented, but not in official list @@ -427,6 +533,20 @@ class DeviceCategory(StrEnum): """ WKF = "wkf" """Thermostatic Radiator Valve (undocumented)""" + WXKG = "wxkg" # Documented, but not in official list + """Wireless Switch + + https://developer.tuya.com/en/docs/iot/s?id=Kbeoa9fkv6brp + """ + XNYJCN = "xnyjcn" + """Micro Storage Inverter + + Energy storage and solar PV inverter system with monitoring capabilities + """ + YWCGQ = "ywcgq" + """Tank Level Sensor (undocumented)""" + ZNRB = "znrb" + """Pool HeatPump""" class DPCode(StrEnum): diff --git a/homeassistant/components/tuya/event.py b/homeassistant/components/tuya/event.py index 5eda6cbe6bb..4cfb22e4cce 100644 --- a/homeassistant/components/tuya/event.py +++ b/homeassistant/components/tuya/event.py @@ -14,17 +14,14 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import TuyaConfigEntry -from .const import TUYA_DISCOVERY_NEW, DPCode, DPType +from .const import TUYA_DISCOVERY_NEW, DeviceCategory, DPCode, DPType from .entity import TuyaEntity # All descriptions can be found here. Mostly the Enum data types in the # default status set of each category (that don't have a set instruction) # end up being events. -# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq -EVENTS: dict[str, tuple[EventEntityDescription, ...]] = { - # Wireless Switch - # https://developer.tuya.com/en/docs/iot/s?id=Kbeoa9fkv6brp - "wxkg": ( +EVENTS: dict[DeviceCategory, tuple[EventEntityDescription, ...]] = { + DeviceCategory.WXKG: ( EventEntityDescription( key=DPCode.SWITCH_MODE1, device_class=EventDeviceClass.BUTTON, diff --git a/homeassistant/components/tuya/fan.py b/homeassistant/components/tuya/fan.py index dc6d234cc5d..db16720ddc4 100644 --- a/homeassistant/components/tuya/fan.py +++ b/homeassistant/components/tuya/fan.py @@ -21,7 +21,7 @@ from homeassistant.util.percentage import ( ) from . import TuyaConfigEntry -from .const import TUYA_DISCOVERY_NEW, DPCode, DPType +from .const import TUYA_DISCOVERY_NEW, DeviceCategory, DPCode, DPType from .entity import TuyaEntity from .models import EnumTypeData, IntegerTypeData from .util import get_dpcode @@ -36,24 +36,13 @@ _SPEED_DPCODES = ( ) _SWITCH_DPCODES = (DPCode.SWITCH_FAN, DPCode.FAN_SWITCH, DPCode.SWITCH) -TUYA_SUPPORT_TYPE = { - # Dehumidifier - # https://developer.tuya.com/en/docs/iot/categorycs?id=Kaiuz1vcz4dha - "cs", - # Fan - # https://developer.tuya.com/en/docs/iot/categoryfs?id=Kaiuz1xweel1c - "fs", - # Ceiling Fan Light - # https://developer.tuya.com/en/docs/iot/fsd?id=Kaof8eiei4c2v - "fsd", - # Fan wall switch - "fskg", - # Air Purifier - # https://developer.tuya.com/en/docs/iot/f?id=K9gf46h2s6dzm - "kj", - # Undocumented tower fan - # https://github.com/orgs/home-assistant/discussions/329 - "ks", +TUYA_SUPPORT_TYPE: set[DeviceCategory] = { + DeviceCategory.CS, + DeviceCategory.FS, + DeviceCategory.FSD, + DeviceCategory.FSKG, + DeviceCategory.KJ, + DeviceCategory.KS, } diff --git a/homeassistant/components/tuya/humidifier.py b/homeassistant/components/tuya/humidifier.py index 3d90ff3b44f..cc6fdd778fe 100644 --- a/homeassistant/components/tuya/humidifier.py +++ b/homeassistant/components/tuya/humidifier.py @@ -18,7 +18,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import TuyaConfigEntry -from .const import TUYA_DISCOVERY_NEW, DPCode, DPType +from .const import TUYA_DISCOVERY_NEW, DeviceCategory, DPCode, DPType from .entity import TuyaEntity from .models import IntegerTypeData from .util import ActionDPCodeNotFoundError, get_dpcode @@ -49,19 +49,15 @@ def _has_a_valid_dpcode( return any(get_dpcode(device, code) for code in properties_to_check) -HUMIDIFIERS: dict[str, TuyaHumidifierEntityDescription] = { - # Dehumidifier - # https://developer.tuya.com/en/docs/iot/categorycs?id=Kaiuz1vcz4dha - "cs": TuyaHumidifierEntityDescription( +HUMIDIFIERS: dict[DeviceCategory, TuyaHumidifierEntityDescription] = { + DeviceCategory.CS: TuyaHumidifierEntityDescription( key=DPCode.SWITCH, dpcode=(DPCode.SWITCH, DPCode.SWITCH_SPRAY), current_humidity=DPCode.HUMIDITY_INDOOR, humidity=DPCode.DEHUMIDITY_SET_VALUE, device_class=HumidifierDeviceClass.DEHUMIDIFIER, ), - # Humidifier - # https://developer.tuya.com/en/docs/iot/categoryjsq?id=Kaiuz1smr440b - "jsq": TuyaHumidifierEntityDescription( + DeviceCategory.JSQ: TuyaHumidifierEntityDescription( key=DPCode.SWITCH, dpcode=(DPCode.SWITCH, DPCode.SWITCH_SPRAY), current_humidity=DPCode.HUMIDITY_CURRENT, diff --git a/homeassistant/components/tuya/light.py b/homeassistant/components/tuya/light.py index 6b1ac3e991f..d2cceaa4620 100644 --- a/homeassistant/components/tuya/light.py +++ b/homeassistant/components/tuya/light.py @@ -26,7 +26,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from homeassistant.util import color as color_util from . import TuyaConfigEntry -from .const import TUYA_DISCOVERY_NEW, DPCode, DPType, WorkMode +from .const import TUYA_DISCOVERY_NEW, DeviceCategory, DPCode, DPType, WorkMode from .entity import TuyaEntity from .models import IntegerTypeData from .util import get_dpcode, remap_value @@ -72,9 +72,8 @@ class TuyaLightEntityDescription(LightEntityDescription): ) -LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { - # White noise machine - "bzyd": ( +LIGHTS: dict[DeviceCategory, tuple[TuyaLightEntityDescription, ...]] = { + DeviceCategory.BZYD: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -82,18 +81,14 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { color_data=DPCode.COLOUR_DATA, ), ), - # Curtain Switch - # https://developer.tuya.com/en/docs/iot/category-clkg?id=Kaiuz0gitil39 - "clkg": ( + DeviceCategory.CLKG: ( TuyaLightEntityDescription( key=DPCode.SWITCH_BACKLIGHT, translation_key="backlight", entity_category=EntityCategory.CONFIG, ), ), - # String Lights - # https://developer.tuya.com/en/docs/iot/dc?id=Kaof7taxmvadu - "dc": ( + DeviceCategory.DC: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -103,9 +98,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { color_data=DPCode.COLOUR_DATA, ), ), - # Strip Lights - # https://developer.tuya.com/en/docs/iot/dd?id=Kaof804aibg2l - "dd": ( + DeviceCategory.DD: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -116,9 +109,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { default_color_type=DEFAULT_COLOR_TYPE_DATA_V2, ), ), - # Light - # https://developer.tuya.com/en/docs/iot/categorydj?id=Kaiuyzy3eheyy - "dj": ( + DeviceCategory.DJ: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -136,11 +127,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { brightness=DPCode.BRIGHT_VALUE_1, ), ), - # Filament Light - # Based on data from https://github.com/home-assistant/core/issues/106703 - # Product category mentioned in https://developer.tuya.com/en/docs/iot/oemapp-light?id=Kb77kja5woao6 - # As at 30/12/23 not documented in https://developer.tuya.com/en/docs/iot/lighting?id=Kaiuyzxq30wmc - "dsd": ( + DeviceCategory.DSD: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -148,9 +135,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { brightness=DPCode.BRIGHT_VALUE, ), ), - # Fan - # https://developer.tuya.com/en/docs/iot/categoryfs?id=Kaiuz1xweel1c - "fs": ( + DeviceCategory.FS: ( TuyaLightEntityDescription( key=DPCode.LIGHT, name=None, @@ -165,9 +150,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { brightness=DPCode.BRIGHT_VALUE_1, ), ), - # Ceiling Fan Light - # https://developer.tuya.com/en/docs/iot/fsd?id=Kaof8eiei4c2v - "fsd": ( + DeviceCategory.FSD: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -182,9 +165,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { name=None, ), ), - # Ambient Light - # https://developer.tuya.com/en/docs/iot/ambient-light?id=Kaiuz06amhe6g - "fwd": ( + DeviceCategory.FWD: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -194,9 +175,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { color_data=DPCode.COLOUR_DATA, ), ), - # Motion Sensor Light - # https://developer.tuya.com/en/docs/iot/gyd?id=Kaof8a8hycfmy - "gyd": ( + DeviceCategory.GYD: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -206,9 +185,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { color_data=DPCode.COLOUR_DATA, ), ), - # Wake Up Light II - # Not documented - "hxd": ( + DeviceCategory.HXD: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, translation_key="light", @@ -217,9 +194,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { brightness_min=DPCode.BRIGHTNESS_MIN_1, ), ), - # Humidifier Light - # https://developer.tuya.com/en/docs/iot/categoryjsq?id=Kaiuz1smr440b - "jsq": ( + DeviceCategory.JSQ: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -228,46 +203,35 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { color_data=DPCode.COLOUR_DATA_HSV, ), ), - # Switch - # https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s - "kg": ( + DeviceCategory.KG: ( TuyaLightEntityDescription( key=DPCode.SWITCH_BACKLIGHT, translation_key="backlight", entity_category=EntityCategory.CONFIG, ), ), - # Air Purifier - # https://developer.tuya.com/en/docs/iot/f?id=K9gf46h2s6dzm - "kj": ( + DeviceCategory.KJ: ( TuyaLightEntityDescription( key=DPCode.LIGHT, translation_key="backlight", entity_category=EntityCategory.CONFIG, ), ), - # Air conditioner - # https://developer.tuya.com/en/docs/iot/categorykt?id=Kaiuz0z71ov2n - "kt": ( + DeviceCategory.KT: ( TuyaLightEntityDescription( key=DPCode.LIGHT, translation_key="backlight", entity_category=EntityCategory.CONFIG, ), ), - # Undocumented tower fan - # https://github.com/orgs/home-assistant/discussions/329 - "ks": ( + DeviceCategory.KS: ( TuyaLightEntityDescription( key=DPCode.LIGHT, translation_key="backlight", entity_category=EntityCategory.CONFIG, ), ), - # Unknown light product - # Found as VECINO RGBW as provided by diagnostics - # Not documented - "mbd": ( + DeviceCategory.MBD: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -276,10 +240,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { color_data=DPCode.COLOUR_DATA, ), ), - # Unknown product with light capabilities - # Fond in some diffusers, plugs and PIR flood lights - # Not documented - "qjdcz": ( + DeviceCategory.QJDCZ: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -288,18 +249,14 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { color_data=DPCode.COLOUR_DATA, ), ), - # Heater - # https://developer.tuya.com/en/docs/iot/categoryqn?id=Kaiuz18kih0sm - "qn": ( + DeviceCategory.QN: ( TuyaLightEntityDescription( key=DPCode.LIGHT, translation_key="backlight", entity_category=EntityCategory.CONFIG, ), ), - # Smart Camera - # https://developer.tuya.com/en/docs/iot/categorysp?id=Kaiuz35leyo12 - "sp": ( + DeviceCategory.SP: ( TuyaLightEntityDescription( key=DPCode.FLOODLIGHT_SWITCH, brightness=DPCode.FLOODLIGHT_LIGHTNESS, @@ -311,18 +268,14 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Smart Gardening system - # https://developer.tuya.com/en/docs/iot/categorysz?id=Kaiuz4e6h7up0 - "sz": ( + DeviceCategory.SZ: ( TuyaLightEntityDescription( key=DPCode.LIGHT, brightness=DPCode.BRIGHT_VALUE, translation_key="light", ), ), - # Dimmer Switch - # https://developer.tuya.com/en/docs/iot/categorytgkg?id=Kaiuz0ktx7m0o - "tgkg": ( + DeviceCategory.TGKG: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED_1, translation_key="indexed_light", @@ -348,9 +301,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { brightness_min=DPCode.BRIGHTNESS_MIN_3, ), ), - # Dimmer - # https://developer.tuya.com/en/docs/iot/tgq?id=Kaof8ke9il4k4 - "tgq": ( + DeviceCategory.TGQ: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, translation_key="light", @@ -371,9 +322,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { brightness=DPCode.BRIGHT_VALUE_2, ), ), - # Outdoor Flood Light - # Not documented - "tyd": ( + DeviceCategory.TYD: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -383,9 +332,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { color_data=DPCode.COLOUR_DATA, ), ), - # Solar Light - # https://developer.tuya.com/en/docs/iot/tynd?id=Kaof8j02e1t98 - "tyndj": ( + DeviceCategory.TYNDJ: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -395,9 +342,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { color_data=DPCode.COLOUR_DATA, ), ), - # Ceiling Light - # https://developer.tuya.com/en/docs/iot/ceiling-light?id=Kaiuz03xxfc4r - "xdd": ( + DeviceCategory.XDD: ( TuyaLightEntityDescription( key=DPCode.SWITCH_LED, name=None, @@ -411,9 +356,7 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { translation_key="night_light", ), ), - # Remote Control - # https://developer.tuya.com/en/docs/iot/ykq?id=Kaof8ljn81aov - "ykq": ( + DeviceCategory.YKQ: ( TuyaLightEntityDescription( key=DPCode.SWITCH_CONTROLLER, name=None, @@ -426,19 +369,16 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = { # Socket (duplicate of `kg`) # https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s -LIGHTS["cz"] = LIGHTS["kg"] +LIGHTS[DeviceCategory.CZ] = LIGHTS[DeviceCategory.KG] # Power Socket (duplicate of `kg`) -# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s -LIGHTS["pc"] = LIGHTS["kg"] +LIGHTS[DeviceCategory.PC] = LIGHTS[DeviceCategory.KG] # Smart Camera - Low power consumption camera (duplicate of `sp`) -# Undocumented, see https://github.com/home-assistant/core/issues/132844 -LIGHTS["dghsxj"] = LIGHTS["sp"] +LIGHTS[DeviceCategory.DGHSXJ] = LIGHTS[DeviceCategory.SP] # Dimmer (duplicate of `tgq`) -# https://developer.tuya.com/en/docs/iot/tgq?id=Kaof8ke9il4k4 -LIGHTS["tdq"] = LIGHTS["tgq"] +LIGHTS[DeviceCategory.TDQ] = LIGHTS[DeviceCategory.TGQ] @dataclass diff --git a/homeassistant/components/tuya/number.py b/homeassistant/components/tuya/number.py index 30c1c03807e..1fb00a4de51 100644 --- a/homeassistant/components/tuya/number.py +++ b/homeassistant/components/tuya/number.py @@ -21,6 +21,7 @@ from .const import ( DOMAIN, LOGGER, TUYA_DISCOVERY_NEW, + DeviceCategory, DPCode, DPType, ) @@ -28,13 +29,8 @@ from .entity import TuyaEntity from .models import IntegerTypeData from .util import ActionDPCodeNotFoundError -# All descriptions can be found here. Mostly the Integer data types in the -# default instructions set of each category end up being a number. -# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq -NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { - # Smart Kettle - # https://developer.tuya.com/en/docs/iot/fbh?id=K9gf484m21yq7 - "bh": ( +NUMBERS: dict[DeviceCategory, tuple[NumberEntityDescription, ...]] = { + DeviceCategory.BH: ( NumberEntityDescription( key=DPCode.TEMP_SET, translation_key="temperature", @@ -65,17 +61,14 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # White noise machine - "bzyd": ( + DeviceCategory.BZYD: ( NumberEntityDescription( key=DPCode.VOLUME_SET, translation_key="volume", entity_category=EntityCategory.CONFIG, ), ), - # CO2 Detector - # https://developer.tuya.com/en/docs/iot/categoryco2bj?id=Kaiuz3wes7yuy - "co2bj": ( + DeviceCategory.CO2BJ: ( NumberEntityDescription( key=DPCode.ALARM_TIME, translation_key="alarm_duration", @@ -84,9 +77,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Smart Pet Feeder - # https://developer.tuya.com/en/docs/iot/categorycwwsq?id=Kaiuz2b6vydld - "cwwsq": ( + DeviceCategory.CWWSQ: ( NumberEntityDescription( key=DPCode.MANUAL_FEED, translation_key="feed", @@ -96,27 +87,21 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { translation_key="voice_times", ), ), - # Multi-functional Sensor - # https://developer.tuya.com/en/docs/iot/categorydgnbj?id=Kaiuz3yorvzg3 - "dgnbj": ( + DeviceCategory.DGNBJ: ( NumberEntityDescription( key=DPCode.ALARM_TIME, translation_key="time", entity_category=EntityCategory.CONFIG, ), ), - # Fan - # https://developer.tuya.com/en/docs/iot/categoryfs?id=Kaiuz1xweel1c - "fs": ( + DeviceCategory.FS: ( NumberEntityDescription( key=DPCode.TEMP, translation_key="temperature", device_class=NumberDeviceClass.TEMPERATURE, ), ), - # Human Presence Sensor - # https://developer.tuya.com/en/docs/iot/categoryhps?id=Kaiuz42yhn1hs - "hps": ( + DeviceCategory.HPS: ( NumberEntityDescription( key=DPCode.SENSITIVITY, translation_key="sensitivity", @@ -140,9 +125,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { device_class=NumberDeviceClass.DISTANCE, ), ), - # Humidifier - # https://developer.tuya.com/en/docs/iot/categoryjsq?id=Kaiuz1smr440b - "jsq": ( + DeviceCategory.JSQ: ( NumberEntityDescription( key=DPCode.TEMP_SET, translation_key="temperature", @@ -154,9 +137,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { device_class=NumberDeviceClass.TEMPERATURE, ), ), - # Coffee maker - # https://developer.tuya.com/en/docs/iot/categorykfj?id=Kaiuz2p12pc7f - "kfj": ( + DeviceCategory.KFJ: ( NumberEntityDescription( key=DPCode.WATER_SET, translation_key="water_level", @@ -179,9 +160,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Alarm Host - # https://developer.tuya.com/en/docs/iot/alarm-hosts?id=K9gf48r87hyjk - "mal": ( + DeviceCategory.MAL: ( NumberEntityDescription( key=DPCode.DELAY_SET, # This setting is called "Arm Delay" in the official Tuya app @@ -203,9 +182,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Sous Vide Cooker - # https://developer.tuya.com/en/docs/iot/categorymzj?id=Kaiuz2vy130ux - "mzj": ( + DeviceCategory.MZJ: ( NumberEntityDescription( key=DPCode.COOK_TEMPERATURE, translation_key="cook_temperature", @@ -223,8 +200,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Cooking thermometer - "swtz": ( + DeviceCategory.SWTZ: ( NumberEntityDescription( key=DPCode.COOK_TEMPERATURE, translation_key="cook_temperature", @@ -237,17 +213,14 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Robot Vacuum - # https://developer.tuya.com/en/docs/iot/fsd?id=K9gf487ck1tlo - "sd": ( + DeviceCategory.SD: ( NumberEntityDescription( key=DPCode.VOLUME_SET, translation_key="volume", entity_category=EntityCategory.CONFIG, ), ), - # Smart Water Timer - "sfkzq": ( + DeviceCategory.SFKZQ: ( # Controls the irrigation duration for the water valve NumberEntityDescription( key=DPCode.COUNTDOWN_1, @@ -306,26 +279,21 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Siren Alarm - # https://developer.tuya.com/en/docs/iot/categorysgbj?id=Kaiuz37tlpbnu - "sgbj": ( + DeviceCategory.SGBJ: ( NumberEntityDescription( key=DPCode.ALARM_TIME, translation_key="time", entity_category=EntityCategory.CONFIG, ), ), - # Smart Camera - # https://developer.tuya.com/en/docs/iot/categorysp?id=Kaiuz35leyo12 - "sp": ( + DeviceCategory.SP: ( NumberEntityDescription( key=DPCode.BASIC_DEVICE_VOLUME, translation_key="volume", entity_category=EntityCategory.CONFIG, ), ), - # Fingerbot - "szjqr": ( + DeviceCategory.SZJQR: ( NumberEntityDescription( key=DPCode.ARM_DOWN_PERCENT, translation_key="move_down", @@ -344,9 +312,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Dimmer Switch - # https://developer.tuya.com/en/docs/iot/categorytgkg?id=Kaiuz0ktx7m0o - "tgkg": ( + DeviceCategory.TGKG: ( NumberEntityDescription( key=DPCode.BRIGHTNESS_MIN_1, translation_key="indexed_minimum_brightness", @@ -384,9 +350,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Dimmer Switch - # https://developer.tuya.com/en/docs/iot/categorytgkg?id=Kaiuz0ktx7m0o - "tgq": ( + DeviceCategory.TGQ: ( NumberEntityDescription( key=DPCode.BRIGHTNESS_MIN_1, translation_key="indexed_minimum_brightness", @@ -412,18 +376,14 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Thermostat - # https://developer.tuya.com/en/docs/iot/f?id=K9gf45ld5l0t9 - "wk": ( + DeviceCategory.WK: ( NumberEntityDescription( key=DPCode.TEMP_CORRECTION, translation_key="temp_correction", entity_category=EntityCategory.CONFIG, ), ), - # Micro Storage Inverter - # Energy storage and solar PV inverter system with monitoring capabilities - "xnyjcn": ( + DeviceCategory.XNYJCN: ( NumberEntityDescription( key=DPCode.BACKUP_RESERVE, translation_key="battery_backup_reserve", @@ -436,9 +396,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Tank Level Sensor - # Note: Undocumented - "ywcgq": ( + DeviceCategory.YWCGQ: ( NumberEntityDescription( key=DPCode.MAX_SET, translation_key="alarm_maximum", @@ -462,17 +420,14 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Vibration Sensor - # https://developer.tuya.com/en/docs/iot/categoryzd?id=Kaiuz3a5vrzno - "zd": ( + DeviceCategory.ZD: ( NumberEntityDescription( key=DPCode.SENSITIVITY, translation_key="sensitivity", entity_category=EntityCategory.CONFIG, ), ), - # Pool HeatPump - "znrb": ( + DeviceCategory.ZNRB: ( NumberEntityDescription( key=DPCode.TEMP_SET, translation_key="temperature", @@ -482,8 +437,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { } # Smart Camera - Low power consumption camera (duplicate of `sp`) -# Undocumented, see https://github.com/home-assistant/core/issues/132844 -NUMBERS["dghsxj"] = NUMBERS["sp"] +NUMBERS[DeviceCategory.DGHSXJ] = NUMBERS[DeviceCategory.SP] async def async_setup_entry( diff --git a/homeassistant/components/tuya/select.py b/homeassistant/components/tuya/select.py index e16642305e7..6a4d8d7b488 100644 --- a/homeassistant/components/tuya/select.py +++ b/homeassistant/components/tuya/select.py @@ -11,16 +11,13 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import TuyaConfigEntry -from .const import TUYA_DISCOVERY_NEW, DPCode, DPType +from .const import TUYA_DISCOVERY_NEW, DeviceCategory, DPCode, DPType from .entity import TuyaEntity # All descriptions can be found here. Mostly the Enum data types in the # default instructions set of each category end up being a select. -# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq -SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { - # Curtain - # https://developer.tuya.com/en/docs/iot/f?id=K9gf46o5mtfyc - "cl": ( +SELECTS: dict[DeviceCategory, tuple[SelectEntityDescription, ...]] = { + DeviceCategory.CL: ( SelectEntityDescription( key=DPCode.CONTROL_BACK_MODE, entity_category=EntityCategory.CONFIG, @@ -32,18 +29,14 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_key="curtain_mode", ), ), - # CO2 Detector - # https://developer.tuya.com/en/docs/iot/categoryco2bj?id=Kaiuz3wes7yuy - "co2bj": ( + DeviceCategory.CO2BJ: ( SelectEntityDescription( key=DPCode.ALARM_VOLUME, translation_key="volume", entity_category=EntityCategory.CONFIG, ), ), - # Dehumidifier - # https://developer.tuya.com/en/docs/iot/categorycs?id=Kaiuz1vcz4dha - "cs": ( + DeviceCategory.CS: ( SelectEntityDescription( key=DPCode.COUNTDOWN_SET, entity_category=EntityCategory.CONFIG, @@ -55,27 +48,21 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Smart Odor Eliminator-Pro - # Undocumented, see https://github.com/orgs/home-assistant/discussions/79 - "cwjwq": ( + DeviceCategory.CWJWQ: ( SelectEntityDescription( key=DPCode.WORK_MODE, entity_category=EntityCategory.CONFIG, translation_key="odor_elimination_mode", ), ), - # Multi-functional Sensor - # https://developer.tuya.com/en/docs/iot/categorydgnbj?id=Kaiuz3yorvzg3 - "dgnbj": ( + DeviceCategory.DGNBJ: ( SelectEntityDescription( key=DPCode.ALARM_VOLUME, translation_key="volume", entity_category=EntityCategory.CONFIG, ), ), - # Electric Blanket - # https://developer.tuya.com/en/docs/iot/categorydr?id=Kaiuz22dyc66p - "dr": ( + DeviceCategory.DR: ( SelectEntityDescription( key=DPCode.LEVEL, icon="mdi:thermometer-lines", @@ -94,9 +81,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_placeholders={"index": "2"}, ), ), - # Fan - # https://developer.tuya.com/en/docs/iot/f?id=K9gf45vs7vkge - "fs": ( + DeviceCategory.FS: ( SelectEntityDescription( key=DPCode.FAN_VERTICAL, entity_category=EntityCategory.CONFIG, @@ -118,9 +103,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_key="countdown", ), ), - # Humidifier - # https://developer.tuya.com/en/docs/iot/categoryjsq?id=Kaiuz1smr440b - "jsq": ( + DeviceCategory.JSQ: ( SelectEntityDescription( key=DPCode.SPRAY_MODE, entity_category=EntityCategory.CONFIG, @@ -147,9 +130,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_key="countdown", ), ), - # Coffee maker - # https://developer.tuya.com/en/docs/iot/categorykfj?id=Kaiuz2p12pc7f - "kfj": ( + DeviceCategory.KFJ: ( SelectEntityDescription( key=DPCode.CUP_NUMBER, translation_key="cups", @@ -169,9 +150,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_key="mode", ), ), - # Switch - # https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s - "kg": ( + DeviceCategory.KG: ( SelectEntityDescription( key=DPCode.RELAY_STATUS, entity_category=EntityCategory.CONFIG, @@ -183,9 +162,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_key="light_mode", ), ), - # Air Purifier - # https://developer.tuya.com/en/docs/iot/f?id=K9gf46h2s6dzm - "kj": ( + DeviceCategory.KJ: ( SelectEntityDescription( key=DPCode.COUNTDOWN, entity_category=EntityCategory.CONFIG, @@ -197,17 +174,13 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_key="countdown", ), ), - # Heater - # https://developer.tuya.com/en/docs/iot/categoryqn?id=Kaiuz18kih0sm - "qn": ( + DeviceCategory.QN: ( SelectEntityDescription( key=DPCode.LEVEL, translation_key="temperature_level", ), ), - # Robot Vacuum - # https://developer.tuya.com/en/docs/iot/fsd?id=K9gf487ck1tlo - "sd": ( + DeviceCategory.SD: ( SelectEntityDescription( key=DPCode.CISTERN, entity_category=EntityCategory.CONFIG, @@ -224,8 +197,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_key="vacuum_mode", ), ), - # Smart Water Timer - "sfkzq": ( + DeviceCategory.SFKZQ: ( # Irrigation will not be run within this set delay period SelectEntityDescription( key=DPCode.WEATHER_DELAY, @@ -233,9 +205,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Siren Alarm - # https://developer.tuya.com/en/docs/iot/categorysgbj?id=Kaiuz37tlpbnu - "sgbj": ( + DeviceCategory.SGBJ: ( SelectEntityDescription( key=DPCode.ALARM_VOLUME, translation_key="volume", @@ -247,8 +217,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Electric desk - "sjz": ( + DeviceCategory.SJZ: ( SelectEntityDescription( key=DPCode.LEVEL, translation_key="desk_level", @@ -260,9 +229,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), - # Smart Camera - # https://developer.tuya.com/en/docs/iot/categorysp?id=Kaiuz35leyo12 - "sp": ( + DeviceCategory.SP: ( SelectEntityDescription( key=DPCode.IPC_WORK_MODE, entity_category=EntityCategory.CONFIG, @@ -294,17 +261,14 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_key="motion_sensitivity", ), ), - # Fingerbot - "szjqr": ( + DeviceCategory.SZJQR: ( SelectEntityDescription( key=DPCode.MODE, entity_category=EntityCategory.CONFIG, translation_key="fingerbot_mode", ), ), - # IoT Switch? - # Note: Undocumented - "tdq": ( + DeviceCategory.TDQ: ( SelectEntityDescription( key=DPCode.RELAY_STATUS, entity_category=EntityCategory.CONFIG, @@ -316,9 +280,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_key="light_mode", ), ), - # Dimmer Switch - # https://developer.tuya.com/en/docs/iot/categorytgkg?id=Kaiuz0ktx7m0o - "tgkg": ( + DeviceCategory.TGKG: ( SelectEntityDescription( key=DPCode.RELAY_STATUS, entity_category=EntityCategory.CONFIG, @@ -348,9 +310,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_placeholders={"index": "3"}, ), ), - # Dimmer - # https://developer.tuya.com/en/docs/iot/tgq?id=Kaof8ke9il4k4 - "tgq": ( + DeviceCategory.TGQ: ( SelectEntityDescription( key=DPCode.LED_TYPE_1, entity_category=EntityCategory.CONFIG, @@ -364,9 +324,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { translation_placeholders={"index": "2"}, ), ), - # Micro Storage Inverter - # Energy storage and solar PV inverter system with monitoring capabilities - "xnyjcn": ( + DeviceCategory.XNYJCN: ( SelectEntityDescription( key=DPCode.WORK_MODE, translation_key="inverter_work_mode", @@ -376,16 +334,13 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { } # Socket (duplicate of `kg`) -# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s -SELECTS["cz"] = SELECTS["kg"] +SELECTS[DeviceCategory.CZ] = SELECTS[DeviceCategory.KG] # Smart Camera - Low power consumption camera (duplicate of `sp`) -# Undocumented, see https://github.com/home-assistant/core/issues/132844 -SELECTS["dghsxj"] = SELECTS["sp"] +SELECTS[DeviceCategory.DGHSXJ] = SELECTS[DeviceCategory.SP] # Power Socket (duplicate of `kg`) -# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s -SELECTS["pc"] = SELECTS["kg"] +SELECTS[DeviceCategory.PC] = SELECTS[DeviceCategory.KG] async def async_setup_entry( diff --git a/homeassistant/components/tuya/siren.py b/homeassistant/components/tuya/siren.py index e6849eb767e..8c29684ba9f 100644 --- a/homeassistant/components/tuya/siren.py +++ b/homeassistant/components/tuya/siren.py @@ -17,37 +17,27 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import TuyaConfigEntry -from .const import TUYA_DISCOVERY_NEW, DPCode +from .const import TUYA_DISCOVERY_NEW, DeviceCategory, DPCode from .entity import TuyaEntity -# All descriptions can be found here: -# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq -SIRENS: dict[str, tuple[SirenEntityDescription, ...]] = { - # CO2 Detector - # https://developer.tuya.com/en/docs/iot/categoryco2bj?id=Kaiuz3wes7yuy - "co2bj": ( +SIRENS: dict[DeviceCategory, tuple[SirenEntityDescription, ...]] = { + DeviceCategory.CO2BJ: ( SirenEntityDescription( key=DPCode.ALARM_SWITCH, entity_category=EntityCategory.CONFIG, ), ), - # Multi-functional Sensor - # https://developer.tuya.com/en/docs/iot/categorydgnbj?id=Kaiuz3yorvzg3 - "dgnbj": ( + DeviceCategory.DGNBJ: ( SirenEntityDescription( key=DPCode.ALARM_SWITCH, ), ), - # Siren Alarm - # https://developer.tuya.com/en/docs/iot/categorysgbj?id=Kaiuz37tlpbnu - "sgbj": ( + DeviceCategory.SGBJ: ( SirenEntityDescription( key=DPCode.ALARM_SWITCH, ), ), - # Smart Camera - # https://developer.tuya.com/en/docs/iot/categorysp?id=Kaiuz35leyo12 - "sp": ( + DeviceCategory.SP: ( SirenEntityDescription( key=DPCode.SIREN_SWITCH, ), @@ -55,8 +45,7 @@ SIRENS: dict[str, tuple[SirenEntityDescription, ...]] = { } # Smart Camera - Low power consumption camera (duplicate of `sp`) -# Undocumented, see https://github.com/home-assistant/core/issues/132844 -SIRENS["dghsxj"] = SIRENS["sp"] +SIRENS[DeviceCategory.DGHSXJ] = SIRENS[DeviceCategory.SP] async def async_setup_entry( diff --git a/homeassistant/components/tuya/vacuum.py b/homeassistant/components/tuya/vacuum.py index 0d5ea1ee70d..8e0674ad23a 100644 --- a/homeassistant/components/tuya/vacuum.py +++ b/homeassistant/components/tuya/vacuum.py @@ -16,7 +16,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import TuyaConfigEntry -from .const import TUYA_DISCOVERY_NEW, DPCode, DPType +from .const import TUYA_DISCOVERY_NEW, DeviceCategory, DPCode, DPType from .entity import TuyaEntity from .models import EnumTypeData from .util import get_dpcode @@ -63,7 +63,7 @@ async def async_setup_entry( entities: list[TuyaVacuumEntity] = [] for device_id in device_ids: device = manager.device_map[device_id] - if device.category == "sd": + if device.category == DeviceCategory.SD: entities.append(TuyaVacuumEntity(device, manager)) async_add_entities(entities) diff --git a/homeassistant/components/tuya/valve.py b/homeassistant/components/tuya/valve.py index dcb63c00cc9..f14d605c19a 100644 --- a/homeassistant/components/tuya/valve.py +++ b/homeassistant/components/tuya/valve.py @@ -15,15 +15,11 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import TuyaConfigEntry -from .const import TUYA_DISCOVERY_NEW, DPCode +from .const import TUYA_DISCOVERY_NEW, DeviceCategory, DPCode from .entity import TuyaEntity -# All descriptions can be found here. Mostly the Boolean data types in the -# default instruction set of each category end up being a Valve. -# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq -VALVES: dict[str, tuple[ValveEntityDescription, ...]] = { - # Smart Water Timer - "sfkzq": ( +VALVES: dict[DeviceCategory, tuple[ValveEntityDescription, ...]] = { + DeviceCategory.SFKZQ: ( ValveEntityDescription( key=DPCode.SWITCH, translation_key="valve",