diff --git a/homeassistant/components/xiaomi_aqara/binary_sensor.py b/homeassistant/components/xiaomi_aqara/binary_sensor.py index 41a99426c67..afbeeece496 100644 --- a/homeassistant/components/xiaomi_aqara/binary_sensor.py +++ b/homeassistant/components/xiaomi_aqara/binary_sensor.py @@ -2,8 +2,7 @@ import logging from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_MOISTURE, - DEVICE_CLASS_OPENING, + BinarySensorDeviceClass, BinarySensorEntity, ) from homeassistant.core import callback @@ -303,7 +302,7 @@ class XiaomiDoorSensor(XiaomiBinarySensor): "Door Window Sensor", xiaomi_hub, data_key, - DEVICE_CLASS_OPENING, + BinarySensorDeviceClass.OPENING, config_entry, ) @@ -353,7 +352,7 @@ class XiaomiWaterLeakSensor(XiaomiBinarySensor): "Water Leak Sensor", xiaomi_hub, data_key, - DEVICE_CLASS_MOISTURE, + BinarySensorDeviceClass.MOISTURE, config_entry, ) diff --git a/homeassistant/components/xiaomi_aqara/sensor.py b/homeassistant/components/xiaomi_aqara/sensor.py index c3f5cf4dacc..c21dd3bcf86 100644 --- a/homeassistant/components/xiaomi_aqara/sensor.py +++ b/homeassistant/components/xiaomi_aqara/sensor.py @@ -3,15 +3,13 @@ from __future__ import annotations import logging -from homeassistant.components.sensor import SensorEntity, SensorEntityDescription +from homeassistant.components.sensor import ( + SensorDeviceClass, + SensorEntity, + SensorEntityDescription, +) from homeassistant.const import ( ATTR_BATTERY_LEVEL, - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_ILLUMINANCE, - DEVICE_CLASS_POWER, - DEVICE_CLASS_PRESSURE, - DEVICE_CLASS_TEMPERATURE, LIGHT_LUX, PERCENTAGE, POWER_WATT, @@ -28,27 +26,27 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = { "temperature": SensorEntityDescription( key="temperature", native_unit_of_measurement=TEMP_CELSIUS, - device_class=DEVICE_CLASS_TEMPERATURE, + device_class=SensorDeviceClass.TEMPERATURE, ), "humidity": SensorEntityDescription( key="humidity", native_unit_of_measurement=PERCENTAGE, - device_class=DEVICE_CLASS_HUMIDITY, + device_class=SensorDeviceClass.HUMIDITY, ), "illumination": SensorEntityDescription( key="illumination", native_unit_of_measurement="lm", - device_class=DEVICE_CLASS_ILLUMINANCE, + device_class=SensorDeviceClass.ILLUMINANCE, ), "lux": SensorEntityDescription( key="lux", native_unit_of_measurement=LIGHT_LUX, - device_class=DEVICE_CLASS_ILLUMINANCE, + device_class=SensorDeviceClass.ILLUMINANCE, ), "pressure": SensorEntityDescription( key="pressure", native_unit_of_measurement=PRESSURE_HPA, - device_class=DEVICE_CLASS_PRESSURE, + device_class=SensorDeviceClass.PRESSURE, ), "bed_activity": SensorEntityDescription( key="bed_activity", @@ -58,7 +56,7 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = { "load_power": SensorEntityDescription( key="load_power", native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, + device_class=SensorDeviceClass.POWER, ), "final_tilt_angle": SensorEntityDescription( key="final_tilt_angle", @@ -185,7 +183,7 @@ class XiaomiBatterySensor(XiaomiDevice, SensorEntity): """Representation of a XiaomiSensor.""" _attr_native_unit_of_measurement = PERCENTAGE - _attr_device_class = DEVICE_CLASS_BATTERY + _attr_device_class = SensorDeviceClass.BATTERY def parse_data(self, data, raw_data): """Parse data sent by gateway."""