diff --git a/homeassistant/components/homematic/binary_sensor.py b/homeassistant/components/homematic/binary_sensor.py index b25fb2949aa..442e4c8e434 100644 --- a/homeassistant/components/homematic/binary_sensor.py +++ b/homeassistant/components/homematic/binary_sensor.py @@ -1,10 +1,6 @@ """Support for HomeMatic binary sensors.""" from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_MOTION, - DEVICE_CLASS_OPENING, - DEVICE_CLASS_PRESENCE, - DEVICE_CLASS_SMOKE, + BinarySensorDeviceClass, BinarySensorEntity, ) @@ -12,24 +8,24 @@ from .const import ATTR_DISCOVER_DEVICES, ATTR_DISCOVERY_TYPE, DISCOVER_BATTERY from .entity import HMDevice SENSOR_TYPES_CLASS = { - "IPShutterContact": DEVICE_CLASS_OPENING, - "IPShutterContactSabotage": DEVICE_CLASS_OPENING, - "MaxShutterContact": DEVICE_CLASS_OPENING, - "Motion": DEVICE_CLASS_MOTION, - "MotionV2": DEVICE_CLASS_MOTION, - "PresenceIP": DEVICE_CLASS_PRESENCE, + "IPShutterContact": BinarySensorDeviceClass.OPENING, + "IPShutterContactSabotage": BinarySensorDeviceClass.OPENING, + "MaxShutterContact": BinarySensorDeviceClass.OPENING, + "Motion": BinarySensorDeviceClass.MOTION, + "MotionV2": BinarySensorDeviceClass.MOTION, + "PresenceIP": BinarySensorDeviceClass.MOTION, "Remote": None, "RemoteMotion": None, - "ShutterContact": DEVICE_CLASS_OPENING, - "Smoke": DEVICE_CLASS_SMOKE, - "SmokeV2": DEVICE_CLASS_SMOKE, + "ShutterContact": BinarySensorDeviceClass.OPENING, + "Smoke": BinarySensorDeviceClass.SMOKE, + "SmokeV2": BinarySensorDeviceClass.SMOKE, "TiltSensor": None, "WeatherSensor": None, - "IPContact": DEVICE_CLASS_OPENING, - "MotionIP": DEVICE_CLASS_MOTION, - "MotionIPV2": DEVICE_CLASS_MOTION, - "MotionIPContactSabotage": DEVICE_CLASS_MOTION, - "IPRemoteMotionV2": DEVICE_CLASS_MOTION, + "IPContact": BinarySensorDeviceClass.OPENING, + "MotionIP": BinarySensorDeviceClass.MOTION, + "MotionIPV2": BinarySensorDeviceClass.MOTION, + "MotionIPContactSabotage": BinarySensorDeviceClass.MOTION, + "IPRemoteMotionV2": BinarySensorDeviceClass.MOTION, } @@ -63,7 +59,7 @@ class HMBinarySensor(HMDevice, BinarySensorEntity): """Return the class of this sensor from DEVICE_CLASSES.""" # If state is MOTION (Only RemoteMotion working) if self._state == "MOTION": - return DEVICE_CLASS_MOTION + return BinarySensorDeviceClass.MOTION return SENSOR_TYPES_CLASS.get(self._hmdevice.__class__.__name__) def _init_data_struct(self): @@ -76,7 +72,7 @@ class HMBinarySensor(HMDevice, BinarySensorEntity): class HMBatterySensor(HMDevice, BinarySensorEntity): """Representation of an HomeMatic low battery sensor.""" - _attr_device_class = DEVICE_CLASS_BATTERY + _attr_device_class = BinarySensorDeviceClass.BATTERY @property def is_on(self): diff --git a/homeassistant/components/homematic/cover.py b/homeassistant/components/homematic/cover.py index deed671931f..b92c3e5b4d7 100644 --- a/homeassistant/components/homematic/cover.py +++ b/homeassistant/components/homematic/cover.py @@ -2,7 +2,7 @@ from homeassistant.components.cover import ( ATTR_POSITION, ATTR_TILT_POSITION, - DEVICE_CLASS_GARAGE, + CoverDeviceClass, CoverEntity, ) @@ -112,7 +112,7 @@ class HMCover(HMDevice, CoverEntity): class HMGarage(HMCover): """Represents a Homematic Garage cover. Homematic garage covers do not support position attributes.""" - _attr_device_class = DEVICE_CLASS_GARAGE + _attr_device_class = CoverDeviceClass.GARAGE @property def current_cover_position(self): diff --git a/homeassistant/components/homematic/sensor.py b/homeassistant/components/homematic/sensor.py index 19b24fbb3f8..3585510beb7 100644 --- a/homeassistant/components/homematic/sensor.py +++ b/homeassistant/components/homematic/sensor.py @@ -5,25 +5,15 @@ from copy import copy import logging from homeassistant.components.sensor import ( - STATE_CLASS_MEASUREMENT, - STATE_CLASS_TOTAL_INCREASING, + SensorDeviceClass, SensorEntity, SensorEntityDescription, + SensorStateClass, ) from homeassistant.const import ( ATTR_NAME, CONCENTRATION_PARTS_PER_MILLION, DEGREE, - DEVICE_CLASS_CO2, - DEVICE_CLASS_CURRENT, - DEVICE_CLASS_ENERGY, - DEVICE_CLASS_GAS, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_ILLUMINANCE, - DEVICE_CLASS_POWER, - DEVICE_CLASS_PRESSURE, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_VOLTAGE, ELECTRIC_CURRENT_MILLIAMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_WATT_HOUR, @@ -64,110 +54,110 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = { "HUMIDITY": SensorEntityDescription( key="HUMIDITY", native_unit_of_measurement=PERCENTAGE, - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), "ACTUAL_TEMPERATURE": SensorEntityDescription( key="ACTUAL_TEMPERATURE", native_unit_of_measurement=TEMP_CELSIUS, - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), "TEMPERATURE": SensorEntityDescription( key="TEMPERATURE", native_unit_of_measurement=TEMP_CELSIUS, - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), "LUX": SensorEntityDescription( key="LUX", native_unit_of_measurement=LIGHT_LUX, - device_class=DEVICE_CLASS_ILLUMINANCE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.ILLUMINANCE, + state_class=SensorStateClass.MEASUREMENT, ), "CURRENT_ILLUMINATION": SensorEntityDescription( key="CURRENT_ILLUMINATION", native_unit_of_measurement=LIGHT_LUX, - device_class=DEVICE_CLASS_ILLUMINANCE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.ILLUMINANCE, + state_class=SensorStateClass.MEASUREMENT, ), "ILLUMINATION": SensorEntityDescription( key="ILLUMINATION", native_unit_of_measurement=LIGHT_LUX, - device_class=DEVICE_CLASS_ILLUMINANCE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.ILLUMINANCE, + state_class=SensorStateClass.MEASUREMENT, ), "AVERAGE_ILLUMINATION": SensorEntityDescription( key="AVERAGE_ILLUMINATION", native_unit_of_measurement=LIGHT_LUX, - device_class=DEVICE_CLASS_ILLUMINANCE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.ILLUMINANCE, + state_class=SensorStateClass.MEASUREMENT, ), "LOWEST_ILLUMINATION": SensorEntityDescription( key="LOWEST_ILLUMINATION", native_unit_of_measurement=LIGHT_LUX, - device_class=DEVICE_CLASS_ILLUMINANCE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.ILLUMINANCE, + state_class=SensorStateClass.MEASUREMENT, ), "HIGHEST_ILLUMINATION": SensorEntityDescription( key="HIGHEST_ILLUMINATION", native_unit_of_measurement=LIGHT_LUX, - device_class=DEVICE_CLASS_ILLUMINANCE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.ILLUMINANCE, + state_class=SensorStateClass.MEASUREMENT, ), "POWER": SensorEntityDescription( key="POWER", native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), "IEC_POWER": SensorEntityDescription( key="IEC_POWER", native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), "CURRENT": SensorEntityDescription( key="CURRENT", native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE, - device_class=DEVICE_CLASS_CURRENT, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, ), "CONCENTRATION": SensorEntityDescription( key="CONCENTRATION", native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, - device_class=DEVICE_CLASS_CO2, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CO2, + state_class=SensorStateClass.MEASUREMENT, ), "ENERGY_COUNTER": SensorEntityDescription( key="ENERGY_COUNTER", native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), "IEC_ENERGY_COUNTER": SensorEntityDescription( key="IEC_ENERGY_COUNTER", native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), "VOLTAGE": SensorEntityDescription( key="VOLTAGE", native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, ), "GAS_POWER": SensorEntityDescription( key="GAS_POWER", native_unit_of_measurement=VOLUME_CUBIC_METERS, - device_class=DEVICE_CLASS_GAS, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.GAS, + state_class=SensorStateClass.MEASUREMENT, ), "GAS_ENERGY_COUNTER": SensorEntityDescription( key="GAS_ENERGY_COUNTER", native_unit_of_measurement=VOLUME_CUBIC_METERS, - device_class=DEVICE_CLASS_GAS, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.GAS, + state_class=SensorStateClass.TOTAL_INCREASING, ), "RAIN_COUNTER": SensorEntityDescription( key="RAIN_COUNTER", @@ -193,8 +183,8 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = { "AIR_PRESSURE": SensorEntityDescription( key="AIR_PRESSURE", native_unit_of_measurement=PRESSURE_HPA, - device_class=DEVICE_CLASS_PRESSURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.PRESSURE, + state_class=SensorStateClass.MEASUREMENT, ), "FREQUENCY": SensorEntityDescription( key="FREQUENCY",