Add complete REST API for lighting control

- Migrated from websockets to aiohttp for unified HTTP/WebSocket server
- Added REST endpoints: /api/pattern, /api/parameters, /api/state, /api/tempo/reset
- Implemented color palette API with 8-slot system and selected colors
- First selected color (index 0) is used as primary RGB for patterns
- All operations now available via simple HTTP requests (no WebSocket needed)
- Added comprehensive documentation: FRONTEND_API.md, COLOR_PALETTE_API.md
- Added test scripts: test_rest_api.sh, test_color_patterns.py
- Updated test/test_control_server.py for new /ws WebSocket path
- Configuration persistence via lighting_config.json
- Pattern parameters (n1-n4, brightness, delay) controllable via API
- WebSocket still available at /ws for legacy support
This commit is contained in:
Pi User
2025-10-03 23:38:54 +13:00
parent aa9f892454
commit 6f9133b43e
19 changed files with 3512 additions and 44 deletions

View File

@@ -82,7 +82,7 @@ async def run_test(uri: str, messages: list[dict], sleep_s: float):
def parse_args():
p = argparse.ArgumentParser(description="Send UI commands to control_server WebSocket")
default_uri = os.getenv("CONTROL_SERVER_URI", "ws://localhost:8765")
default_uri = os.getenv("CONTROL_SERVER_URI", "ws://localhost:8765/ws")
p.add_argument("--uri", default=default_uri, help=f"WebSocket URI (default from .env or {default_uri})")
p.add_argument("--pattern", help="Pattern name for pattern_change")
p.add_argument("--r", type=int, help="Red 0-255 for color_change")