Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set sensor state class to enable statistics #62

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions custom_components/biketrax/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
Expand Down Expand Up @@ -50,6 +51,7 @@ class BikeTraxSensorEntityDescription(
key="battery_level",
name="Battery level",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
BikeTraxSensorEntityDescription(
coordinator=DATA_DEVICE,
Expand All @@ -58,6 +60,7 @@ class BikeTraxSensorEntityDescription(
key="total_distance",
name="Total distance",
native_unit_of_measurement=LENGTH_KILOMETERS,
state_class=SensorStateClass.TOTAL_INCREASING,
),
BikeTraxSensorEntityDescription(
coordinator=DATA_DEVICE,
Expand All @@ -66,6 +69,7 @@ class BikeTraxSensorEntityDescription(
key="speed",
name="Current speed",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
state_class=SensorStateClass.MEASUREMENT,
),
BikeTraxSensorEntityDescription(
coordinator=DATA_SUBSCRIPTION,
Expand Down