Use new SensorStateClass enum in amberelectric (#61265)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-08 21:13:33 +01:00 committed by GitHub
parent e4e0dcbae0
commit 549b72e48e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,9 +15,9 @@ from amberelectric.model.current_interval import CurrentInterval
from amberelectric.model.forecast_interval import ForecastInterval from amberelectric.model.forecast_interval import ForecastInterval
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CURRENCY_DOLLAR, ENERGY_KILO_WATT_HOUR from homeassistant.const import CURRENCY_DOLLAR, ENERGY_KILO_WATT_HOUR
@ -209,7 +209,7 @@ async def async_setup_entry(
key="current", key="current",
name=f"{entry.title} - {friendly_channel_type(channel_type)} Price", name=f"{entry.title} - {friendly_channel_type(channel_type)} Price",
native_unit_of_measurement=UNIT, native_unit_of_measurement=UNIT,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon=ICONS[channel_type], icon=ICONS[channel_type],
) )
entities.append(AmberPriceSensor(coordinator, description, channel_type)) entities.append(AmberPriceSensor(coordinator, description, channel_type))
@ -219,7 +219,7 @@ async def async_setup_entry(
key="forecasts", key="forecasts",
name=f"{entry.title} - {friendly_channel_type(channel_type)} Forecast", name=f"{entry.title} - {friendly_channel_type(channel_type)} Forecast",
native_unit_of_measurement=UNIT, native_unit_of_measurement=UNIT,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon=ICONS[channel_type], icon=ICONS[channel_type],
) )
entities.append(AmberForecastSensor(coordinator, description, channel_type)) entities.append(AmberForecastSensor(coordinator, description, channel_type))
@ -228,7 +228,7 @@ async def async_setup_entry(
key="renewables", key="renewables",
name=f"{entry.title} - Renewables", name=f"{entry.title} - Renewables",
native_unit_of_measurement="%", native_unit_of_measurement="%",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon="mdi:solar-power", icon="mdi:solar-power",
) )
entities.append(AmberGridSensor(coordinator, renewables_description)) entities.append(AmberGridSensor(coordinator, renewables_description))