diff --git a/moonraker/components/data_store.py b/moonraker/components/data_store.py index 383f0cf..cee78c6 100644 --- a/moonraker/components/data_store.py +++ b/moonraker/components/data_store.py @@ -50,6 +50,9 @@ class DataStore: "server:gcode_response", self._update_gcode_store) self.server.register_event_handler( "server:klippy_ready", self._init_sensors) + self.server.register_event_handler( + "klippy_connection:gcode_received", self._store_gcode_command + ) # Register endpoints self.server.register_endpoint( @@ -145,7 +148,7 @@ class DataStore: self.gcode_queue.append( {'message': response, 'time': curtime, 'type': "response"}) - def store_gcode_command(self, script: str) -> None: + def _store_gcode_command(self, script: str) -> None: curtime = time.time() for cmd in script.split('\n'): cmd = cmd.strip() diff --git a/moonraker/klippy_connection.py b/moonraker/klippy_connection.py index 5109934..fc72591 100644 --- a/moonraker/klippy_connection.py +++ b/moonraker/klippy_connection.py @@ -30,7 +30,6 @@ from typing import ( if TYPE_CHECKING: from app import MoonrakerApp from websockets import WebRequest, Subscribable - from components.data_store import DataStore from components.klippy_apis import KlippyAPI from components.file_manager.file_manager import FileManager FlexCallback = Callable[..., Optional[Coroutine]] @@ -417,9 +416,9 @@ class KlippyConnection: else: if rpc_method == "gcode/script": script = web_request.get_str('script', "") - data_store: DataStore - data_store = self.server.lookup_component('data_store') - data_store.store_gcode_command(script) + if script: + self.server.send_event( + "klippy_connection:gcode_received", script) return await self._request_standard(web_request) async def _request_subscripton(self,