From b42f0a67f2283e29e2bbf2f5dc95c1bb4aa1ce62 Mon Sep 17 00:00:00 2001 From: Jeff Koenig Date: Tue, 19 Sep 2023 22:25:04 -0400 Subject: [PATCH] feat: add speed factor sensor --- custom_components/moonraker/sensor.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/custom_components/moonraker/sensor.py b/custom_components/moonraker/sensor.py index 132f47d..5aec860 100755 --- a/custom_components/moonraker/sensor.py +++ b/custom_components/moonraker/sensor.py @@ -395,6 +395,18 @@ async def async_setup_optional_sensors(coordinator, entry, async_add_entities): unit=PERCENTAGE, ) sensors.append(desc) + elif obj == "gcode_move": + desc = MoonrakerSensorDescription( + key="speed_factor", + name="Speed factor", + value_fn=lambda sensor: round( + sensor.coordinator.data["status"]["gcode_move"]["speed_factor"] * 100, 2 + ), + subscriptions=[("gcode_move", "speed_factor")], + icon="mdi:speedometer", + unit=PERCENTAGE, + ) + sensors.append(desc) coordinator.load_sensor_data(sensors) await coordinator.async_refresh()