From 530f9de85efef9983b10f337d3323e8d54b97b04 Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 2 Jan 2024 08:06:31 +0100 Subject: [PATCH] Update sensor.py fix deprication warnings for HA 2024.1 Please test the changes, since I don't have Daikin to test against :) --- custom_components/daikin_altherma/sensor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/custom_components/daikin_altherma/sensor.py b/custom_components/daikin_altherma/sensor.py index 4e8b11f..1ef2e73 100755 --- a/custom_components/daikin_altherma/sensor.py +++ b/custom_components/daikin_altherma/sensor.py @@ -1,7 +1,8 @@ import logging from homeassistant.components.sensor import SensorEntity, SensorDeviceClass, SensorStateClass #DEVICE_CLASS_TEMPERATURE, STATE_CLASS_TOTAL_INCREASING -from homeassistant.const import TEMP_CELSIUS, ENERGY_KILO_WATT_HOUR, DEVICE_CLASS_ENERGY +from homeassistant.const import UnitOfEnergy, UnitOfTemperature +# TEMP_CELSIUS, ENERGY_KILO_WATT_HOUR, DEVICE_CLASS_ENERGY from homeassistant.helpers.typing import StateType from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, @@ -90,7 +91,7 @@ async def async_setup_entry(hass, entry, async_add_entities): class AlthermaUnitSensor(SensorEntity, CoordinatorEntity): _attr_device_class = SensorDeviceClass.TEMPERATURE - _attr_native_unit_of_measurement = TEMP_CELSIUS + _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS def __init__(self, coordinator, api: AlthermaAPI, sensor: str, name: str = None): super().__init__(coordinator) @@ -135,7 +136,7 @@ def _find_last_value(a): class ConsumptionSensor(SensorEntity, CoordinatorEntity): _attr_device_class = SensorDeviceClass.ENERGY - _attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR + _attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR _attr_state_class = SensorStateClass.TOTAL_INCREASING