Use Unit enums in MELCloud sensors (#84036)

This commit is contained in:
ollo69 2022-12-15 14:25:51 +01:00 committed by GitHub
parent c4a01cf8d2
commit 30ac390471
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,7 +15,7 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS
from homeassistant.const import UnitOfEnergy, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -43,7 +43,7 @@ ATA_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
key="room_temperature",
name="Room Temperature",
icon="mdi:thermometer",
native_unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
value_fn=lambda x: x.device.room_temperature,
enabled=lambda x: True,
@ -52,7 +52,7 @@ ATA_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
key="energy",
name="Energy",
icon="mdi:factory",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
value_fn=lambda x: x.device.total_energy_consumed,
enabled=lambda x: x.device.has_energy_consumed_meter,
@ -61,7 +61,7 @@ ATA_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
key="daily_energy",
name="Daily Energy Consumed",
icon="mdi:factory",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
value_fn=lambda x: x.device.daily_energy_consumed,
enabled=lambda x: True,
@ -72,7 +72,7 @@ ATW_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
key="outside_temperature",
name="Outside Temperature",
icon="mdi:thermometer",
native_unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
value_fn=lambda x: x.device.outside_temperature,
enabled=lambda x: True,
@ -81,7 +81,7 @@ ATW_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
key="tank_temperature",
name="Tank Temperature",
icon="mdi:thermometer",
native_unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
value_fn=lambda x: x.device.tank_temperature,
enabled=lambda x: True,
@ -90,7 +90,7 @@ ATW_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
key="daily_energy",
name="Daily Energy Consumed",
icon="mdi:factory",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
value_fn=lambda x: x.device.daily_energy_consumed,
enabled=lambda x: True,
@ -101,7 +101,7 @@ ATW_ZONE_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
key="room_temperature",
name="Room Temperature",
icon="mdi:thermometer",
native_unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
value_fn=lambda zone: zone.room_temperature,
enabled=lambda x: True,
@ -110,7 +110,7 @@ ATW_ZONE_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
key="flow_temperature",
name="Flow Temperature",
icon="mdi:thermometer",
native_unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
value_fn=lambda zone: zone.flow_temperature,
enabled=lambda x: True,
@ -119,7 +119,7 @@ ATW_ZONE_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
key="return_temperature",
name="Flow Return Temperature",
icon="mdi:thermometer",
native_unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
value_fn=lambda zone: zone.return_temperature,
enabled=lambda x: True,