Fix: jsonrpc endpoint for slimproto devices
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 24 Feb 2025 13:14:41 +0000 (14:14 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 24 Feb 2025 13:14:41 +0000 (14:14 +0100)
music_assistant/providers/slimproto/__init__.py

index 3818bc011f4832145893fbbd4bf57bc1b2a7e7bf..b44a5bfebad4a0bb744d092352cf4e9f1cca3520 100644 (file)
@@ -265,10 +265,18 @@ class SlimprotoProvider(PlayerProvider):
         self.mass.streams.register_dynamic_route(
             "/slimproto/multi", self._serve_multi_client_stream
         )
+        # it seems that WiiM devices do not use the json rpc port that is broadcasted
+        # in the discovery info but instead they just assume that the jsonrpc endpoint
+        # lives on the same server as stream URL. So we need to provide a jsonrpc.js
+        # endpoint that just redirects to the jsonrpc handler within the slimproto package.
+        self.mass.streams.register_dynamic_route(
+            "/jsonrpc.js", self.slimproto.cli._handle_jsonrpc_client
+        )
 
     async def unload(self, is_removed: bool = False) -> None:
         """Handle close/cleanup of the provider."""
         self.mass.streams.unregister_dynamic_route("/slimproto/multi")
+        self.mass.streams.unregister_dynamic_route("/jsonrpc.js")
         await self.slimproto.stop()
 
     async def get_player_config_entries(self, player_id: str) -> tuple[ConfigEntry]: