Update melcloud to use state class total increasing (#54607)
This commit is contained in:
parent
99a62799ae
commit
75a2ac0808
1 changed files with 4 additions and 3 deletions
|
@ -11,11 +11,11 @@ from homeassistant.components.sensor import (
|
||||||
DEVICE_CLASS_ENERGY,
|
DEVICE_CLASS_ENERGY,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS
|
from homeassistant.const import ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS
|
||||||
from homeassistant.util import dt as dt_util
|
|
||||||
|
|
||||||
from . import MelCloudDevice
|
from . import MelCloudDevice
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -150,10 +150,11 @@ class MelDeviceSensor(SensorEntity):
|
||||||
|
|
||||||
self._attr_name = f"{api.name} {description.name}"
|
self._attr_name = f"{api.name} {description.name}"
|
||||||
self._attr_unique_id = f"{api.device.serial}-{api.device.mac}-{description.key}"
|
self._attr_unique_id = f"{api.device.serial}-{api.device.mac}-{description.key}"
|
||||||
self._attr_state_class = STATE_CLASS_MEASUREMENT
|
|
||||||
|
|
||||||
if description.device_class == DEVICE_CLASS_ENERGY:
|
if description.device_class == DEVICE_CLASS_ENERGY:
|
||||||
self._attr_last_reset = dt_util.utc_from_timestamp(0)
|
self._attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
||||||
|
else:
|
||||||
|
self._attr_state_class = STATE_CLASS_MEASUREMENT
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue