From f7efe81f19cd2e7eaa8343f11aacfbb26cc9e1ce Mon Sep 17 00:00:00 2001 From: Sebastian Oehm Date: Sun, 19 Oct 2025 19:21:37 +0200 Subject: [PATCH 1/2] Fix: ensuring that battery runtime, when not available, will not be used as a shutdown condition. Making sure when runtime is not available shutdown will not start immediately regardless of specified percentage See: https://github.com/nutdotnet/WinNUT-Client/issues/195 --- WinNUT_V2/WinNUT-Client/WinNUT.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WinNUT_V2/WinNUT-Client/WinNUT.vb b/WinNUT_V2/WinNUT-Client/WinNUT.vb index 11f3de6..3df4777 100644 --- a/WinNUT_V2/WinNUT-Client/WinNUT.vb +++ b/WinNUT_V2/WinNUT-Client/WinNUT.vb @@ -642,7 +642,7 @@ Public Class WinNUT LogFile.LogTracing("Battery properties unavailable, unable to validate shutdown conditions.", LogLvl.LOG_WARNING, Me) ElseIf Not ShutdownStatus Then If .Batt_Charge <= My.Settings.PW_BattChrgFloor Or - .Batt_Runtime <= My.Settings.PW_RuntimeFloor Then + (.Batt_Runtime <> -1 AndAlso .Batt_Runtime <= My.Settings.PW_RuntimeFloor) Then LogFile.LogTracing("UPS battery has dropped below stop condition limits.", LogLvl.LOG_NOTICE, Me, StrLog.Item(AppResxStr.STR_LOG_SHUT_START)) Shutdown_Event() From b9cd3fcde06749a7d86a7d5021f18afc202fe12b Mon Sep 17 00:00:00 2001 From: Sebastian Oehm Date: Sun, 19 Oct 2025 22:00:03 +0200 Subject: [PATCH 2/2] Ensure that Battery charge may not be used as a shutdown trigger when its value is -1 (indicating its unavailable). --- WinNUT_V2/WinNUT-Client/WinNUT.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WinNUT_V2/WinNUT-Client/WinNUT.vb b/WinNUT_V2/WinNUT-Client/WinNUT.vb index 3df4777..bdd1e55 100644 --- a/WinNUT_V2/WinNUT-Client/WinNUT.vb +++ b/WinNUT_V2/WinNUT-Client/WinNUT.vb @@ -641,7 +641,7 @@ Public Class WinNUT If .Batt_Charge = -1 AndAlso .Batt_Runtime = -1 Then LogFile.LogTracing("Battery properties unavailable, unable to validate shutdown conditions.", LogLvl.LOG_WARNING, Me) ElseIf Not ShutdownStatus Then - If .Batt_Charge <= My.Settings.PW_BattChrgFloor Or + If (.Batt_Charge <> -1 AndAlso .Batt_Charge <= My.Settings.PW_BattChrgFloor) Or (.Batt_Runtime <> -1 AndAlso .Batt_Runtime <= My.Settings.PW_RuntimeFloor) Then LogFile.LogTracing("UPS battery has dropped below stop condition limits.", LogLvl.LOG_NOTICE, Me, StrLog.Item(AppResxStr.STR_LOG_SHUT_START))