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