mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Fix Youless state class for power total sensor (#57758)
This commit is contained in:
parent
f02522783a
commit
cb625d1c7a
@ -5,6 +5,7 @@ from youless_api.youless_sensor import YoulessSensor
|
|||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
|
STATE_CLASS_TOTAL,
|
||||||
STATE_CLASS_TOTAL_INCREASING,
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
)
|
)
|
||||||
@ -40,9 +41,9 @@ async def async_setup_entry(
|
|||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
GasSensor(coordinator, device),
|
GasSensor(coordinator, device),
|
||||||
PowerMeterSensor(coordinator, device, "low"),
|
PowerMeterSensor(coordinator, device, "low", STATE_CLASS_TOTAL_INCREASING),
|
||||||
PowerMeterSensor(coordinator, device, "high"),
|
PowerMeterSensor(coordinator, device, "high", STATE_CLASS_TOTAL_INCREASING),
|
||||||
PowerMeterSensor(coordinator, device, "total"),
|
PowerMeterSensor(coordinator, device, "total", STATE_CLASS_TOTAL),
|
||||||
CurrentPowerSensor(coordinator, device),
|
CurrentPowerSensor(coordinator, device),
|
||||||
DeliveryMeterSensor(coordinator, device, "low"),
|
DeliveryMeterSensor(coordinator, device, "low"),
|
||||||
DeliveryMeterSensor(coordinator, device, "high"),
|
DeliveryMeterSensor(coordinator, device, "high"),
|
||||||
@ -168,7 +169,11 @@ class PowerMeterSensor(YoulessBaseSensor):
|
|||||||
_attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
_attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, coordinator: DataUpdateCoordinator, device: str, dev_type: str
|
self,
|
||||||
|
coordinator: DataUpdateCoordinator,
|
||||||
|
device: str,
|
||||||
|
dev_type: str,
|
||||||
|
state_class: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Instantiate a power meter sensor."""
|
"""Instantiate a power meter sensor."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
@ -177,6 +182,7 @@ class PowerMeterSensor(YoulessBaseSensor):
|
|||||||
self._device = device
|
self._device = device
|
||||||
self._type = dev_type
|
self._type = dev_type
|
||||||
self._attr_name = f"Power {dev_type}"
|
self._attr_name = f"Power {dev_type}"
|
||||||
|
self._attr_state_class = state_class
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_sensor(self) -> YoulessSensor | None:
|
def get_sensor(self) -> YoulessSensor | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user