Skip to content

Commit

Permalink
Fix state and device class of the total generated energy sensor
Browse files Browse the repository at this point in the history
Kudos to @daniil226
  • Loading branch information
syssi committed Jul 31, 2024
1 parent 1ef015f commit 449c695
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions components/pipsolar/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
import esphome.config_validation as cv
from esphome.components import sensor
from esphome.const import (
CONF_BATTERY_VOLTAGE,
CONF_BUS_VOLTAGE,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_POWER,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLTAGE,
ICON_COUNTER,
ICON_CURRENT_AC,
UNIT_AMPERE,
UNIT_CELSIUS,
Expand All @@ -14,10 +17,10 @@
UNIT_VOLT,
UNIT_VOLT_AMPS,
UNIT_WATT,
CONF_BUS_VOLTAGE,
CONF_BATTERY_VOLTAGE,
UNIT_WATT_HOURS,
)
from .. import PIPSOLAR_COMPONENT_SCHEMA, CONF_PIPSOLAR_ID

from .. import CONF_PIPSOLAR_ID, PIPSOLAR_COMPONENT_SCHEMA

DEPENDENCIES = ["uart"]

Expand Down Expand Up @@ -305,9 +308,11 @@
accuracy_decimals=0,
),
CONF_TOTAL_GENERATED_ENERGY: sensor.sensor_schema(
unit_of_measurement=UNIT_WATT,
unit_of_measurement=UNIT_WATT_HOURS,
icon=ICON_COUNTER,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
# for all in parallel
CONF_TOTAL_AC_OUTPUT_APPARENT_POWER: sensor.sensor_schema(
Expand Down

0 comments on commit 449c695

Please sign in to comment.