diff --git a/.env b/.env index 9585771..2843be9 100644 --- a/.env +++ b/.env @@ -1,8 +1,9 @@ # Lighting Controller Configuration CONTROL_SERVER_URI=ws://localhost:8765 +CONTROL_SERVER_HOST=0.0.0.0 CONTROL_SERVER_PORT=8765 TRANSPORT=spi -AUDIO_INPUT_DEVICE=7 +AUDIO_INPUT_DEVICE=1 MIDI_TCP_HOST=127.0.0.1 MIDI_TCP_PORT=65432 SOUND_CONTROL_HOST=127.0.0.1 diff --git a/.env.example b/.env.example index fd8bdb2..7e82863 100644 --- a/.env.example +++ b/.env.example @@ -15,6 +15,11 @@ CONTROL_SERVER_URI=ws://10.42.0.1:8765 # For custom IP (if your Pi has a different address): # CONTROL_SERVER_URI=ws://YOUR_PI_IP:8765 +# Control server WebSocket host (bind address) +# 0.0.0.0 = listen on all interfaces (allows external connections) +# localhost or 127.0.0.1 = listen only on localhost (local only) +CONTROL_SERVER_HOST=0.0.0.0 + # Control server WebSocket port CONTROL_SERVER_PORT=8765 @@ -29,7 +34,7 @@ TRANSPORT=spi # Sound Detection Configuration # ============================== # Audio input device index (use sound.py to list available devices) -AUDIO_INPUT_DEVICE=7 +AUDIO_INPUT_DEVICE=1 # MIDI TCP configuration MIDI_TCP_HOST=127.0.0.1 diff --git a/src/control_server.py b/src/control_server.py index 4beeb07..b187a69 100644 --- a/src/control_server.py +++ b/src/control_server.py @@ -376,10 +376,11 @@ class ControlServer: async def start_websocket_server(self): """Start WebSocket server for UI clients.""" + host = os.getenv("CONTROL_SERVER_HOST", "0.0.0.0") server = await websockets.serve( - self.handle_ui_client, "localhost", CONTROL_SERVER_PORT + self.handle_ui_client, host, CONTROL_SERVER_PORT ) - logging.info(f"WebSocket server listening on localhost:{CONTROL_SERVER_PORT}") + logging.info(f"WebSocket server listening on {host}:{CONTROL_SERVER_PORT}") async def run(self): """Run the control server."""