Update mill to use state class total (#54581)

pull/54705/head
Daniel Hjelseth Høyer 2021-08-16 15:57:23 +02:00 committed by GitHub
parent 3e93215a1f
commit 979165669c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -2,7 +2,7 @@
from homeassistant.components.sensor import (
DEVICE_CLASS_ENERGY,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL,
SensorEntity,
)
from homeassistant.const import ENERGY_KILO_WATT_HOUR
@ -27,17 +27,18 @@ async def async_setup_entry(hass, entry, async_add_entities):
class MillHeaterEnergySensor(SensorEntity):
"""Representation of a Mill Sensor device."""
_attr_device_class = DEVICE_CLASS_ENERGY
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
_attr_state_class = STATE_CLASS_TOTAL
def __init__(self, heater, mill_data_connection, sensor_type):
"""Initialize the sensor."""
self._id = heater.device_id
self._conn = mill_data_connection
self._sensor_type = sensor_type
self._attr_device_class = DEVICE_CLASS_ENERGY
self._attr_name = f"{heater.name} {sensor_type.replace('_', ' ')}"
self._attr_unique_id = f"{heater.device_id}_{sensor_type}"
self._attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
self._attr_state_class = STATE_CLASS_MEASUREMENT
self._attr_device_info = {
"identifiers": {(DOMAIN, heater.device_id)},
"name": self.name,