Skip to content

Commit

Permalink
Sensor: fix state class according to dev doc
Browse files Browse the repository at this point in the history
  • Loading branch information
DasBasti committed Aug 4, 2024
1 parent f9caa2d commit c47dd45
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions custom_components/smarthashtag/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@
name="Odometer",
icon="mdi:counter",
device_class=SensorDeviceClass.DISTANCE,
state_class=SensorStateClass.TOTAL_INCREASING,
# The sensor's value never resets
# https://developers.home-assistant.io/docs/core/entity/sensor/#how-to-choose-state_class-and-last_reset
state_class=SensorStateClass.TOTAL,
last_reset=None,
native_unit_of_measurement="km",
),
SensorEntityDescription(
Expand Down Expand Up @@ -366,7 +369,9 @@
name="Trip meter 1",
icon="mdi:counter",
device_class=SensorDeviceClass.DISTANCE,
state_class=SensorStateClass.TOTAL,
# The sensor's value may reset to 0, and its value can only increase
# https://developers.home-assistant.io/docs/core/entity/sensor/#how-to-choose-state_class-and-last_reset
state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement="km",
),
SensorEntityDescription(
Expand All @@ -375,7 +380,9 @@
name="Trip meter 2",
icon="mdi:counter",
device_class=SensorDeviceClass.DISTANCE,
state_class=SensorStateClass.TOTAL,
# The sensor's value may reset to 0, and its value can only increase
# https://developers.home-assistant.io/docs/core/entity/sensor/#how-to-choose-state_class-and-last_reset
state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement="km",
),
SensorEntityDescription(
Expand Down

0 comments on commit c47dd45

Please sign in to comment.