Skip to content

Commit

Permalink
fix deprecated constants (tggm#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
brew-your-own committed May 26, 2024
1 parent a3ccf4c commit 725b34a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions custom_components/rointe/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
HVACMode,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS
from homeassistant.const import UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand Down Expand Up @@ -80,7 +80,7 @@ def icon(self) -> str | None:
@property
def temperature_unit(self) -> str:
"""Temperature unit."""
return TEMP_CELSIUS
return UnitOfTemperature.CELSIUS

@property
def target_temperature(self) -> float:
Expand Down
9 changes: 5 additions & 4 deletions custom_components/rointe/sensor_descriptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sensor descriptions for Rointe."""

from __future__ import annotations

from collections.abc import Callable
Expand All @@ -10,7 +11,7 @@
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT, TEMP_CELSIUS
from homeassistant.const import UnitOfEnergy, UnitOfPower, UnitOfTemperature
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.typing import StateType

Expand Down Expand Up @@ -38,7 +39,7 @@ class RointeSensorEntityDescription(
key="current_temperature",
name="Current Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda radiator: radiator.temp_probe,
last_reset_fn=lambda radiator: None,
Expand All @@ -48,7 +49,7 @@ class RointeSensorEntityDescription(
key="energy",
name="Energy Consumption",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
state_class=SensorStateClass.TOTAL,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda radiator: radiator.energy_data.kwh
Expand All @@ -63,7 +64,7 @@ class RointeSensorEntityDescription(
key="power",
name="Effective Power",
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda radiator: radiator.energy_data.effective_power
Expand Down

0 comments on commit 725b34a

Please sign in to comment.