diff --git a/homeassistant/components/toon/binary_sensor.py b/homeassistant/components/toon/binary_sensor.py index 30f5459c175..84e47ce6cb5 100644 --- a/homeassistant/components/toon/binary_sensor.py +++ b/homeassistant/components/toon/binary_sensor.py @@ -4,8 +4,7 @@ from __future__ import annotations from dataclasses import dataclass from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_CONNECTIVITY, - DEVICE_CLASS_PROBLEM, + BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription, ) @@ -113,7 +112,7 @@ BINARY_SENSOR_ENTITIES = ( name="Boiler Module Connection", section="thermostat", measurement="boiler_module_connected", - device_class=DEVICE_CLASS_CONNECTIVITY, + device_class=BinarySensorDeviceClass.CONNECTIVITY, entity_registry_enabled_default=False, cls=ToonBoilerModuleBinarySensor, ), @@ -167,7 +166,7 @@ BINARY_SENSOR_ENTITIES_BOILER: tuple[ToonBinarySensorEntityDescription, ...] = ( name="Boiler Status", section="thermostat", measurement="error_found", - device_class=DEVICE_CLASS_PROBLEM, + device_class=BinarySensorDeviceClass.PROBLEM, icon="mdi:alert", cls=ToonBoilerBinarySensor, ), @@ -176,7 +175,7 @@ BINARY_SENSOR_ENTITIES_BOILER: tuple[ToonBinarySensorEntityDescription, ...] = ( name="OpenTherm Connection", section="thermostat", measurement="opentherm_communication_error", - device_class=DEVICE_CLASS_PROBLEM, + device_class=BinarySensorDeviceClass.PROBLEM, icon="mdi:check-network-outline", entity_registry_enabled_default=False, cls=ToonBoilerBinarySensor, diff --git a/homeassistant/components/toon/sensor.py b/homeassistant/components/toon/sensor.py index 30cde4632a9..3a4fc1a71af 100644 --- a/homeassistant/components/toon/sensor.py +++ b/homeassistant/components/toon/sensor.py @@ -4,18 +4,13 @@ from __future__ import annotations from dataclasses import dataclass from homeassistant.components.sensor import ( - STATE_CLASS_MEASUREMENT, - STATE_CLASS_TOTAL_INCREASING, + SensorDeviceClass, SensorEntity, SensorEntityDescription, + SensorStateClass, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - DEVICE_CLASS_ENERGY, - DEVICE_CLASS_GAS, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_POWER, - DEVICE_CLASS_TEMPERATURE, ENERGY_KILO_WATT_HOUR, PERCENTAGE, POWER_WATT, @@ -137,9 +132,9 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="thermostat", measurement="current_display_temperature", native_unit_of_measurement=TEMP_CELSIUS, - device_class=DEVICE_CLASS_TEMPERATURE, + device_class=SensorDeviceClass.TEMPERATURE, entity_registry_enabled_default=False, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, cls=ToonDisplayDeviceSensor, ), ToonSensorEntityDescription( @@ -148,9 +143,9 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="thermostat", measurement="current_humidity", native_unit_of_measurement=PERCENTAGE, - device_class=DEVICE_CLASS_HUMIDITY, + device_class=SensorDeviceClass.HUMIDITY, entity_registry_enabled_default=False, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, cls=ToonDisplayDeviceSensor, ), ToonSensorEntityDescription( @@ -167,7 +162,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( name="Average Daily Gas Usage", section="gas_usage", measurement="day_average", - device_class=DEVICE_CLASS_GAS, + device_class=SensorDeviceClass.GAS, native_unit_of_measurement=VOLUME_CUBIC_METERS, entity_registry_enabled_default=False, cls=ToonGasMeterDeviceSensor, @@ -177,7 +172,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( name="Gas Usage Today", section="gas_usage", measurement="day_usage", - device_class=DEVICE_CLASS_GAS, + device_class=SensorDeviceClass.GAS, native_unit_of_measurement=VOLUME_CUBIC_METERS, cls=ToonGasMeterDeviceSensor, ), @@ -196,8 +191,8 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="gas_usage", measurement="meter", native_unit_of_measurement=VOLUME_CUBIC_METERS, - state_class=STATE_CLASS_TOTAL_INCREASING, - device_class=DEVICE_CLASS_GAS, + state_class=SensorStateClass.TOTAL_INCREASING, + device_class=SensorDeviceClass.GAS, cls=ToonGasMeterDeviceSensor, ), ToonSensorEntityDescription( @@ -215,7 +210,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="average", native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, + device_class=SensorDeviceClass.POWER, entity_registry_enabled_default=False, cls=ToonElectricityMeterDeviceSensor, ), @@ -225,7 +220,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="day_average", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, + device_class=SensorDeviceClass.ENERGY, entity_registry_enabled_default=False, cls=ToonElectricityMeterDeviceSensor, ), @@ -244,7 +239,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="day_usage", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, + device_class=SensorDeviceClass.ENERGY, cls=ToonElectricityMeterDeviceSensor, ), ToonSensorEntityDescription( @@ -253,8 +248,8 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="meter_high", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, cls=ToonElectricityMeterDeviceSensor, ), ToonSensorEntityDescription( @@ -263,8 +258,8 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="meter_low", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, cls=ToonElectricityMeterDeviceSensor, ), ToonSensorEntityDescription( @@ -273,8 +268,8 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="current", native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, cls=ToonElectricityMeterDeviceSensor, ), ToonSensorEntityDescription( @@ -283,8 +278,8 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="meter_produced_high", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, cls=ToonElectricityMeterDeviceSensor, ), ToonSensorEntityDescription( @@ -293,8 +288,8 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="meter_produced_low", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, cls=ToonElectricityMeterDeviceSensor, ), ToonSensorEntityDescription( @@ -335,7 +330,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( native_unit_of_measurement=VOLUME_CUBIC_METERS, icon="mdi:water", entity_registry_enabled_default=False, - state_class=STATE_CLASS_TOTAL_INCREASING, + state_class=SensorStateClass.TOTAL_INCREASING, cls=ToonWaterMeterDeviceSensor, ), ToonSensorEntityDescription( @@ -346,7 +341,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( native_unit_of_measurement=VOLUME_LMIN, icon="mdi:water-pump", entity_registry_enabled_default=False, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, cls=ToonWaterMeterDeviceSensor, ), ToonSensorEntityDescription( @@ -368,8 +363,8 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="current_solar", native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, cls=ToonSolarDeviceSensor, ), ToonSensorEntityDescription( @@ -378,7 +373,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="day_max_solar", native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, + device_class=SensorDeviceClass.POWER, cls=ToonSolarDeviceSensor, ), ToonSensorEntityDescription( @@ -387,8 +382,8 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="current_produced", native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, cls=ToonSolarDeviceSensor, ), ToonSensorEntityDescription( @@ -397,8 +392,8 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="day_produced_solar", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, cls=ToonSolarDeviceSensor, ), ToonSensorEntityDescription( @@ -407,7 +402,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="day_to_grid_usage", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, + device_class=SensorDeviceClass.ENERGY, entity_registry_enabled_default=False, cls=ToonSolarDeviceSensor, ), @@ -417,7 +412,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="day_from_grid_usage", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, + device_class=SensorDeviceClass.ENERGY, entity_registry_enabled_default=False, cls=ToonSolarDeviceSensor, ), @@ -427,7 +422,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = ( section="power_usage", measurement="average_produced", native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, + device_class=SensorDeviceClass.POWER, entity_registry_enabled_default=False, cls=ToonSolarDeviceSensor, ), @@ -438,7 +433,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = ( measurement="current_covered_by_solar", native_unit_of_measurement=PERCENTAGE, icon="mdi:solar-power", - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, cls=ToonSolarDeviceSensor, ), ) @@ -452,7 +447,7 @@ SENSOR_ENTITIES_BOILER: tuple[ToonSensorEntityDescription, ...] = ( native_unit_of_measurement=PERCENTAGE, icon="mdi:percent", entity_registry_enabled_default=False, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, cls=ToonBoilerDeviceSensor, ), )