feat: main's import/export, zones, audio API and web UI

Profiles, presets and sequences export and import as main's bundles.
Zones carry group_ids, preset_group_ids, sequence_ids, content_kind and
brightness; profiles seed rainbow as colour_cycle, and deleting a
profile also deletes its sequences. Groups, zones and sequences written
by older versions are migrated at boot.

/api/audio (status, event stream, start/stop, reset, anchor-bar,
devices) maps main's audio detector onto the mic's beat detector. Audio
start/stop picks whether mic beats or the BPM clock time sequences; the
clock's beats also go to the drivers while the mic is off.
/ws now greets from a post-handshake callback (httpd does not call the
handler for the upgrade).

The web UI is main's, plus v2's outputs editor, list search and
hostname/static IP settings; the bridge, Wi-Fi AP and led-tool parts
are gone. API tests follow main's behaviour (119 pass on the board).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-03 20:34:22 +13:00
1 parent 04b56c6ef2
commit bfeeb958df
44 files changed
+8709 -2338

No files matched your search

+2 -65
View File
@@ -1,69 +1,6 @@
"""Groups, sequences, scenes and palettes."""
"""Scenes and palettes."""
from helpers import find_id_by_field, new_id, unique
def test_groups(c):
name = unique("pytest-group")
assert c.post("/groups", json={"name": name}).status_code == 201
gid = find_id_by_field(c.get("/groups").json(), "name", name)
resp = c.get(f"/groups/{gid}")
assert resp.status_code == 200
assert resp.json()["name"] == name
resp = c.put(f"/groups/{gid}", json={"brightness": 10})
assert resp.status_code == 200
assert resp.json()["brightness"] == 10
assert c.delete(f"/groups/{gid}").status_code == 200
def test_sequences_crud(c):
name = unique("pytest-seq")
resp = c.post("/sequences", json={"name": name, "steps": [{"preset_id": "1", "duration_s": 2}]})
assert resp.status_code == 201
sid = find_id_by_field(c.get("/sequences").json(), "name", name)
resp = c.get(f"/sequences/{sid}")
assert resp.status_code == 200
assert resp.json()["steps"] == [{"preset_id": "1", "duration_s": 2.0}]
resp = c.put(f"/sequences/{sid}", json={"loop": False, "repeat_count": 2})
assert resp.status_code == 200
assert resp.json()["loop"] is False and resp.json()["repeat_count"] == 2
assert c.get("/sequences/status").status_code == 200
assert c.delete(f"/sequences/{sid}").status_code == 200
def test_sequence_step_needs_preset(c):
sid = new_id(c.post("/sequences", json={"name": unique("pytest-seq"), "steps": []}))
assert c.put(f"/sequences/{sid}", json={"steps": [{"duration_s": 1}]}).status_code == 400
c.delete(f"/sequences/{sid}")
def test_sequence_without_zone_cannot_play(c):
sid = new_id(c.post("/sequences", json={"name": unique("pytest-seq"),
"steps": [{"preset_id": "1", "duration_s": 1}]}))
assert c.post(f"/sequences/{sid}/play").status_code == 400
c.delete(f"/sequences/{sid}")
def test_sequence_play_and_stop(c):
profile = new_id(c.post("/profiles", json={"name": unique("pytest-engine")}))
c.post(f"/profiles/{profile}/apply")
preset = new_id(c.post("/presets", json={"name": "pytest-on", "pattern": "on", "colors": ["#ff0000"]}))
zone = new_id(c.post("/zones", json={"name": "pytest-engine-zone", "names": ["pytest-nobody"]}))
c.post("/sequences", json={"name": "pytest-engine-seq", "zone_id": zone, "loop": False,
"steps": [{"preset_id": preset, "duration_s": 0.5}]})
sid = find_id_by_field(c.get("/sequences").json(), "name", "pytest-engine-seq")
resp = c.post(f"/sequences/{sid}/play")
assert resp.status_code == 200
assert resp.json()["zone_id"] == zone
assert c.get(f"/sequences/{sid}").json()["active"] is True
resp = c.post(f"/sequences/{sid}/stop")
assert resp.json()["stopped"] is True
assert c.get(f"/sequences/{sid}").json()["active"] is False
c.delete(f"/sequences/{sid}")
c.delete(f"/zones/{zone}")
c.delete(f"/profiles/{profile}")
from helpers import find_id_by_field, unique
def test_scenes(c):