From 588ee30180e34dc45f740d6187826e5bd46b6c94 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 2 Jan 2025 11:44:43 -0700 Subject: [PATCH] Revert "prefer to use LAN API to apply light scenes" This reverts commit c0545a87111a08465fd8fb9e717e5fff868a4b33; we'll revisit this after a bit more investigation. refs: https://github.com/wez/govee2mqtt/issues/354 refs: https://github.com/wez/govee2mqtt/issues/353 --- src/service/state.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/service/state.rs b/src/service/state.rs index 10bb4fc..fc8f666 100644 --- a/src/service/state.rs +++ b/src/service/state.rs @@ -639,21 +639,6 @@ impl State { device: &Device, scene: &str, ) -> anyhow::Result<()> { - if let Some(lan_dev) = &device.lan_device { - log::info!("Using LAN API to set {device} to scene {scene}"); - match lan_dev.set_scene_by_name(scene).await { - Ok(_) => { - self.device_mut(&device.sku, &device.id) - .await - .set_active_scene(Some(scene)); - return Ok(()); - } - Err(err) => { - log::error!("Error using LAN API to set {device} to scene {scene}: {err:#}. Maybe fallback to platform API"); - } - } - } - // TODO: some plumbing to maintain offline scene controls for preferred-LAN control let avoid_platform_api = device.avoid_platform_api(); @@ -670,6 +655,16 @@ impl State { } } + if let Some(lan_dev) = &device.lan_device { + log::info!("Using LAN API to set {device} to scene {scene}"); + lan_dev.set_scene_by_name(scene).await?; + + self.device_mut(&device.sku, &device.id) + .await + .set_active_scene(Some(scene)); + return Ok(()); + } + anyhow::bail!("Unable to set scene for {device}"); }