mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Update mill to use state class total (#54581)
This commit is contained in:
parent
3e93215a1f
commit
979165669c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
DEVICE_CLASS_ENERGY,
|
DEVICE_CLASS_ENERGY,
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_TOTAL,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR
|
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):
|
class MillHeaterEnergySensor(SensorEntity):
|
||||||
"""Representation of a Mill Sensor device."""
|
"""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):
|
def __init__(self, heater, mill_data_connection, sensor_type):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._id = heater.device_id
|
self._id = heater.device_id
|
||||||
self._conn = mill_data_connection
|
self._conn = mill_data_connection
|
||||||
self._sensor_type = sensor_type
|
self._sensor_type = sensor_type
|
||||||
|
|
||||||
self._attr_device_class = DEVICE_CLASS_ENERGY
|
|
||||||
self._attr_name = f"{heater.name} {sensor_type.replace('_', ' ')}"
|
self._attr_name = f"{heater.name} {sensor_type.replace('_', ' ')}"
|
||||||
self._attr_unique_id = f"{heater.device_id}_{sensor_type}"
|
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 = {
|
self._attr_device_info = {
|
||||||
"identifiers": {(DOMAIN, heater.device_id)},
|
"identifiers": {(DOMAIN, heater.device_id)},
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user