mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use new enums in lyric (#61888)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
c9132b229d
commit
59e4b52065
@ -10,16 +10,12 @@ from aiolyric.objects.device import LyricDevice
|
|||||||
from aiolyric.objects.location import LyricLocation
|
from aiolyric.objects.location import LyricLocation
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
STATE_CLASS_MEASUREMENT,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
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.core import HomeAssistant
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
@ -81,8 +77,8 @@ async def async_setup_entry(
|
|||||||
LyricSensorEntityDescription(
|
LyricSensorEntityDescription(
|
||||||
key=f"{device.macID}_indoor_temperature",
|
key=f"{device.macID}_indoor_temperature",
|
||||||
name="Indoor Temperature",
|
name="Indoor Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=hass.config.units.temperature_unit,
|
native_unit_of_measurement=hass.config.units.temperature_unit,
|
||||||
value=lambda device: device.indoorTemperature,
|
value=lambda device: device.indoorTemperature,
|
||||||
),
|
),
|
||||||
@ -97,8 +93,8 @@ async def async_setup_entry(
|
|||||||
LyricSensorEntityDescription(
|
LyricSensorEntityDescription(
|
||||||
key=f"{device.macID}_outdoor_temperature",
|
key=f"{device.macID}_outdoor_temperature",
|
||||||
name="Outdoor Temperature",
|
name="Outdoor Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=hass.config.units.temperature_unit,
|
native_unit_of_measurement=hass.config.units.temperature_unit,
|
||||||
value=lambda device: device.outdoorTemperature,
|
value=lambda device: device.outdoorTemperature,
|
||||||
),
|
),
|
||||||
@ -113,8 +109,8 @@ async def async_setup_entry(
|
|||||||
LyricSensorEntityDescription(
|
LyricSensorEntityDescription(
|
||||||
key=f"{device.macID}_outdoor_humidity",
|
key=f"{device.macID}_outdoor_humidity",
|
||||||
name="Outdoor Humidity",
|
name="Outdoor Humidity",
|
||||||
device_class=DEVICE_CLASS_HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement="%",
|
native_unit_of_measurement="%",
|
||||||
value=lambda device: device.displayedOutdoorHumidity,
|
value=lambda device: device.displayedOutdoorHumidity,
|
||||||
),
|
),
|
||||||
@ -130,7 +126,7 @@ async def async_setup_entry(
|
|||||||
LyricSensorEntityDescription(
|
LyricSensorEntityDescription(
|
||||||
key=f"{device.macID}_next_period_time",
|
key=f"{device.macID}_next_period_time",
|
||||||
name="Next Period Time",
|
name="Next Period Time",
|
||||||
device_class=DEVICE_CLASS_TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
value=lambda device: get_datetime_from_future_time(
|
value=lambda device: get_datetime_from_future_time(
|
||||||
device.changeableValues.nextPeriodTime
|
device.changeableValues.nextPeriodTime
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user