diff --git a/custom_components/moonraker/sensor.py b/custom_components/moonraker/sensor.py index 589a9a7..b2d45b9 100755 --- a/custom_components/moonraker/sensor.py +++ b/custom_components/moonraker/sensor.py @@ -552,11 +552,13 @@ async def async_setup_history_sensors(coordinator, entry, async_add_entities): MoonrakerSensorDescription( key="total_print_time", name="Totals Print Time", - value_fn=lambda sensor: convert_time( - sensor.coordinator.data["history"]["job_totals"]["total_print_time"] - ), + value_fn=lambda sensor: sensor.coordinator.data["history"]["job_totals"][ + "total_print_time" + ], subscriptions=[], icon="mdi:clock-outline", + device_class=SensorDeviceClass.DURATION, + unit=UnitOfTime.SECONDS, ), MoonrakerSensorDescription( key="total_filament_used", @@ -574,11 +576,13 @@ async def async_setup_history_sensors(coordinator, entry, async_add_entities): MoonrakerSensorDescription( key="longest_print", name="Longest Print", - value_fn=lambda sensor: convert_time( - sensor.coordinator.data["history"]["job_totals"]["longest_print"] - ), + value_fn=lambda sensor: sensor.coordinator.data["history"]["job_totals"][ + "longest_print" + ], subscriptions=[], icon="mdi:clock-outline", + device_class=SensorDeviceClass.DURATION, + unit=UnitOfTime.SECONDS, ), ] diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 3609af4..77785ef 100755 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -101,10 +101,10 @@ async def test_sensor_services_update(hass, get_data): ("mainsail_heater_fan", "51.23"), ("mainsail_controller_fan", "51.23"), ("mainsail_nevermore_fan", "12.34"), - ("mainsail_totals_print_time", "3h 9m 9s"), + ("mainsail_totals_print_time", "11348.79"), ("mainsail_totals_jobs", "3"), ("mainsail_totals_filament_used", "11.62"), - ("mainsail_longest_print", "3h 9m 9s"), + ("mainsail_longest_print", "11348.79"), ("mainsail_total_layer", "313"), ("mainsail_current_layer", "51"), ("mainsail_toolhead_position_x", "23.3"),