diff --git a/homeassistant/components/tuya/binary_sensor.py b/homeassistant/components/tuya/binary_sensor.py index a851cbdbce5..a083cfd73f5 100644 --- a/homeassistant/components/tuya/binary_sensor.py +++ b/homeassistant/components/tuya/binary_sensor.py @@ -9,6 +9,7 @@ from homeassistant.components.binary_sensor import ( DEVICE_CLASS_DOOR, DEVICE_CLASS_MOTION, DEVICE_CLASS_SAFETY, + DEVICE_CLASS_TAMPER, DEVICE_CLASS_VIBRATION, BinarySensorEntity, BinarySensorEntityDescription, @@ -50,6 +51,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { TuyaBinarySensorEntityDescription( key=DPCode.TEMPER_ALARM, name="Tamper", + device_class=DEVICE_CLASS_TAMPER, entity_category=ENTITY_CATEGORY_DIAGNOSTIC, ), ), @@ -59,6 +61,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { TuyaBinarySensorEntityDescription( key=DPCode.TEMPER_ALARM, name="Tamper", + device_class=DEVICE_CLASS_TAMPER, entity_category=ENTITY_CATEGORY_DIAGNOSTIC, ), ), @@ -73,6 +76,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { TuyaBinarySensorEntityDescription( key=DPCode.TEMPER_ALARM, name="Tamper", + device_class=DEVICE_CLASS_TAMPER, entity_category=ENTITY_CATEGORY_DIAGNOSTIC, ), ), @@ -86,6 +90,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { TuyaBinarySensorEntityDescription( key=DPCode.TEMPER_ALARM, name="Tamper", + device_class=DEVICE_CLASS_TAMPER, entity_category=ENTITY_CATEGORY_DIAGNOSTIC, ), ), diff --git a/homeassistant/components/tuya/number.py b/homeassistant/components/tuya/number.py index 63d94195233..34325e63d98 100644 --- a/homeassistant/components/tuya/number.py +++ b/homeassistant/components/tuya/number.py @@ -28,24 +28,24 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { key=DPCode.WATER_SET, name="Water Level", icon="mdi:cup-water", - entity_registry_enabled_default=False, + entity_category=ENTITY_CATEGORY_CONFIG, ), NumberEntityDescription( key=DPCode.TEMP_SET, name="Temperature", icon="mdi:thermometer", - entity_registry_enabled_default=False, + entity_category=ENTITY_CATEGORY_CONFIG, ), NumberEntityDescription( key=DPCode.WARM_TIME, name="Heat Preservation Time", icon="mdi:timer", - entity_registry_enabled_default=False, + entity_category=ENTITY_CATEGORY_CONFIG, ), NumberEntityDescription( key=DPCode.POWDER_SET, name="Powder", - entity_registry_enabled_default=False, + entity_category=ENTITY_CATEGORY_CONFIG, ), ), # Siren Alarm diff --git a/homeassistant/components/tuya/select.py b/homeassistant/components/tuya/select.py index 3c99e131284..762c105632f 100644 --- a/homeassistant/components/tuya/select.py +++ b/homeassistant/components/tuya/select.py @@ -33,14 +33,17 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { key=DPCode.CONCENTRATION_SET, name="Concentration", icon="mdi:altimeter", + entity_category=ENTITY_CATEGORY_CONFIG, ), SelectEntityDescription( key=DPCode.MATERIAL, name="Material", + entity_category=ENTITY_CATEGORY_CONFIG, ), SelectEntityDescription( key=DPCode.MODE, name="Mode", + icon="mdi:coffee", ), ), # Siren Alarm diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index 4bba17284cd..fc12b9b9ace 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -39,6 +39,24 @@ from .const import ( UnitOfMeasurement, ) +# Commonly used battery sensors, that are re-used in the sensors down below. +BATTERY_SENSORS: tuple[SensorEntityDescription, ...] = ( + 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", + icon="mdi:battery", + entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + ), +) + # All descriptions can be found here. Mostly the Integer data types in the # default status set of each category (that don't have a set instruction) # end up being a sensor. @@ -46,22 +64,7 @@ from .const import ( SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { # Door Window Sensor # https://developer.tuya.com/en/docs/iot/s?id=K9gf48hm02l8m - "mcs": ( - 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", - icon="mdi:battery", - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, - ), - ), + "mcs": BATTERY_SENSORS, # Switch # https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s "kg": ( @@ -119,74 +122,17 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { device_class=DEVICE_CLASS_CO2, state_class=STATE_CLASS_MEASUREMENT, ), - 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", - icon="mdi:battery", - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, - ), + *BATTERY_SENSORS, ), # PIR Detector # https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80 - "pir": ( - 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", - icon="mdi:battery", - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, - ), - ), + "pir": BATTERY_SENSORS, # Vibration Sensor # https://developer.tuya.com/en/docs/iot/categoryzd?id=Kaiuz3a5vrzno - "zd": ( - 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", - icon="mdi:battery", - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, - ), - ), + "zd": BATTERY_SENSORS, # 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, - ), - ), + "sos": BATTERY_SENSORS, } # Socket (duplicate of `kg`) diff --git a/homeassistant/components/tuya/switch.py b/homeassistant/components/tuya/switch.py index a828b6c6936..d4dddb5910a 100644 --- a/homeassistant/components/tuya/switch.py +++ b/homeassistant/components/tuya/switch.py @@ -35,6 +35,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { SwitchEntityDescription( key=DPCode.WARM, name="Heat preservation", + entity_category=ENTITY_CATEGORY_CONFIG, ), ), # Pet Water Feeder @@ -44,11 +45,13 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.FILTER_RESET, name="Filter reset", icon="mdi:filter", + entity_category=ENTITY_CATEGORY_CONFIG, ), SwitchEntityDescription( key=DPCode.PUMP_RESET, name="Water pump reset", icon="mdi:pump", + entity_category=ENTITY_CATEGORY_CONFIG, ), SwitchEntityDescription( key=DPCode.SWITCH, @@ -58,7 +61,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.WATER_RESET, name="Reset of water usage days", icon="mdi:water-sync", - entity_registry_enabled_default=False, + entity_category=ENTITY_CATEGORY_CONFIG, ), ), # Cirquit Breaker @@ -67,6 +70,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.CHILD_LOCK, name="Child Lock", icon="mdi:account-lock", + entity_category=ENTITY_CATEGORY_CONFIG, ), SwitchEntityDescription( key=DPCode.SWITCH_1, @@ -80,6 +84,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.CHILD_LOCK, name="Child Lock", icon="mdi:account-lock", + entity_category=ENTITY_CATEGORY_CONFIG, ), SwitchEntityDescription( key=DPCode.SWITCH_1, @@ -148,17 +153,19 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.ANION, name="Ionizer", icon="mdi:minus-circle-outline", + entity_category=ENTITY_CATEGORY_CONFIG, ), SwitchEntityDescription( key=DPCode.FILTER_RESET, name="Filter cartridge reset", icon="mdi:filter", - entity_registry_enabled_default=False, + entity_category=ENTITY_CATEGORY_CONFIG, ), SwitchEntityDescription( key=DPCode.LOCK, name="Child lock", icon="mdi:account-lock", + entity_category=ENTITY_CATEGORY_CONFIG, ), SwitchEntityDescription( key=DPCode.SWITCH, @@ -168,6 +175,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.WET, name="Humidification", icon="mdi:water-percent", + entity_category=ENTITY_CATEGORY_CONFIG, ), ), # Power Socket @@ -177,6 +185,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.CHILD_LOCK, name="Child Lock", icon="mdi:account-lock", + entity_category=ENTITY_CATEGORY_CONFIG, ), SwitchEntityDescription( key=DPCode.SWITCH_1, @@ -243,11 +252,12 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { "sgbj": ( SwitchEntityDescription( key=DPCode.MUFFLING, - name="Muffling", + name="Mute", entity_category=ENTITY_CATEGORY_CONFIG, ), ), # Diffuser + # https://developer.tuya.com/en/docs/iot/categoryxxj?id=Kaiuz1f9mo6bl "xxj": ( SwitchEntityDescription( key=DPCode.SWITCH, @@ -262,7 +272,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.SWITCH_VOICE, name="Voice", icon="mdi:account-voice", - entity_registry_enabled_default=False, + entity_category=ENTITY_CATEGORY_CONFIG, ), ), }