From 3a36d0b13f9e27a23ba48d232efcf207b7044082 Mon Sep 17 00:00:00 2001 From: konsulten Date: Mon, 20 Feb 2023 03:48:59 +0100 Subject: [PATCH] BL0939 state_class set for energy sensors (#4463) BL0939 was missing TOTAL_INCREASING for energy (kWh) thus it did not show as statistics in home assistant --- esphome/components/bl0939/sensor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/bl0939/sensor.py b/esphome/components/bl0939/sensor.py index bcc72ad61a..4c6e3ea4d9 100644 --- a/esphome/components/bl0939/sensor.py +++ b/esphome/components/bl0939/sensor.py @@ -9,6 +9,7 @@ from esphome.const import ( DEVICE_CLASS_POWER, DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, + STATE_CLASS_TOTAL_INCREASING, UNIT_AMPERE, UNIT_KILOWATT_HOURS, UNIT_VOLT, @@ -66,16 +67,19 @@ CONFIG_SCHEMA = ( unit_of_measurement=UNIT_KILOWATT_HOURS, accuracy_decimals=3, device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, ), cv.Optional(CONF_ENERGY_2): sensor.sensor_schema( unit_of_measurement=UNIT_KILOWATT_HOURS, accuracy_decimals=3, device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, ), cv.Optional(CONF_ENERGY_TOTAL): sensor.sensor_schema( unit_of_measurement=UNIT_KILOWATT_HOURS, accuracy_decimals=3, device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, ), } )