From 4345432d14defb3a299f770d2353a604261dc386 Mon Sep 17 00:00:00 2001 From: hesselonline Date: Thu, 4 Nov 2021 09:58:58 +0100 Subject: [PATCH] Add state class to wallbox component (#58801) --- homeassistant/components/wallbox/sensor.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/wallbox/sensor.py b/homeassistant/components/wallbox/sensor.py index 25c0796d0bd..affc78d6210 100644 --- a/homeassistant/components/wallbox/sensor.py +++ b/homeassistant/components/wallbox/sensor.py @@ -4,7 +4,12 @@ from __future__ import annotations from dataclasses import dataclass import logging -from homeassistant.components.sensor import SensorEntity, SensorEntityDescription +from homeassistant.components.sensor import ( + STATE_CLASS_MEASUREMENT, + STATE_CLASS_TOTAL_INCREASING, + SensorEntity, + SensorEntityDescription, +) from homeassistant.const import ( DEVICE_CLASS_BATTERY, DEVICE_CLASS_CURRENT, @@ -54,6 +59,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { precision=2, native_unit_of_measurement=POWER_KILO_WATT, device_class=DEVICE_CLASS_POWER, + state_class=STATE_CLASS_MEASUREMENT, ), CONF_MAX_AVAILABLE_POWER_KEY: WallboxSensorEntityDescription( key=CONF_MAX_AVAILABLE_POWER_KEY, @@ -61,12 +67,14 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { precision=0, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, device_class=DEVICE_CLASS_CURRENT, + state_class=STATE_CLASS_MEASUREMENT, ), CONF_CHARGING_SPEED_KEY: WallboxSensorEntityDescription( key=CONF_CHARGING_SPEED_KEY, icon="mdi:speedometer", name="Charging Speed", precision=0, + state_class=STATE_CLASS_MEASUREMENT, ), CONF_ADDED_RANGE_KEY: WallboxSensorEntityDescription( key=CONF_ADDED_RANGE_KEY, @@ -74,6 +82,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { name="Added Range", precision=0, native_unit_of_measurement=LENGTH_KILOMETERS, + state_class=STATE_CLASS_TOTAL_INCREASING, ), CONF_ADDED_ENERGY_KEY: WallboxSensorEntityDescription( key=CONF_ADDED_ENERGY_KEY, @@ -81,17 +90,20 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { precision=2, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, ), CONF_COST_KEY: WallboxSensorEntityDescription( key=CONF_COST_KEY, icon="mdi:ev-station", name="Cost", + state_class=STATE_CLASS_TOTAL_INCREASING, ), CONF_STATE_OF_CHARGE_KEY: WallboxSensorEntityDescription( key=CONF_STATE_OF_CHARGE_KEY, name="State of Charge", native_unit_of_measurement=PERCENTAGE, device_class=DEVICE_CLASS_BATTERY, + state_class=STATE_CLASS_MEASUREMENT, ), CONF_CURRENT_MODE_KEY: WallboxSensorEntityDescription( key=CONF_CURRENT_MODE_KEY, @@ -114,6 +126,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { name="Max. Charging Current", native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, device_class=DEVICE_CLASS_CURRENT, + state_class=STATE_CLASS_MEASUREMENT, ), }