Skip to content

Commit

Permalink
MAI: Migrate to new unit of measure constant (#90)
Browse files Browse the repository at this point in the history
Homeassistant Core has deprecated the TEMP_CELSIUS constant.
The new constant is an ENUM which collects all temp units together.

Closes #66
  • Loading branch information
carterbox authored Jul 7, 2024
1 parent 3abcffb commit 569f25e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions custom_components/aquanta/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
SensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS, PERCENTAGE
from homeassistant.const import UnitOfTemperature, PERCENTAGE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

Expand All @@ -23,7 +23,7 @@
name="Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
icon="mdi:water-thermometer",
),
"native_value": lambda entity: entity.coordinator.data["devices"][
Expand All @@ -38,7 +38,7 @@
name="Set point",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
icon="mdi:thermometer-water",
),
"native_value": lambda entity: entity.coordinator.data["devices"][
Expand Down
6 changes: 2 additions & 4 deletions custom_components/aquanta/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
WaterHeaterEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
TEMP_CELSIUS,
)
from homeassistant.const import UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

Expand Down Expand Up @@ -41,7 +39,7 @@ class AquantaWaterHeater(AquantaEntity, WaterHeaterEntity):

_attr_has_entity_name = True
_attr_supported_features = WaterHeaterEntityFeature.AWAY_MODE
_attr_temperature_unit = TEMP_CELSIUS
_attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_operation_list = [STATE_ECO, STATE_PERFORMANCE, STATE_OFF]
_attr_name = "Water heater"

Expand Down

0 comments on commit 569f25e

Please sign in to comment.