feat(snapshot): include scene playlists + cycling state in snapshot
The aggregated /api/v1/snapshot poll now emits a `scene_playlists` section (each playlist with its `is_running` flag) plus a companion `playlist_state` key carrying the single global cycling state (running playlist, current index/ preset, dwell) — so the HA-coordinator and other low-overhead pollers get playlist state in the same round trip as scenes/targets, matching the other entity sections. Gated by the `scene_playlists` include-section like the rest. Reuses the existing list_scene_playlists handler; snapshot route tests updated.
This commit is contained in:
@@ -33,6 +33,8 @@ _TOP_LEVEL_KEYS = (
|
||||
"css_sources",
|
||||
"value_sources",
|
||||
"scene_presets",
|
||||
"scene_playlists",
|
||||
"playlist_state",
|
||||
"sync_clocks",
|
||||
"system",
|
||||
)
|
||||
@@ -56,6 +58,21 @@ def client(test_config, monkeypatch):
|
||||
value_store.get_all_sources.return_value = []
|
||||
preset_store = MagicMock()
|
||||
preset_store.get_all_presets.return_value = []
|
||||
playlist_store = MagicMock()
|
||||
playlist_store.get_all_playlists.return_value = []
|
||||
playlist_engine = MagicMock()
|
||||
playlist_engine.get_running_playlist_id.return_value = None
|
||||
playlist_engine.get_state.return_value = {
|
||||
"is_running": False,
|
||||
"playlist_id": None,
|
||||
"playlist_name": None,
|
||||
"current_index": 0,
|
||||
"item_count": 0,
|
||||
"current_preset_id": None,
|
||||
"started_at": None,
|
||||
"step_started_at": None,
|
||||
"step_duration": 0.0,
|
||||
}
|
||||
clock_store = MagicMock()
|
||||
clock_store.get_all_clocks.return_value = []
|
||||
clock_manager = MagicMock()
|
||||
@@ -74,6 +91,8 @@ def client(test_config, monkeypatch):
|
||||
app.dependency_overrides[deps.get_color_strip_store] = lambda: css_store
|
||||
app.dependency_overrides[deps.get_value_source_store] = lambda: value_store
|
||||
app.dependency_overrides[deps.get_scene_preset_store] = lambda: preset_store
|
||||
app.dependency_overrides[deps.get_scene_playlist_store] = lambda: playlist_store
|
||||
app.dependency_overrides[deps.get_playlist_engine] = lambda: playlist_engine
|
||||
app.dependency_overrides[deps.get_sync_clock_store] = lambda: clock_store
|
||||
app.dependency_overrides[deps.get_sync_clock_manager] = lambda: clock_manager
|
||||
app.dependency_overrides[deps.get_processor_manager] = lambda: manager
|
||||
@@ -97,12 +116,16 @@ def test_snapshot_returns_all_sections(client):
|
||||
"css_sources",
|
||||
"value_sources",
|
||||
"scene_presets",
|
||||
"scene_playlists",
|
||||
"sync_clocks",
|
||||
):
|
||||
assert data[list_key] == []
|
||||
for dict_key in ("target_states", "target_metrics", "device_brightness"):
|
||||
assert data[dict_key] == {}
|
||||
|
||||
# The single global cycling state rides along with the playlist list.
|
||||
assert data["playlist_state"]["is_running"] is False
|
||||
|
||||
|
||||
def test_snapshot_system_block_has_health_version(client):
|
||||
data = client.get("/api/v1/snapshot", headers=_AUTH).json()
|
||||
|
||||
Reference in New Issue
Block a user