Use new enums in lyric (#61888)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-15 16:37:35 +01:00 committed by GitHub
parent c9132b229d
commit 59e4b52065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,16 +10,12 @@ from aiolyric.objects.device import LyricDevice
from aiolyric.objects.location import LyricLocation
from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -81,8 +77,8 @@ async def async_setup_entry(
LyricSensorEntityDescription(
key=f"{device.macID}_indoor_temperature",
name="Indoor Temperature",
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=hass.config.units.temperature_unit,
value=lambda device: device.indoorTemperature,
),
@ -97,8 +93,8 @@ async def async_setup_entry(
LyricSensorEntityDescription(
key=f"{device.macID}_outdoor_temperature",
name="Outdoor Temperature",
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=hass.config.units.temperature_unit,
value=lambda device: device.outdoorTemperature,
),
@ -113,8 +109,8 @@ async def async_setup_entry(
LyricSensorEntityDescription(
key=f"{device.macID}_outdoor_humidity",
name="Outdoor Humidity",
device_class=DEVICE_CLASS_HUMIDITY,
state_class=STATE_CLASS_MEASUREMENT,
device_class=SensorDeviceClass.HUMIDITY,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement="%",
value=lambda device: device.displayedOutdoorHumidity,
),
@ -130,7 +126,7 @@ async def async_setup_entry(
LyricSensorEntityDescription(
key=f"{device.macID}_next_period_time",
name="Next Period Time",
device_class=DEVICE_CLASS_TIMESTAMP,
device_class=SensorDeviceClass.TIMESTAMP,
value=lambda device: get_datetime_from_future_time(
device.changeableValues.nextPeriodTime
),