diff --git a/homeassistant/components/tuya/binary_sensor.py b/homeassistant/components/tuya/binary_sensor.py index 12fbc963942..c9a1ab598c3 100644 --- a/homeassistant/components/tuya/binary_sensor.py +++ b/homeassistant/components/tuya/binary_sensor.py @@ -6,21 +6,14 @@ from dataclasses import dataclass from tuya_iot import TuyaDevice, TuyaDeviceManager from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_DOOR, - DEVICE_CLASS_GAS, - DEVICE_CLASS_MOISTURE, - DEVICE_CLASS_MOTION, - DEVICE_CLASS_SAFETY, - DEVICE_CLASS_SMOKE, - DEVICE_CLASS_TAMPER, - DEVICE_CLASS_VIBRATION, + BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import HomeAssistantTuyaData @@ -43,8 +36,8 @@ class TuyaBinarySensorEntityDescription(BinarySensorEntityDescription): TAMPER_BINARY_SENSOR = TuyaBinarySensorEntityDescription( key=DPCode.TEMPER_ALARM, name="Tamper", - device_class=DEVICE_CLASS_TAMPER, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=BinarySensorDeviceClass.TAMPER, + entity_category=EntityCategory.DIAGNOSTIC, ) @@ -58,7 +51,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "co2bj": ( TuyaBinarySensorEntityDescription( key=DPCode.CO2_STATE, - device_class=DEVICE_CLASS_SAFETY, + device_class=BinarySensorDeviceClass.SAFETY, on_value="alarm", ), TAMPER_BINARY_SENSOR, @@ -68,12 +61,12 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "cobj": ( TuyaBinarySensorEntityDescription( key=DPCode.CO_STATE, - device_class=DEVICE_CLASS_SAFETY, + device_class=BinarySensorDeviceClass.SAFETY, on_value="1", ), TuyaBinarySensorEntityDescription( key=DPCode.CO_STATUS, - device_class=DEVICE_CLASS_SAFETY, + device_class=BinarySensorDeviceClass.SAFETY, on_value="alarm", ), TAMPER_BINARY_SENSOR, @@ -83,7 +76,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "hps": ( TuyaBinarySensorEntityDescription( key=DPCode.PRESENCE_STATE, - device_class=DEVICE_CLASS_MOTION, + device_class=BinarySensorDeviceClass.MOTION, on_value="presence", ), ), @@ -92,7 +85,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "jqbj": ( TuyaBinarySensorEntityDescription( key=DPCode.CH2O_STATE, - device_class=DEVICE_CLASS_SAFETY, + device_class=BinarySensorDeviceClass.SAFETY, on_value="alarm", ), TAMPER_BINARY_SENSOR, @@ -102,7 +95,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "jwbj": ( TuyaBinarySensorEntityDescription( key=DPCode.CH4_SENSOR_STATE, - device_class=DEVICE_CLASS_GAS, + device_class=BinarySensorDeviceClass.GAS, on_value="alarm", ), TAMPER_BINARY_SENSOR, @@ -112,7 +105,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "mcs": ( TuyaBinarySensorEntityDescription( key=DPCode.DOORCONTACT_STATE, - device_class=DEVICE_CLASS_DOOR, + device_class=BinarySensorDeviceClass.DOOR, ), TAMPER_BINARY_SENSOR, ), @@ -122,8 +115,8 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { TuyaBinarySensorEntityDescription( key=DPCode.TEMPER_ALARM, name="Tamper", - device_class=DEVICE_CLASS_TAMPER, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=BinarySensorDeviceClass.TAMPER, + entity_category=EntityCategory.DIAGNOSTIC, ), TAMPER_BINARY_SENSOR, ), @@ -132,7 +125,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "pir": ( TuyaBinarySensorEntityDescription( key=DPCode.PIR, - device_class=DEVICE_CLASS_MOTION, + device_class=BinarySensorDeviceClass.MOTION, on_value="pir", ), TAMPER_BINARY_SENSOR, @@ -142,7 +135,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "pm2.5": ( TuyaBinarySensorEntityDescription( key=DPCode.PM25_STATE, - device_class=DEVICE_CLASS_SAFETY, + device_class=BinarySensorDeviceClass.SAFETY, on_value="alarm", ), TAMPER_BINARY_SENSOR, @@ -152,12 +145,12 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "rqbj": ( TuyaBinarySensorEntityDescription( key=DPCode.GAS_SENSOR_STATUS, - device_class=DEVICE_CLASS_GAS, + device_class=BinarySensorDeviceClass.GAS, on_value="alarm", ), TuyaBinarySensorEntityDescription( key=DPCode.GAS_SENSOR_STATE, - device_class=DEVICE_CLASS_GAS, + device_class=BinarySensorDeviceClass.GAS, on_value="1", ), TAMPER_BINARY_SENSOR, @@ -167,7 +160,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "sj": ( TuyaBinarySensorEntityDescription( key=DPCode.WATERSENSOR_STATE, - device_class=DEVICE_CLASS_MOISTURE, + device_class=BinarySensorDeviceClass.MOISTURE, on_value="alarm", ), TAMPER_BINARY_SENSOR, @@ -177,7 +170,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "sos": ( TuyaBinarySensorEntityDescription( key=DPCode.SOS_STATE, - device_class=DEVICE_CLASS_SAFETY, + device_class=BinarySensorDeviceClass.SAFETY, ), TAMPER_BINARY_SENSOR, ), @@ -186,7 +179,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "voc": ( TuyaBinarySensorEntityDescription( key=DPCode.VOC_STATE, - device_class=DEVICE_CLASS_SAFETY, + device_class=BinarySensorDeviceClass.SAFETY, on_value="alarm", ), TAMPER_BINARY_SENSOR, @@ -208,12 +201,12 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { "ywbj": ( TuyaBinarySensorEntityDescription( key=DPCode.SMOKE_SENSOR_STATUS, - device_class=DEVICE_CLASS_SMOKE, + device_class=BinarySensorDeviceClass.SMOKE, on_value="alarm", ), TuyaBinarySensorEntityDescription( key=DPCode.SMOKE_SENSOR_STATE, - device_class=DEVICE_CLASS_SMOKE, + device_class=BinarySensorDeviceClass.SMOKE, on_value="1", ), TAMPER_BINARY_SENSOR, @@ -225,7 +218,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { key=f"{DPCode.SHOCK_STATE}_vibration", dpcode=DPCode.SHOCK_STATE, name="Vibration", - device_class=DEVICE_CLASS_VIBRATION, + device_class=BinarySensorDeviceClass.VIBRATION, on_value="vibration", ), TuyaBinarySensorEntityDescription( diff --git a/homeassistant/components/tuya/button.py b/homeassistant/components/tuya/button.py index d07d6947272..cd410db24cc 100644 --- a/homeassistant/components/tuya/button.py +++ b/homeassistant/components/tuya/button.py @@ -7,9 +7,9 @@ from tuya_iot import TuyaDevice, TuyaDeviceManager from homeassistant.components.button import ButtonEntity, ButtonEntityDescription from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ENTITY_CATEGORY_CONFIG from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import HomeAssistantTuyaData @@ -26,31 +26,31 @@ BUTTONS: dict[str, tuple[ButtonEntityDescription, ...]] = { key=DPCode.RESET_DUSTER_CLOTH, name="Reset Duster Cloth", icon="mdi:restart", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ButtonEntityDescription( key=DPCode.RESET_EDGE_BRUSH, name="Reset Edge Brush", icon="mdi:restart", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ButtonEntityDescription( key=DPCode.RESET_FILTER, name="Reset Filter", icon="mdi:air-filter", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ButtonEntityDescription( key=DPCode.RESET_MAP, name="Reset Map", icon="mdi:map-marker-remove", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ButtonEntityDescription( key=DPCode.RESET_ROLL_BRUSH, name="Reset Roll Brush", icon="mdi:restart", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), } diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index dd229011c2a..66142998691 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -7,38 +7,12 @@ from enum import Enum from tuya_iot import TuyaCloudOpenAPIEndpoint +from homeassistant.components.sensor import SensorDeviceClass from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_MILLION, - DEVICE_CLASS_AQI, - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_CO, - DEVICE_CLASS_CO2, - DEVICE_CLASS_CURRENT, - DEVICE_CLASS_DATE, - DEVICE_CLASS_ENERGY, - DEVICE_CLASS_GAS, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_ILLUMINANCE, - DEVICE_CLASS_MONETARY, - DEVICE_CLASS_NITROGEN_DIOXIDE, - DEVICE_CLASS_NITROGEN_MONOXIDE, - DEVICE_CLASS_NITROUS_OXIDE, - DEVICE_CLASS_OZONE, - DEVICE_CLASS_PM1, - DEVICE_CLASS_PM10, - DEVICE_CLASS_PM25, - DEVICE_CLASS_POWER, - DEVICE_CLASS_POWER_FACTOR, - DEVICE_CLASS_PRESSURE, - DEVICE_CLASS_SIGNAL_STRENGTH, - DEVICE_CLASS_SULPHUR_DIOXIDE, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_TIMESTAMP, - DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, - DEVICE_CLASS_VOLTAGE, ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_MILLIAMPERE, ELECTRIC_POTENTIAL_MILLIVOLT, @@ -355,33 +329,33 @@ UNITS = ( unit="", aliases={" "}, device_classes={ - DEVICE_CLASS_AQI, - DEVICE_CLASS_DATE, - DEVICE_CLASS_MONETARY, - DEVICE_CLASS_TIMESTAMP, + SensorDeviceClass.AQI, + SensorDeviceClass.DATE, + SensorDeviceClass.MONETARY, + SensorDeviceClass.TIMESTAMP, }, ), UnitOfMeasurement( unit=PERCENTAGE, aliases={"pct", "percent"}, device_classes={ - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_POWER_FACTOR, + SensorDeviceClass.BATTERY, + SensorDeviceClass.HUMIDITY, + SensorDeviceClass.POWER_FACTOR, }, ), UnitOfMeasurement( unit=CONCENTRATION_PARTS_PER_MILLION, device_classes={ - DEVICE_CLASS_CO, - DEVICE_CLASS_CO2, + SensorDeviceClass.CO, + SensorDeviceClass.CO2, }, ), UnitOfMeasurement( unit=CONCENTRATION_PARTS_PER_BILLION, device_classes={ - DEVICE_CLASS_CO, - DEVICE_CLASS_CO2, + SensorDeviceClass.CO, + SensorDeviceClass.CO2, }, conversion_unit=CONCENTRATION_PARTS_PER_MILLION, conversion_fn=lambda x: x / 1000, @@ -389,73 +363,73 @@ UNITS = ( UnitOfMeasurement( unit=ELECTRIC_CURRENT_AMPERE, aliases={"a", "ampere"}, - device_classes={DEVICE_CLASS_CURRENT}, + device_classes={SensorDeviceClass.CURRENT}, ), UnitOfMeasurement( unit=ELECTRIC_CURRENT_MILLIAMPERE, aliases={"ma", "milliampere"}, - device_classes={DEVICE_CLASS_CURRENT}, + device_classes={SensorDeviceClass.CURRENT}, conversion_unit=ELECTRIC_CURRENT_AMPERE, conversion_fn=lambda x: x / 1000, ), UnitOfMeasurement( unit=ENERGY_WATT_HOUR, aliases={"wh", "watthour"}, - device_classes={DEVICE_CLASS_ENERGY}, + device_classes={SensorDeviceClass.ENERGY}, ), UnitOfMeasurement( unit=ENERGY_KILO_WATT_HOUR, aliases={"kwh", "kilowatt-hour", "kW·h"}, - device_classes={DEVICE_CLASS_ENERGY}, + device_classes={SensorDeviceClass.ENERGY}, ), UnitOfMeasurement( unit=VOLUME_CUBIC_FEET, aliases={"ft3"}, - device_classes={DEVICE_CLASS_GAS}, + device_classes={SensorDeviceClass.GAS}, ), UnitOfMeasurement( unit=VOLUME_CUBIC_METERS, aliases={"m3"}, - device_classes={DEVICE_CLASS_GAS}, + device_classes={SensorDeviceClass.GAS}, ), UnitOfMeasurement( unit=LIGHT_LUX, aliases={"lux"}, - device_classes={DEVICE_CLASS_ILLUMINANCE}, + device_classes={SensorDeviceClass.ILLUMINANCE}, ), UnitOfMeasurement( unit="lm", aliases={"lum", "lumen"}, - device_classes={DEVICE_CLASS_ILLUMINANCE}, + device_classes={SensorDeviceClass.ILLUMINANCE}, ), UnitOfMeasurement( unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, aliases={"ug/m3", "µg/m3", "ug/m³"}, device_classes={ - DEVICE_CLASS_NITROGEN_DIOXIDE, - DEVICE_CLASS_NITROGEN_MONOXIDE, - DEVICE_CLASS_NITROUS_OXIDE, - DEVICE_CLASS_OZONE, - DEVICE_CLASS_PM1, - DEVICE_CLASS_PM25, - DEVICE_CLASS_PM10, - DEVICE_CLASS_SULPHUR_DIOXIDE, - DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, + SensorDeviceClass.NITROGEN_DIOXIDE, + SensorDeviceClass.NITROGEN_MONOXIDE, + SensorDeviceClass.NITROUS_OXIDE, + SensorDeviceClass.OZONE, + SensorDeviceClass.PM1, + SensorDeviceClass.PM25, + SensorDeviceClass.PM10, + SensorDeviceClass.SULPHUR_DIOXIDE, + SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS, }, ), UnitOfMeasurement( unit=CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER, aliases={"mg/m3"}, device_classes={ - DEVICE_CLASS_NITROGEN_DIOXIDE, - DEVICE_CLASS_NITROGEN_MONOXIDE, - DEVICE_CLASS_NITROUS_OXIDE, - DEVICE_CLASS_OZONE, - DEVICE_CLASS_PM1, - DEVICE_CLASS_PM25, - DEVICE_CLASS_PM10, - DEVICE_CLASS_SULPHUR_DIOXIDE, - DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, + SensorDeviceClass.NITROGEN_DIOXIDE, + SensorDeviceClass.NITROGEN_MONOXIDE, + SensorDeviceClass.NITROUS_OXIDE, + SensorDeviceClass.OZONE, + SensorDeviceClass.PM1, + SensorDeviceClass.PM25, + SensorDeviceClass.PM10, + SensorDeviceClass.SULPHUR_DIOXIDE, + SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS, }, conversion_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, conversion_fn=lambda x: x * 1000, @@ -463,69 +437,69 @@ UNITS = ( UnitOfMeasurement( unit=POWER_WATT, aliases={"watt"}, - device_classes={DEVICE_CLASS_POWER}, + device_classes={SensorDeviceClass.POWER}, ), UnitOfMeasurement( unit=POWER_KILO_WATT, aliases={"kilowatt"}, - device_classes={DEVICE_CLASS_POWER}, + device_classes={SensorDeviceClass.POWER}, ), UnitOfMeasurement( unit=PRESSURE_BAR, - device_classes={DEVICE_CLASS_PRESSURE}, + device_classes={SensorDeviceClass.PRESSURE}, ), UnitOfMeasurement( unit=PRESSURE_MBAR, aliases={"millibar"}, - device_classes={DEVICE_CLASS_PRESSURE}, + device_classes={SensorDeviceClass.PRESSURE}, ), UnitOfMeasurement( unit=PRESSURE_HPA, aliases={"hpa", "hectopascal"}, - device_classes={DEVICE_CLASS_PRESSURE}, + device_classes={SensorDeviceClass.PRESSURE}, ), UnitOfMeasurement( unit=PRESSURE_INHG, aliases={"inhg"}, - device_classes={DEVICE_CLASS_PRESSURE}, + device_classes={SensorDeviceClass.PRESSURE}, ), UnitOfMeasurement( unit=PRESSURE_PSI, - device_classes={DEVICE_CLASS_PRESSURE}, + device_classes={SensorDeviceClass.PRESSURE}, ), UnitOfMeasurement( unit=PRESSURE_PA, - device_classes={DEVICE_CLASS_PRESSURE}, + device_classes={SensorDeviceClass.PRESSURE}, ), UnitOfMeasurement( unit=SIGNAL_STRENGTH_DECIBELS, aliases={"db"}, - device_classes={DEVICE_CLASS_SIGNAL_STRENGTH}, + device_classes={SensorDeviceClass.SIGNAL_STRENGTH}, ), UnitOfMeasurement( unit=SIGNAL_STRENGTH_DECIBELS_MILLIWATT, aliases={"dbm"}, - device_classes={DEVICE_CLASS_SIGNAL_STRENGTH}, + device_classes={SensorDeviceClass.SIGNAL_STRENGTH}, ), UnitOfMeasurement( unit=TEMP_CELSIUS, aliases={"°c", "c", "celsius"}, - device_classes={DEVICE_CLASS_TEMPERATURE}, + device_classes={SensorDeviceClass.TEMPERATURE}, ), UnitOfMeasurement( unit=TEMP_FAHRENHEIT, aliases={"°f", "f", "fahrenheit"}, - device_classes={DEVICE_CLASS_TEMPERATURE}, + device_classes={SensorDeviceClass.TEMPERATURE}, ), UnitOfMeasurement( unit=ELECTRIC_POTENTIAL_VOLT, aliases={"volt"}, - device_classes={DEVICE_CLASS_VOLTAGE}, + device_classes={SensorDeviceClass.VOLTAGE}, ), UnitOfMeasurement( unit=ELECTRIC_POTENTIAL_MILLIVOLT, aliases={"mv", "millivolt"}, - device_classes={DEVICE_CLASS_VOLTAGE}, + device_classes={SensorDeviceClass.VOLTAGE}, conversion_unit=ELECTRIC_POTENTIAL_VOLT, conversion_fn=lambda x: x / 1000, ), diff --git a/homeassistant/components/tuya/cover.py b/homeassistant/components/tuya/cover.py index 2598429dda3..09ae829f382 100644 --- a/homeassistant/components/tuya/cover.py +++ b/homeassistant/components/tuya/cover.py @@ -10,14 +10,12 @@ from tuya_iot import TuyaDevice, TuyaDeviceManager from homeassistant.components.cover import ( ATTR_POSITION, ATTR_TILT_POSITION, - DEVICE_CLASS_BLIND, - DEVICE_CLASS_CURTAIN, - DEVICE_CLASS_GARAGE, SUPPORT_CLOSE, SUPPORT_OPEN, SUPPORT_SET_POSITION, SUPPORT_SET_TILT_POSITION, SUPPORT_STOP, + CoverDeviceClass, CoverEntity, CoverEntityDescription, ) @@ -53,21 +51,21 @@ COVERS: dict[str, tuple[TuyaCoverEntityDescription, ...]] = { current_state=DPCode.SITUATION_SET, current_position=DPCode.PERCENT_STATE, set_position=DPCode.PERCENT_CONTROL, - device_class=DEVICE_CLASS_CURTAIN, + device_class=CoverDeviceClass.CURTAIN, ), TuyaCoverEntityDescription( key=DPCode.CONTROL_2, name="Curtain 2", current_position=DPCode.PERCENT_STATE_2, set_position=DPCode.PERCENT_CONTROL_2, - device_class=DEVICE_CLASS_CURTAIN, + device_class=CoverDeviceClass.CURTAIN, ), TuyaCoverEntityDescription( key=DPCode.CONTROL_3, name="Curtain 3", current_position=DPCode.PERCENT_STATE_3, set_position=DPCode.PERCENT_CONTROL_3, - device_class=DEVICE_CLASS_CURTAIN, + device_class=CoverDeviceClass.CURTAIN, ), # switch_1 is an undocumented code that behaves identically to control # It is used by the Kogan Smart Blinds Driver @@ -76,7 +74,7 @@ COVERS: dict[str, tuple[TuyaCoverEntityDescription, ...]] = { name="Blind", current_position=DPCode.PERCENT_CONTROL, set_position=DPCode.PERCENT_CONTROL, - device_class=DEVICE_CLASS_BLIND, + device_class=CoverDeviceClass.BLIND, ), ), # Garage Door Opener @@ -87,21 +85,21 @@ COVERS: dict[str, tuple[TuyaCoverEntityDescription, ...]] = { name="Door", current_state=DPCode.DOORCONTACT_STATE, current_state_inverse=True, - device_class=DEVICE_CLASS_GARAGE, + device_class=CoverDeviceClass.GARAGE, ), TuyaCoverEntityDescription( key=DPCode.SWITCH_2, name="Door 2", current_state=DPCode.DOORCONTACT_STATE_2, current_state_inverse=True, - device_class=DEVICE_CLASS_GARAGE, + device_class=CoverDeviceClass.GARAGE, ), TuyaCoverEntityDescription( key=DPCode.SWITCH_3, name="Door 3", current_state=DPCode.DOORCONTACT_STATE_3, current_state_inverse=True, - device_class=DEVICE_CLASS_GARAGE, + device_class=CoverDeviceClass.GARAGE, ), ), # Curtain Switch @@ -112,14 +110,14 @@ COVERS: dict[str, tuple[TuyaCoverEntityDescription, ...]] = { name="Curtain", current_position=DPCode.PERCENT_CONTROL, set_position=DPCode.PERCENT_CONTROL, - device_class=DEVICE_CLASS_CURTAIN, + device_class=CoverDeviceClass.CURTAIN, ), TuyaCoverEntityDescription( key=DPCode.CONTROL_2, name="Curtain 2", current_position=DPCode.PERCENT_CONTROL_2, set_position=DPCode.PERCENT_CONTROL_2, - device_class=DEVICE_CLASS_CURTAIN, + device_class=CoverDeviceClass.CURTAIN, ), ), # Curtain Robot @@ -129,7 +127,7 @@ COVERS: dict[str, tuple[TuyaCoverEntityDescription, ...]] = { key=DPCode.CONTROL, current_position=DPCode.PERCENT_STATE, set_position=DPCode.PERCENT_CONTROL, - device_class=DEVICE_CLASS_CURTAIN, + device_class=CoverDeviceClass.CURTAIN, ), ), } diff --git a/homeassistant/components/tuya/humidifier.py b/homeassistant/components/tuya/humidifier.py index 3169000fcba..c6cddad2759 100644 --- a/homeassistant/components/tuya/humidifier.py +++ b/homeassistant/components/tuya/humidifier.py @@ -6,9 +6,8 @@ from dataclasses import dataclass from tuya_iot import TuyaDevice, TuyaDeviceManager from homeassistant.components.humidifier import ( - DEVICE_CLASS_DEHUMIDIFIER, - DEVICE_CLASS_HUMIDIFIER, SUPPORT_MODES, + HumidifierDeviceClass, HumidifierEntity, HumidifierEntityDescription, ) @@ -39,7 +38,7 @@ HUMIDIFIERS: dict[str, TuyaHumidifierEntityDescription] = { key=DPCode.SWITCH, dpcode=(DPCode.SWITCH, DPCode.SWITCH_SPRAY), humidity=DPCode.DEHUMIDITY_SET_VALUE, - device_class=DEVICE_CLASS_DEHUMIDIFIER, + device_class=HumidifierDeviceClass.DEHUMIDIFIER, ), # Humidifier # https://developer.tuya.com/en/docs/iot/categoryjsq?id=Kaiuz1smr440b @@ -47,7 +46,7 @@ HUMIDIFIERS: dict[str, TuyaHumidifierEntityDescription] = { key=DPCode.SWITCH, dpcode=(DPCode.SWITCH, DPCode.SWITCH_SPRAY), humidity=DPCode.HUMIDITY_SET, - device_class=DEVICE_CLASS_HUMIDIFIER, + device_class=HumidifierDeviceClass.HUMIDIFIER, ), } diff --git a/homeassistant/components/tuya/number.py b/homeassistant/components/tuya/number.py index a3ef644fa16..f75f21dc57f 100644 --- a/homeassistant/components/tuya/number.py +++ b/homeassistant/components/tuya/number.py @@ -8,9 +8,9 @@ from tuya_iot.device import TuyaDeviceStatusRange from homeassistant.components.number import NumberEntity, NumberEntityDescription from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ENTITY_CATEGORY_CONFIG from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import HomeAssistantTuyaData @@ -28,31 +28,31 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { key=DPCode.TEMP_SET, name="Temperature", icon="mdi:thermometer", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.TEMP_SET_F, name="Temperature", icon="mdi:thermometer", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.TEMP_BOILING_C, name="Temperature After Boiling", icon="mdi:thermometer", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.TEMP_BOILING_F, name="Temperature After Boiling", icon="mdi:thermometer", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.WARM_TIME, name="Heat Preservation Time", icon="mdi:timer", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Human Presence Sensor @@ -61,19 +61,19 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { NumberEntityDescription( key=DPCode.SENSITIVITY, name="Sensitivity", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.NEAR_DETECTION, name="Near Detection", icon="mdi:signal-distance-variant", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.FAR_DETECTION, name="Far Detection", icon="mdi:signal-distance-variant", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Coffee maker @@ -83,24 +83,24 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { key=DPCode.WATER_SET, name="Water Level", icon="mdi:cup-water", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.TEMP_SET, name="Temperature", icon="mdi:thermometer", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.WARM_TIME, name="Heat Preservation Time", icon="mdi:timer", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.POWDER_SET, name="Powder", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Robot Vacuum @@ -110,7 +110,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { key=DPCode.VOLUME_SET, name="Volume", icon="mdi:volume-high", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Siren Alarm @@ -119,7 +119,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { NumberEntityDescription( key=DPCode.ALARM_TIME, name="Time", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Smart Camera @@ -129,7 +129,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { key=DPCode.BASIC_DEVICE_VOLUME, name="Volume", icon="mdi:volume-high", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Dimmer Switch @@ -139,37 +139,37 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { key=DPCode.BRIGHTNESS_MIN_1, name="Minimum Brightness", icon="mdi:lightbulb-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.BRIGHTNESS_MAX_1, name="Maximum Brightness", icon="mdi:lightbulb-on-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.BRIGHTNESS_MIN_2, name="Minimum Brightness 2", icon="mdi:lightbulb-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.BRIGHTNESS_MAX_2, name="Maximum Brightness 2", icon="mdi:lightbulb-on-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.BRIGHTNESS_MIN_3, name="Minimum Brightness 3", icon="mdi:lightbulb-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.BRIGHTNESS_MAX_3, name="Maximum Brightness 3", icon="mdi:lightbulb-on-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Dimmer Switch @@ -179,25 +179,25 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { key=DPCode.BRIGHTNESS_MIN_1, name="Minimum Brightness", icon="mdi:lightbulb-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.BRIGHTNESS_MAX_1, name="Maximum Brightness", icon="mdi:lightbulb-on-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.BRIGHTNESS_MIN_2, name="Minimum Brightness 2", icon="mdi:lightbulb-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.BRIGHTNESS_MAX_2, name="Maximum Brightness 2", icon="mdi:lightbulb-on-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Vibration Sensor @@ -206,7 +206,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { NumberEntityDescription( key=DPCode.SENSITIVITY, name="Sensitivity", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Fingerbot @@ -215,19 +215,19 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { key=DPCode.ARM_DOWN_PERCENT, name="Move Down %", icon="mdi:arrow-down-bold", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.ARM_UP_PERCENT, name="Move Up %", icon="mdi:arrow-up-bold", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), NumberEntityDescription( key=DPCode.CLICK_SUSTAIN_TIME, name="Down Delay", icon="mdi:timer", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), } diff --git a/homeassistant/components/tuya/select.py b/homeassistant/components/tuya/select.py index 4eee162f814..9d5012c6578 100644 --- a/homeassistant/components/tuya/select.py +++ b/homeassistant/components/tuya/select.py @@ -8,9 +8,9 @@ from tuya_iot.device import TuyaDeviceStatusRange from homeassistant.components.select import SelectEntity, SelectEntityDescription from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ENTITY_CATEGORY_CONFIG from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import HomeAssistantTuyaData @@ -47,12 +47,12 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { key=DPCode.CONCENTRATION_SET, name="Concentration", icon="mdi:altimeter", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.MATERIAL, name="Material", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.MODE, @@ -67,13 +67,13 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { key=DPCode.RELAY_STATUS, name="Power on Behavior", device_class=DEVICE_CLASS_TUYA_RELAY_STATUS, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.LIGHT_MODE, name="Indicator Light Mode", device_class=DEVICE_CLASS_TUYA_LIGHT_MODE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Heater @@ -91,12 +91,12 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { SelectEntityDescription( key=DPCode.ALARM_VOLUME, name="Volume", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.BRIGHT_STATE, name="Brightness", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Smart Camera @@ -106,42 +106,42 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { key=DPCode.IPC_WORK_MODE, name="IPC Mode", device_class=DEVICE_CLASS_TUYA_IPC_WORK_MODE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.DECIBEL_SENSITIVITY, name="Sound Detection Sensitivity", icon="mdi:volume-vibrate", device_class=DEVICE_CLASS_TUYA_DECIBEL_SENSITIVITY, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.RECORD_MODE, name="Record Mode", icon="mdi:record-rec", device_class=DEVICE_CLASS_TUYA_RECORD_MODE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.BASIC_NIGHTVISION, name="Night Vision", icon="mdi:theme-light-dark", device_class=DEVICE_CLASS_TUYA_BASIC_NIGHTVISION, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.BASIC_ANTI_FLICKER, name="Anti-flicker", icon="mdi:image-outline", device_class=DEVICE_CLASS_TUYA_BASIC_ANTI_FLICKR, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.MOTION_SENSITIVITY, name="Motion Detection Sensitivity", icon="mdi:motion-sensor", device_class=DEVICE_CLASS_TUYA_MOTION_SENSITIVITY, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # IoT Switch? @@ -151,13 +151,13 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { key=DPCode.RELAY_STATUS, name="Power on Behavior", device_class=DEVICE_CLASS_TUYA_RELAY_STATUS, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.LIGHT_MODE, name="Indicator Light Mode", device_class=DEVICE_CLASS_TUYA_LIGHT_MODE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Dimmer Switch @@ -167,31 +167,31 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { key=DPCode.RELAY_STATUS, name="Power on Behavior", device_class=DEVICE_CLASS_TUYA_RELAY_STATUS, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.LIGHT_MODE, name="Indicator Light Mode", device_class=DEVICE_CLASS_TUYA_LIGHT_MODE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.LED_TYPE_1, name="Light Source Type", device_class=DEVICE_CLASS_TUYA_LED_TYPE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.LED_TYPE_2, name="Light 2 Source Type", device_class=DEVICE_CLASS_TUYA_LED_TYPE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.LED_TYPE_3, name="Light 3 Source Type", device_class=DEVICE_CLASS_TUYA_LED_TYPE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Dimmer @@ -201,13 +201,13 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { key=DPCode.LED_TYPE_1, name="Light Source Type", device_class=DEVICE_CLASS_TUYA_LED_TYPE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SelectEntityDescription( key=DPCode.LED_TYPE_2, name="Light 2 Source Type", device_class=DEVICE_CLASS_TUYA_LED_TYPE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Fingerbot @@ -216,7 +216,7 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { key=DPCode.MODE, name="Mode", device_class=DEVICE_CLASS_TUYA_FINGERBOT_MODE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), } diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index 4ba7fb461c3..62a330cbefb 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -8,36 +8,21 @@ from tuya_iot import TuyaDevice, TuyaDeviceManager from tuya_iot.device import TuyaDeviceStatusRange from homeassistant.components.sensor import ( - DEVICE_CLASS_BATTERY, - STATE_CLASS_MEASUREMENT, - STATE_CLASS_TOTAL_INCREASING, + SensorDeviceClass, SensorEntity, SensorEntityDescription, + SensorStateClass, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - DEVICE_CLASS_CO, - DEVICE_CLASS_CO2, - DEVICE_CLASS_CURRENT, - DEVICE_CLASS_ENERGY, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_ILLUMINANCE, - DEVICE_CLASS_PM1, - DEVICE_CLASS_PM10, - DEVICE_CLASS_PM25, - DEVICE_CLASS_POWER, - DEVICE_CLASS_PRESSURE, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, - DEVICE_CLASS_VOLTAGE, ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, - ENTITY_CATEGORY_DIAGNOSTIC, PERCENTAGE, POWER_KILO_WATT, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType @@ -66,29 +51,29 @@ BATTERY_SENSORS: tuple[TuyaSensorEntityDescription, ...] = ( 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, + device_class=SensorDeviceClass.BATTERY, + state_class=SensorStateClass.MEASUREMENT, + entity_category=EntityCategory.DIAGNOSTIC, ), TuyaSensorEntityDescription( key=DPCode.BATTERY_STATE, name="Battery State", icon="mdi:battery", - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), TuyaSensorEntityDescription( key=DPCode.BATTERY_VALUE, name="Battery", - device_class=DEVICE_CLASS_BATTERY, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.BATTERY, + entity_category=EntityCategory.DIAGNOSTIC, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.VA_BATTERY, name="Battery", - device_class=DEVICE_CLASS_BATTERY, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.BATTERY, + entity_category=EntityCategory.DIAGNOSTIC, + state_class=SensorStateClass.MEASUREMENT, ), ) @@ -103,14 +88,14 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.TEMP_CURRENT, name="Current Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.TEMP_CURRENT_F, name="Current Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.STATUS, @@ -124,20 +109,20 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.HUMIDITY_VALUE, name="Humidity", - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.TEMP_CURRENT, name="Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.CO2_VALUE, name="Carbon Dioxide", - device_class=DEVICE_CLASS_CO2, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CO2, + state_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -147,8 +132,8 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.CO_VALUE, name="Carbon Monoxide", - device_class=DEVICE_CLASS_CO, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CO, + state_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -158,37 +143,37 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.TEMP_CURRENT, name="Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.HUMIDITY_VALUE, name="Humidity", - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.CO2_VALUE, name="Carbon Dioxide", - device_class=DEVICE_CLASS_CO2, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CO2, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.CH2O_VALUE, name="Formaldehyde", - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.VOC_VALUE, name="Volatile Organic Compound", - device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.PM25_VALUE, name="Particulate Matter 2.5 µm", - device_class=DEVICE_CLASS_PM25, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.PM25, + state_class=SensorStateClass.MEASUREMENT, ), ), # Formaldehyde Detector @@ -197,37 +182,37 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.CO2_VALUE, name="Carbon Dioxide", - device_class=DEVICE_CLASS_CO2, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CO2, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.VOC_VALUE, name="Volatile Organic Compound", - device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.PM25_VALUE, name="Particulate Matter 2.5 µm", - device_class=DEVICE_CLASS_PM25, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.PM25, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.VA_HUMIDITY, name="Humidity", - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.VA_TEMPERATURE, name="Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.CH2O_VALUE, name="Formaldehyde", - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -237,7 +222,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.CH4_SENSOR_VALUE, name="Methane", - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -247,22 +232,22 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.CUR_CURRENT, name="Current", - device_class=DEVICE_CLASS_CURRENT, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, ), TuyaSensorEntityDescription( key=DPCode.CUR_POWER, name="Power", - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, ), TuyaSensorEntityDescription( key=DPCode.CUR_VOLTAGE, name="Voltage", - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, ), ), @@ -277,26 +262,26 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.BRIGHT_VALUE, name="Luminosity", - device_class=DEVICE_CLASS_ILLUMINANCE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.ILLUMINANCE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.TEMP_CURRENT, name="Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.HUMIDITY_VALUE, name="Humidity", - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.CO2_VALUE, name="Carbon Dioxide", - device_class=DEVICE_CLASS_CO2, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CO2, + state_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -312,49 +297,49 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.PM25_VALUE, name="Particulate Matter 2.5 µm", - device_class=DEVICE_CLASS_PM25, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.PM25, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.CH2O_VALUE, name="Formaldehyde", - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.VOC_VALUE, name="Volatile Organic Compound", - device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.TEMP_CURRENT, name="Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.CO2_VALUE, name="Carbon Dioxide", - device_class=DEVICE_CLASS_CO2, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CO2, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.HUMIDITY_VALUE, name="Humidity", - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.PM1, name="Particulate Matter 1.0 µm", - device_class=DEVICE_CLASS_PM1, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.PM1, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.PM10, name="Particulate Matter 10.0 µm", - device_class=DEVICE_CLASS_PM10, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.PM10, + state_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -364,8 +349,8 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.WORK_POWER, name="Power", - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), ), # Gas Detector @@ -374,7 +359,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.GAS_SENSOR_VALUE, icon="mdi:gas-cylinder", - device_class=STATE_CLASS_MEASUREMENT, + device_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -390,21 +375,21 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.SENSOR_TEMPERATURE, name="Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.SENSOR_HUMIDITY, name="Humidity", - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.WIRELESS_ELECTRICITY, name="Battery", - device_class=DEVICE_CLASS_BATTERY, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.BATTERY, + entity_category=EntityCategory.DIAGNOSTIC, + state_class=SensorStateClass.MEASUREMENT, ), ), # Fingerbot @@ -418,37 +403,37 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.CO2_VALUE, name="Carbon Dioxide", - device_class=DEVICE_CLASS_CO2, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CO2, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.PM25_VALUE, name="Particulate Matter 2.5 µm", - device_class=DEVICE_CLASS_PM25, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.PM25, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.CH2O_VALUE, name="Formaldehyde", - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.HUMIDITY_VALUE, name="Humidity", - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.TEMP_CURRENT, name="Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.VOC_VALUE, name="Volatile Organic Compound", - device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS, + state_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -458,32 +443,32 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.VA_TEMPERATURE, name="Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.TEMP_CURRENT, name="Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.VA_HUMIDITY, name="Humidity", - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.HUMIDITY_VALUE, name="Humidity", - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), TuyaSensorEntityDescription( key=DPCode.BRIGHT_VALUE, name="Luminosity", - device_class=DEVICE_CLASS_ILLUMINANCE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.ILLUMINANCE, + state_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -492,8 +477,8 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { "ylcg": ( TuyaSensorEntityDescription( key=DPCode.PRESSURE_VALUE, - device_class=DEVICE_CLASS_PRESSURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.PRESSURE, + state_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -504,8 +489,8 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { key=DPCode.SMOKE_SENSOR_VALUE, name="Smoke Amount", icon="mdi:smoke-detector", - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, - device_class=STATE_CLASS_MEASUREMENT, + entity_category=EntityCategory.DIAGNOSTIC, + device_class=SensorStateClass.MEASUREMENT, ), *BATTERY_SENSORS, ), @@ -518,78 +503,78 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { TuyaSensorEntityDescription( key=DPCode.FORWARD_ENERGY_TOTAL, name="Total Energy", - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), TuyaSensorEntityDescription( key=DPCode.PHASE_A, name="Phase A Current", - device_class=DEVICE_CLASS_CURRENT, + device_class=SensorDeviceClass.CURRENT, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, subkey="electriccurrent", ), TuyaSensorEntityDescription( key=DPCode.PHASE_A, name="Phase A Power", - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=POWER_KILO_WATT, subkey="power", ), TuyaSensorEntityDescription( key=DPCode.PHASE_A, name="Phase A Voltage", - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, subkey="voltage", ), TuyaSensorEntityDescription( key=DPCode.PHASE_B, name="Phase B Current", - device_class=DEVICE_CLASS_CURRENT, + device_class=SensorDeviceClass.CURRENT, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, subkey="electriccurrent", ), TuyaSensorEntityDescription( key=DPCode.PHASE_B, name="Phase B Power", - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=POWER_KILO_WATT, subkey="power", ), TuyaSensorEntityDescription( key=DPCode.PHASE_B, name="Phase B Voltage", - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, subkey="voltage", ), TuyaSensorEntityDescription( key=DPCode.PHASE_C, name="Phase C Current", - device_class=DEVICE_CLASS_CURRENT, + device_class=SensorDeviceClass.CURRENT, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, subkey="electriccurrent", ), TuyaSensorEntityDescription( key=DPCode.PHASE_C, name="Phase C Power", - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=POWER_KILO_WATT, subkey="power", ), TuyaSensorEntityDescription( key=DPCode.PHASE_C, name="Phase C Voltage", - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, subkey="voltage", ), diff --git a/homeassistant/components/tuya/switch.py b/homeassistant/components/tuya/switch.py index acc6e2e57e0..17b0feb70a7 100644 --- a/homeassistant/components/tuya/switch.py +++ b/homeassistant/components/tuya/switch.py @@ -6,14 +6,14 @@ from typing import Any from tuya_iot import TuyaDevice, TuyaDeviceManager from homeassistant.components.switch import ( - DEVICE_CLASS_OUTLET, + SwitchDeviceClass, SwitchEntity, SwitchEntityDescription, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ENTITY_CATEGORY_CONFIG from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import HomeAssistantTuyaData @@ -35,7 +35,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { SwitchEntityDescription( key=DPCode.WARM, name="Heat Preservation", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Pet Water Feeder @@ -45,13 +45,13 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.FILTER_RESET, name="Filter reset", icon="mdi:filter", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.PUMP_RESET, name="Water pump reset", icon="mdi:pump", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.SWITCH, @@ -61,7 +61,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.WATER_RESET, name="Reset of water usage days", icon="mdi:water-sync", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Light @@ -81,7 +81,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.CHILD_LOCK, name="Child Lock", icon="mdi:account-lock", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.SWITCH_1, @@ -95,37 +95,37 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.CHILD_LOCK, name="Child Lock", icon="mdi:account-lock", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.SWITCH_1, name="Switch 1", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_2, name="Switch 2", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_3, name="Switch 3", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_4, name="Switch 4", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_5, name="Switch 5", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_6, name="Switch 6", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_USB1, @@ -154,7 +154,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { SwitchEntityDescription( key=DPCode.SWITCH, name="Switch", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), ), # Air Purifier @@ -164,19 +164,19 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.ANION, name="Ionizer", icon="mdi:minus-circle-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.FILTER_RESET, name="Filter cartridge reset", icon="mdi:filter", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.LOCK, name="Child lock", icon="mdi:account-lock", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.SWITCH, @@ -186,7 +186,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.WET, name="Humidification", icon="mdi:water-percent", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Air conditioner @@ -196,13 +196,13 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.ANION, name="Ionizer", icon="mdi:minus-circle-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.LOCK, name="Child Lock", icon="mdi:account-lock", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Power Socket @@ -212,37 +212,37 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.CHILD_LOCK, name="Child Lock", icon="mdi:account-lock", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.SWITCH_1, name="Socket 1", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_2, name="Socket 2", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_3, name="Socket 3", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_4, name="Socket 4", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_5, name="Socket 5", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_6, name="Socket 6", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_USB1, @@ -271,7 +271,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { SwitchEntityDescription( key=DPCode.SWITCH, name="Socket", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), ), # Heater @@ -281,13 +281,13 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.ANION, name="Ionizer", icon="mdi:minus-circle-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.LOCK, name="Child Lock", icon="mdi:account-lock", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Robot Vacuum @@ -297,13 +297,13 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.SWITCH_DISTURB, name="Do Not Disturb", icon="mdi:minus-circle", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.VOICE_SWITCH, name="Voice", icon="mdi:account-voice", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Siren Alarm @@ -312,7 +312,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { SwitchEntityDescription( key=DPCode.MUFFLING, name="Mute", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Smart Camera @@ -322,67 +322,67 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.WIRELESS_BATTERYLOCK, name="Battery Lock", icon="mdi:battery-lock", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.CRY_DETECTION_SWITCH, icon="mdi:emoticon-cry", name="Cry Detection", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.DECIBEL_SWITCH, icon="mdi:microphone-outline", name="Sound Detection", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.RECORD_SWITCH, icon="mdi:record-rec", name="Video Recording", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.MOTION_RECORD, icon="mdi:record-rec", name="Motion Recording", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.BASIC_PRIVATE, icon="mdi:eye-off", name="Privacy Mode", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.BASIC_FLIP, icon="mdi:flip-horizontal", name="Flip", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.BASIC_OSD, icon="mdi:watermark", name="Time Watermark", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.BASIC_WDR, icon="mdi:watermark", name="Wide Dynamic Range", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.MOTION_TRACKING, icon="mdi:motion-sensor", name="Motion Tracking", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=DPCode.MOTION_SWITCH, icon="mdi:motion-sensor", name="Motion Alarm", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Fingerbot @@ -399,23 +399,23 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { SwitchEntityDescription( key=DPCode.SWITCH_1, name="Switch 1", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_2, name="Switch 2", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.SWITCH_3, name="Switch 3", - device_class=DEVICE_CLASS_OUTLET, + device_class=SwitchDeviceClass.OUTLET, ), SwitchEntityDescription( key=DPCode.CHILD_LOCK, name="Child Lock", icon="mdi:account-lock", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Solar Light @@ -425,7 +425,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.SWITCH_SAVE_ENERGY, name="Energy Saving", icon="mdi:leaf", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Ceiling Light @@ -435,7 +435,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.DO_NOT_DISTURB, name="Do not disturb", icon="mdi:minus-circle-outline", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Diffuser @@ -454,7 +454,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { key=DPCode.SWITCH_VOICE, name="Voice", icon="mdi:account-voice", - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, ), ), # Smart Electricity Meter