Skip to content

Commit

Permalink
Merge pull request #135 from DasBasti/121-add-long-term-statistics-su…
Browse files Browse the repository at this point in the history
…pport

Sensor: fix state class according to dev doc
  • Loading branch information
DasBasti authored Aug 4, 2024
2 parents da38376 + c47dd45 commit 700244d
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 700244d

Please sign in to comment.