Use unit enums in nexia (#84349)

This commit is contained in:
epenet 2022-12-21 11:13:16 +01:00 committed by GitHub
parent 316f187bee
commit af7a487706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.const import PERCENTAGE, UnitOfTemperature
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -86,11 +86,10 @@ async def async_setup_entry(
) )
# Outdoor Temperature # Outdoor Temperature
if thermostat.has_outdoor_temperature(): if thermostat.has_outdoor_temperature():
unit = ( if thermostat.get_unit() == UNIT_CELSIUS:
TEMP_CELSIUS unit = UnitOfTemperature.CELSIUS
if thermostat.get_unit() == UNIT_CELSIUS else:
else TEMP_FAHRENHEIT unit = UnitOfTemperature.FAHRENHEIT
)
entities.append( entities.append(
NexiaThermostatSensor( NexiaThermostatSensor(
coordinator, coordinator,
@ -120,11 +119,10 @@ async def async_setup_entry(
# Zone Sensors # Zone Sensors
for zone_id in thermostat.get_zone_ids(): for zone_id in thermostat.get_zone_ids():
zone = thermostat.get_zone_by_id(zone_id) zone = thermostat.get_zone_by_id(zone_id)
unit = ( if thermostat.get_unit() == UNIT_CELSIUS:
TEMP_CELSIUS unit = UnitOfTemperature.CELSIUS
if thermostat.get_unit() == UNIT_CELSIUS else:
else TEMP_FAHRENHEIT unit = UnitOfTemperature.FAHRENHEIT
)
# Temperature # Temperature
entities.append( entities.append(
NexiaThermostatZoneSensor( NexiaThermostatZoneSensor(