From 77f6ac167ae4a236728b761b451857aaace8aa7b Mon Sep 17 00:00:00 2001 From: Thomas Schamm Date: Fri, 11 Mar 2022 12:23:09 +0100 Subject: [PATCH] Add long-term statistics to sensors. Increased to version 0.4.27 --- custom_components/bosch_shc/manifest.json | 2 +- custom_components/bosch_shc/sensor.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/custom_components/bosch_shc/manifest.json b/custom_components/bosch_shc/manifest.json index 2342cb2..51270f2 100644 --- a/custom_components/bosch_shc/manifest.json +++ b/custom_components/bosch_shc/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://github.com/tschamm/boschshc-hass/blob/master/README.md", "requirements": ["boschshcpy==0.2.30"], - "version": "0.4.26", + "version": "0.4.27", "zeroconf": [{ "type": "_http._tcp.local.", "name": "bosch shc*" }], "iot_class": "local_push", "issue_tracker": "https://github.com/tschamm/boschshc-hass/issues", diff --git a/custom_components/bosch_shc/sensor.py b/custom_components/bosch_shc/sensor.py index 331a5eb..58f59af 100644 --- a/custom_components/bosch_shc/sensor.py +++ b/custom_components/bosch_shc/sensor.py @@ -4,7 +4,11 @@ from boschshcpy import SHCSession from boschshcpy.device import SHCDevice -from homeassistant.components.sensor import SensorDeviceClass, SensorEntity +from homeassistant.components.sensor import ( + SensorDeviceClass, + SensorEntity, + SensorStateClass, +) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, @@ -162,6 +166,7 @@ class TemperatureSensor(SHCEntity, SensorEntity): _attr_device_class = SensorDeviceClass.TEMPERATURE _attr_native_unit_of_measurement = TEMP_CELSIUS + _attr_state_class = SensorStateClass.MEASUREMENT def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: """Initialize an SHC temperature reporting sensor.""" @@ -180,6 +185,7 @@ class HumiditySensor(SHCEntity, SensorEntity): _attr_device_class = SensorDeviceClass.HUMIDITY _attr_native_unit_of_measurement = PERCENTAGE + _attr_state_class = SensorStateClass.MEASUREMENT def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: """Initialize an SHC humidity reporting sensor.""" @@ -198,6 +204,7 @@ class PuritySensor(SHCEntity, SensorEntity): _attr_icon = "mdi:molecule-co2" _attr_native_unit_of_measurement = CONCENTRATION_PARTS_PER_MILLION + _attr_state_class = SensorStateClass.MEASUREMENT def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: """Initialize an SHC purity reporting sensor.""" @@ -300,6 +307,7 @@ class PowerSensor(SHCEntity, SensorEntity): _attr_device_class = SensorDeviceClass.POWER _attr_native_unit_of_measurement = POWER_WATT + _attr_state_class = SensorStateClass.MEASUREMENT def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: """Initialize an SHC power reporting sensor.""" @@ -318,6 +326,7 @@ class EnergySensor(SHCEntity, SensorEntity): _attr_device_class = SensorDeviceClass.ENERGY _attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR + _attr_state_class = SensorStateClass.TOTAL_INCREASING def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: """Initialize an SHC energy reporting sensor."""