From 7e2df9170279267e4621142e7ff63eca446fa78f Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Tue, 13 Jan 2026 23:24:30 +0100 Subject: [PATCH] Fix battery warnings on unsupported devices Fix #644, break early if battery is unsupported. --- daemon/src/battery/mod.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/daemon/src/battery/mod.rs b/daemon/src/battery/mod.rs index 1f001ea..e8e2cb7 100644 --- a/daemon/src/battery/mod.rs +++ b/daemon/src/battery/mod.rs @@ -1,6 +1,6 @@ use std::{path::Path, time::Duration}; -use log::{error, info}; +use log::{info, warn}; use rayhunter::Device; use serde::Serialize; use tokio::select; @@ -66,11 +66,11 @@ pub fn run_battery_notification_worker( // Don't send a notification initially if the device starts at a low battery level. let mut triggered = match get_battery_status(&device).await { Err(RayhunterError::FunctionNotSupportedForDeviceError) => { - info!("Battery level function not supported for device"); - false + info!("Battery status not supported for this device, disabling battery notifications"); + return; } Err(e) => { - error!("Failed to get battery status: {e}"); + warn!("Failed to get battery status: {e}"); true } Ok(status) => status.level <= LOW_BATTERY_LEVEL, @@ -83,8 +83,12 @@ pub fn run_battery_notification_worker( } let status = match get_battery_status(&device).await { + Err(RayhunterError::FunctionNotSupportedForDeviceError) => { + info!("Battery status not supported for this device, disabling battery notifications"); + break; + } Err(e) => { - error!("Failed to get battery status: {e}"); + warn!("Failed to get battery status: {e}"); continue; } Ok(status) => status,