Add state class to Huisbaasje (#52114)
parent
33e2b910c2
commit
b3b23066a8
|
@ -8,6 +8,7 @@ from huisbaasje.const import (
|
|||
SOURCE_TYPE_GAS,
|
||||
)
|
||||
|
||||
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_POWER,
|
||||
|
@ -48,26 +49,31 @@ SENSORS_INFO = [
|
|||
"name": "Huisbaasje Current Power",
|
||||
"device_class": DEVICE_CLASS_POWER,
|
||||
"source_type": SOURCE_TYPE_ELECTRICITY,
|
||||
"state_class": STATE_CLASS_MEASUREMENT,
|
||||
},
|
||||
{
|
||||
"name": "Huisbaasje Current Power In",
|
||||
"device_class": DEVICE_CLASS_POWER,
|
||||
"source_type": SOURCE_TYPE_ELECTRICITY_IN,
|
||||
"state_class": STATE_CLASS_MEASUREMENT,
|
||||
},
|
||||
{
|
||||
"name": "Huisbaasje Current Power In Low",
|
||||
"device_class": DEVICE_CLASS_POWER,
|
||||
"source_type": SOURCE_TYPE_ELECTRICITY_IN_LOW,
|
||||
"state_class": STATE_CLASS_MEASUREMENT,
|
||||
},
|
||||
{
|
||||
"name": "Huisbaasje Current Power Out",
|
||||
"device_class": DEVICE_CLASS_POWER,
|
||||
"source_type": SOURCE_TYPE_ELECTRICITY_OUT,
|
||||
"state_class": STATE_CLASS_MEASUREMENT,
|
||||
},
|
||||
{
|
||||
"name": "Huisbaasje Current Power Out Low",
|
||||
"device_class": DEVICE_CLASS_POWER,
|
||||
"source_type": SOURCE_TYPE_ELECTRICITY_OUT_LOW,
|
||||
"state_class": STATE_CLASS_MEASUREMENT,
|
||||
},
|
||||
{
|
||||
"name": "Huisbaasje Energy Today",
|
||||
|
@ -107,6 +113,7 @@ SENSORS_INFO = [
|
|||
"source_type": SOURCE_TYPE_GAS,
|
||||
"icon": "mdi:fire",
|
||||
"precision": 1,
|
||||
"state_class": STATE_CLASS_MEASUREMENT,
|
||||
},
|
||||
{
|
||||
"name": "Huisbaasje Gas Today",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Platform for sensor integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ID, POWER_WATT
|
||||
|
@ -38,6 +40,7 @@ class HuisbaasjeSensor(CoordinatorEntity, SensorEntity):
|
|||
unit_of_measurement: str = POWER_WATT,
|
||||
icon: str = "mdi:lightning-bolt",
|
||||
precision: int = 0,
|
||||
state_class: str | None = None,
|
||||
) -> None:
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(coordinator)
|
||||
|
@ -49,6 +52,7 @@ class HuisbaasjeSensor(CoordinatorEntity, SensorEntity):
|
|||
self._sensor_type = sensor_type
|
||||
self._icon = icon
|
||||
self._precision = precision
|
||||
self._attr_state_class = state_class
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
|
|
Loading…
Reference in New Issue