Skip to content

Commit

Permalink
use light effect catalog to get device scenes for lan control
Browse files Browse the repository at this point in the history
We default to querying the list of scene effects from the platform
API, but if you are running without the platform API credentials
(eg: want to run in LAN only mode) then we'd punt on getting
the list of scenes, even though we do actually have a way to
obtain that information to pave over gaps in the Govee API.

This commit adds a fallback to querying that light effect
catalog.

refs: #349
  • Loading branch information
wez committed Dec 31, 2024
1 parent 2392986 commit 1d9c8be
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/service/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,21 @@ impl State {
}
}

if let Ok(categories) = GoveeUndocumentedApi::get_scenes_for_device(&device.sku).await {
let mut names = vec![];
for cat in categories {
for scene in cat.scenes {
for effect in scene.light_effects {
if effect.scene_code != 0 {
names.push(scene.scene_name);
break;
}
}
}
}
return Ok(sort_and_dedup_scenes(names));
}

log::trace!("Platform API unavailable: Don't know how to list scenes for {device}");

Ok(vec![])
Expand Down

0 comments on commit 1d9c8be

Please sign in to comment.