Skip to content

Commit a062fe5

Browse files
committed
fix "devices not support this instance" error message
This was actually harmless, but noisy. The cause was that Govee API returns this error message when trying to list the available scenes for the device. When I started this project the API returned an empty list, but as of a few days ago they made it return an error condition for devices that don't support scenes. We ignore the error and continue, so it didn't harm anything, it was just noisy. refs: #58 refs: #50 refs: #59 refs: #56
1 parent 4179ad0 commit a062fe5

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

src/platform_api.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ impl GoveeApiClient {
147147
&self,
148148
device: &HttpDeviceInfo,
149149
) -> anyhow::Result<Vec<DeviceCapability>> {
150+
if !device.supports_dynamic_scenes() {
151+
return Ok(vec![]);
152+
}
153+
150154
let key = format!("scene-list-diy-{}-{}", device.sku, device.device);
151155
cache_get(
152156
CacheGetOptions {
@@ -181,6 +185,10 @@ impl GoveeApiClient {
181185
&self,
182186
device: &HttpDeviceInfo,
183187
) -> anyhow::Result<Vec<DeviceCapability>> {
188+
if !device.supports_dynamic_scenes() {
189+
return Ok(vec![]);
190+
}
191+
184192
let key = format!("scene-list-{}-{}", device.sku, device.device);
185193
cache_get(
186194
CacheGetOptions {
@@ -635,6 +643,13 @@ impl HttpDeviceInfo {
635643
self.capability_by_instance("brightness").is_some()
636644
}
637645

646+
pub fn supports_dynamic_scenes(&self) -> bool {
647+
self
648+
.capabilities
649+
.iter()
650+
.any(|cap| cap.kind == DeviceCapabilityKind::DynamicScene)
651+
}
652+
638653
/// If supported, returns the number of segments
639654
pub fn supports_segmented_rgb(&self) -> Option<std::ops::Range<u32>> {
640655
let cap = self.capability_by_instance("segmentedColorRgb")?;

src/service/quirks.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub struct Quirk {
1414
pub ble_only: bool,
1515
pub lan_api_capable: bool,
1616
pub device_type: DeviceType,
17-
pub supports_scenes: Option<bool>,
1817
}
1918

2019
impl Quirk {
@@ -29,7 +28,6 @@ impl Quirk {
2928
icon: icon.into(),
3029
lan_api_capable: false,
3130
device_type: DeviceType::Light,
32-
supports_scenes: None,
3331
}
3432
}
3533

@@ -44,15 +42,9 @@ impl Quirk {
4442
icon: "mdi:air-humidifier".into(),
4543
lan_api_capable: false,
4644
device_type: DeviceType::Humidifier,
47-
supports_scenes: None,
4845
}
4946
}
5047

51-
pub fn with_scenes(mut self, supports_scenes: Option<bool>) -> Self {
52-
self.supports_scenes = supports_scenes;
53-
self
54-
}
55-
5648
pub fn with_rgb(mut self) -> Self {
5749
self.supports_rgb = true;
5850
self
@@ -119,7 +111,6 @@ fn load_quirks() -> HashMap<String, Quirk> {
119111
Quirk::humidifier("H7160")
120112
.with_broken_platform()
121113
.with_rgb()
122-
.with_scenes(Some(false))
123114
.with_brightness(),
124115
// Lights from the list of LAN API enabled devices
125116
// at <https://app-h5.govee.com/user-manual/wlan-guide>

src/service/state.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,6 @@ impl State {
488488

489489
pub async fn device_list_scenes(&self, device: &Device) -> anyhow::Result<Vec<String>> {
490490
// TODO: some plumbing to maintain offline scene controls for preferred-LAN control
491-
492-
if let Some(quirk) = device.resolve_quirk() {
493-
if quirk.supports_scenes == Some(false) {
494-
return Ok(vec![]);
495-
}
496-
}
497-
498491
if let Some(client) = self.get_platform_client().await {
499492
if let Some(info) = &device.http_device_info {
500493
return Ok(sort_and_dedup_scenes(client.list_scene_names(info).await?));

0 commit comments

Comments
 (0)