Skip to content

Commit

Permalink
fixing state class for layers (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolivierarsenault authored Sep 6, 2023
1 parent 687d1ab commit ca6ba95
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions custom_components/moonraker/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.const import PERCENTAGE, UnitOfLength, UnitOfTemperature, UnitOfTime
from homeassistant.core import callback
Expand Down Expand Up @@ -268,13 +269,15 @@ class MoonrakerSensorDescription(SensorEntityDescription):
),
subscriptions=[("print_stats", "info", "total_layer")],
icon="mdi:layers-triple",
state_class=SensorStateClass.MEASUREMENT,
),
MoonrakerSensorDescription(
key="current_layer",
name="Current Layer",
value_fn=lambda sensor: calculate_current_layer(sensor.coordinator.data),
subscriptions=[("print_stats", "info", "current_layer")],
icon="mdi:layers-edit",
state_class=SensorStateClass.MEASUREMENT,
),
MoonrakerSensorDescription(
key="toolhead_position_x",
Expand Down Expand Up @@ -421,6 +424,7 @@ async def async_setup_history_sensors(coordinator, entry, async_add_entities):
subscriptions=[],
icon="mdi:numeric",
unit="Jobs",
state_class=SensorStateClass.TOTAL_INCREASING,
),
MoonrakerSensorDescription(
key="total_print_time",
Expand All @@ -442,6 +446,7 @@ async def async_setup_history_sensors(coordinator, entry, async_add_entities):
subscriptions=[],
icon="mdi:clock-outline",
unit=UnitOfLength.METERS,
state_class=SensorStateClass.TOTAL_INCREASING,
),
MoonrakerSensorDescription(
key="longest_print",
Expand Down

0 comments on commit ca6ba95

Please sign in to comment.