From 3d827d7513946c06680d69b910c3c8777584cad0 Mon Sep 17 00:00:00 2001 From: Arksine Date: Wed, 11 Nov 2020 17:10:13 -0500 Subject: [PATCH] websockets: Add "notify_klippy_ready" notification GIven that subscriptions are reset, connected clients no longer maintained and they cannot check "webhooks.state" to see if Klippy is ready. This notifcation may be used to in its place. SIgned-off-by: Eric Callahan --- moonraker/websockets.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/moonraker/websockets.py b/moonraker/websockets.py index 3f88c91..aa4740f 100644 --- a/moonraker/websockets.py +++ b/moonraker/websockets.py @@ -170,6 +170,8 @@ class WebsocketManager: self.rpc.register_method("server.websocket.id", self._handle_id_request) # Register events + self.server.register_event_handler( + "server:klippy_ready", self._handle_klippy_ready) self.server.register_event_handler( "server:klippy_disconnect", self._handle_klippy_disconnect) self.server.register_event_handler( @@ -181,6 +183,9 @@ class WebsocketManager: self.server.register_event_handler( "gpio_power:power_changed", self._handle_power_changed) + async def _handle_klippy_ready(self): + await self.notify_websockets("klippy_ready") + async def _handle_klippy_disconnect(self): await self.notify_websockets("klippy_disconnected")