mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Add state class to Enphase Envoy (#52113)
This commit is contained in:
parent
38daf94562
commit
5b663b1fb9
@ -1,6 +1,7 @@
|
|||||||
"""The enphase_envoy component."""
|
"""The enphase_envoy component."""
|
||||||
|
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT
|
||||||
from homeassistant.const import ENERGY_WATT_HOUR, POWER_WATT
|
from homeassistant.const import ENERGY_WATT_HOUR, POWER_WATT
|
||||||
|
|
||||||
DOMAIN = "enphase_envoy"
|
DOMAIN = "enphase_envoy"
|
||||||
@ -12,19 +13,21 @@ COORDINATOR = "coordinator"
|
|||||||
NAME = "name"
|
NAME = "name"
|
||||||
|
|
||||||
SENSORS = {
|
SENSORS = {
|
||||||
"production": ("Current Energy Production", POWER_WATT),
|
"production": ("Current Energy Production", POWER_WATT, STATE_CLASS_MEASUREMENT),
|
||||||
"daily_production": ("Today's Energy Production", ENERGY_WATT_HOUR),
|
"daily_production": ("Today's Energy Production", ENERGY_WATT_HOUR, None),
|
||||||
"seven_days_production": (
|
"seven_days_production": (
|
||||||
"Last Seven Days Energy Production",
|
"Last Seven Days Energy Production",
|
||||||
ENERGY_WATT_HOUR,
|
ENERGY_WATT_HOUR,
|
||||||
|
None,
|
||||||
),
|
),
|
||||||
"lifetime_production": ("Lifetime Energy Production", ENERGY_WATT_HOUR),
|
"lifetime_production": ("Lifetime Energy Production", ENERGY_WATT_HOUR, None),
|
||||||
"consumption": ("Current Energy Consumption", POWER_WATT),
|
"consumption": ("Current Energy Consumption", POWER_WATT, STATE_CLASS_MEASUREMENT),
|
||||||
"daily_consumption": ("Today's Energy Consumption", ENERGY_WATT_HOUR),
|
"daily_consumption": ("Today's Energy Consumption", ENERGY_WATT_HOUR, None),
|
||||||
"seven_days_consumption": (
|
"seven_days_consumption": (
|
||||||
"Last Seven Days Energy Consumption",
|
"Last Seven Days Energy Consumption",
|
||||||
ENERGY_WATT_HOUR,
|
ENERGY_WATT_HOUR,
|
||||||
|
None,
|
||||||
),
|
),
|
||||||
"lifetime_consumption": ("Lifetime Energy Consumption", ENERGY_WATT_HOUR),
|
"lifetime_consumption": ("Lifetime Energy Consumption", ENERGY_WATT_HOUR, None),
|
||||||
"inverters": ("Inverter", POWER_WATT),
|
"inverters": ("Inverter", POWER_WATT, STATE_CLASS_MEASUREMENT),
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
config_entry.unique_id,
|
config_entry.unique_id,
|
||||||
serial_number,
|
serial_number,
|
||||||
SENSORS[condition][1],
|
SENSORS[condition][1],
|
||||||
|
SENSORS[condition][2],
|
||||||
coordinator,
|
coordinator,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -91,6 +92,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
config_entry.unique_id,
|
config_entry.unique_id,
|
||||||
None,
|
None,
|
||||||
SENSORS[condition][1],
|
SENSORS[condition][1],
|
||||||
|
SENSORS[condition][2],
|
||||||
coordinator,
|
coordinator,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -109,6 +111,7 @@ class Envoy(CoordinatorEntity, SensorEntity):
|
|||||||
device_serial_number,
|
device_serial_number,
|
||||||
serial_number,
|
serial_number,
|
||||||
unit,
|
unit,
|
||||||
|
state_class,
|
||||||
coordinator,
|
coordinator,
|
||||||
):
|
):
|
||||||
"""Initialize Envoy entity."""
|
"""Initialize Envoy entity."""
|
||||||
@ -118,6 +121,7 @@ class Envoy(CoordinatorEntity, SensorEntity):
|
|||||||
self._device_name = device_name
|
self._device_name = device_name
|
||||||
self._device_serial_number = device_serial_number
|
self._device_serial_number = device_serial_number
|
||||||
self._unit_of_measurement = unit
|
self._unit_of_measurement = unit
|
||||||
|
self._attr_state_class = state_class
|
||||||
|
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user