From b3b23066a8cb6d68e136064c97046bbc0e334c9c Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 23 Jun 2021 13:11:33 +0200 Subject: [PATCH] Add state class to Huisbaasje (#52114) --- homeassistant/components/huisbaasje/const.py | 7 +++++++ homeassistant/components/huisbaasje/sensor.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/homeassistant/components/huisbaasje/const.py b/homeassistant/components/huisbaasje/const.py index abac03e6182..f2565a15ce2 100644 --- a/homeassistant/components/huisbaasje/const.py +++ b/homeassistant/components/huisbaasje/const.py @@ -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", diff --git a/homeassistant/components/huisbaasje/sensor.py b/homeassistant/components/huisbaasje/sensor.py index 1ea392b8269..038325ece4a 100644 --- a/homeassistant/components/huisbaasje/sensor.py +++ b/homeassistant/components/huisbaasje/sensor.py @@ -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: