From 096ad5cee5ff186b0979f3c3f9602d35289e505a Mon Sep 17 00:00:00 2001 From: Will Barber Date: Thu, 18 Jul 2024 09:51:50 +0100 Subject: [PATCH] Include run_uuid in state messages Clear run_uuid value before sending NoUSB status --- runusb/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runusb/__main__.py b/runusb/__main__.py index 5cadfbd..8455b89 100755 --- a/runusb/__main__.py +++ b/runusb/__main__.py @@ -175,7 +175,7 @@ def set_status(self, value: LedStatus) -> None: topic_prefix = MQTT_SETTINGS.active_config.topic_prefix mqtt_client.publish( f'{topic_prefix}/state', - json.dumps({"state": value.name}), + json.dumps(dict(state=value.name, **MQTT_SETTINGS.extra_data)), qos=1, retain=True, ) @@ -363,10 +363,10 @@ def cleanup(self) -> None: def close(self) -> None: self.cleanup() + MQTT_SETTINGS.extra_data["run_uuid"] = "" # Reset the run UUID LED_CONTROLLER.set_status(LedStatus.NoUSB) LED_CONTROLLER.set_code(False) USERCODE_LOGGER.removeHandler(self.handler) - MQTT_SETTINGS.extra_data["run_uuid"] = "" # Reset the run UUID MQTT_SETTINGS.active_usercode = None def reset(self) -> None: