Use state class total increasing for TPLink smart plugs (#54723)

This commit is contained in:
Michael 2021-08-16 23:54:11 +02:00 committed by GitHub
parent de0460de61
commit 684d035969
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 13 deletions

View file

@ -6,8 +6,8 @@ from typing import Any, Final
from pyHS100 import SmartPlug
from homeassistant.components.sensor import (
ATTR_LAST_RESET,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity,
SensorEntityDescription,
)
@ -62,14 +62,14 @@ ENERGY_SENSORS: Final[list[SensorEntityDescription]] = [
key=ATTR_TOTAL_ENERGY_KWH,
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_MEASUREMENT,
state_class=STATE_CLASS_TOTAL_INCREASING,
name="Total Consumption",
),
SensorEntityDescription(
key=ATTR_TODAY_ENERGY_KWH,
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_MEASUREMENT,
state_class=STATE_CLASS_TOTAL_INCREASING,
name="Today's Consumption",
),
SensorEntityDescription(
@ -127,9 +127,6 @@ class SmartPlugSensor(CoordinatorEntity, SensorEntity):
self.smartplug = smartplug
self.entity_description = description
self._attr_name = f"{coordinator.data[CONF_ALIAS]} {description.name}"
self._attr_last_reset = coordinator.data[CONF_EMETER_PARAMS][
ATTR_LAST_RESET
].get(description.key)
@property
def data(self) -> dict[str, Any]: