mirror of
https://github.com/home-assistant/core
synced 2024-07-12 07:21:24 +02: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 (
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
STATE_CLASS_TOTAL,
|
||||
STATE_CLASS_TOTAL_INCREASING,
|
||||
SensorEntity,
|
||||
)
|
||||
@ -40,9 +41,9 @@ async def async_setup_entry(
|
||||
async_add_entities(
|
||||
[
|
||||
GasSensor(coordinator, device),
|
||||
PowerMeterSensor(coordinator, device, "low"),
|
||||
PowerMeterSensor(coordinator, device, "high"),
|
||||
PowerMeterSensor(coordinator, device, "total"),
|
||||
PowerMeterSensor(coordinator, device, "low", STATE_CLASS_TOTAL_INCREASING),
|
||||
PowerMeterSensor(coordinator, device, "high", STATE_CLASS_TOTAL_INCREASING),
|
||||
PowerMeterSensor(coordinator, device, "total", STATE_CLASS_TOTAL),
|
||||
CurrentPowerSensor(coordinator, device),
|
||||
DeliveryMeterSensor(coordinator, device, "low"),
|
||||
DeliveryMeterSensor(coordinator, device, "high"),
|
||||
@ -168,7 +169,11 @@ class PowerMeterSensor(YoulessBaseSensor):
|
||||
_attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
||||
|
||||
def __init__(
|
||||
self, coordinator: DataUpdateCoordinator, device: str, dev_type: str
|
||||
self,
|
||||
coordinator: DataUpdateCoordinator,
|
||||
device: str,
|
||||
dev_type: str,
|
||||
state_class: str,
|
||||
) -> None:
|
||||
"""Instantiate a power meter sensor."""
|
||||
super().__init__(
|
||||
@ -177,6 +182,7 @@ class PowerMeterSensor(YoulessBaseSensor):
|
||||
self._device = device
|
||||
self._type = dev_type
|
||||
self._attr_name = f"Power {dev_type}"
|
||||
self._attr_state_class = state_class
|
||||
|
||||
@property
|
||||
def get_sensor(self) -> YoulessSensor | None:
|
||||
|
Loading…
Reference in New Issue
Block a user