Use new enums in forecast_solar (#61443)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/61450/head
parent
4d282eca6d
commit
731c70a0e7
|
@ -3,14 +3,8 @@ from __future__ import annotations
|
|||
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_TIMESTAMP,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
POWER_WATT,
|
||||
)
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT
|
||||
|
||||
from .models import ForecastSolarSensorEntityDescription
|
||||
|
||||
|
@ -26,32 +20,32 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
|
|||
key="energy_production_today",
|
||||
name="Estimated Energy Production - Today",
|
||||
state=lambda estimate: estimate.energy_production_today / 1000,
|
||||
device_class=DEVICE_CLASS_ENERGY,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
),
|
||||
ForecastSolarSensorEntityDescription(
|
||||
key="energy_production_tomorrow",
|
||||
name="Estimated Energy Production - Tomorrow",
|
||||
state=lambda estimate: estimate.energy_production_tomorrow / 1000,
|
||||
device_class=DEVICE_CLASS_ENERGY,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
),
|
||||
ForecastSolarSensorEntityDescription(
|
||||
key="power_highest_peak_time_today",
|
||||
name="Highest Power Peak Time - Today",
|
||||
device_class=DEVICE_CLASS_TIMESTAMP,
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
),
|
||||
ForecastSolarSensorEntityDescription(
|
||||
key="power_highest_peak_time_tomorrow",
|
||||
name="Highest Power Peak Time - Tomorrow",
|
||||
device_class=DEVICE_CLASS_TIMESTAMP,
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
),
|
||||
ForecastSolarSensorEntityDescription(
|
||||
key="power_production_now",
|
||||
name="Estimated Power Production - Now",
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state=lambda estimate: estimate.power_production_now,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
),
|
||||
ForecastSolarSensorEntityDescription(
|
||||
|
@ -60,7 +54,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
|
|||
estimate.now() + timedelta(hours=1)
|
||||
),
|
||||
name="Estimated Power Production - Next Hour",
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
entity_registry_enabled_default=False,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
),
|
||||
|
@ -70,7 +64,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
|
|||
estimate.now() + timedelta(hours=12)
|
||||
),
|
||||
name="Estimated Power Production - Next 12 Hours",
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
entity_registry_enabled_default=False,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
),
|
||||
|
@ -80,7 +74,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
|
|||
estimate.now() + timedelta(hours=24)
|
||||
),
|
||||
name="Estimated Power Production - Next 24 Hours",
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
entity_registry_enabled_default=False,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
),
|
||||
|
@ -88,14 +82,14 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
|
|||
key="energy_current_hour",
|
||||
name="Estimated Energy Production - This Hour",
|
||||
state=lambda estimate: estimate.energy_current_hour / 1000,
|
||||
device_class=DEVICE_CLASS_ENERGY,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
),
|
||||
ForecastSolarSensorEntityDescription(
|
||||
key="energy_next_hour",
|
||||
state=lambda estimate: estimate.sum_energy_production(1) / 1000,
|
||||
name="Estimated Energy Production - Next Hour",
|
||||
device_class=DEVICE_CLASS_ENERGY,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue