Skip to content

WinNUT shuts down immediately when remaining battery time is "Unavailable", even if remaining time trigger set to 0 #195

Description

@GeraZsolt
  • [X ] Searched to see if this issue exists
  • [X ] Completed below form
  • Attached debug log file
  • Copy output in File -> UPS Variable

**WinNUT Version: **
v2.3.8988

**Windows OS Version: **
Win10 22H2

Describe the bug
My UPS (SPS-MID 1000 OnLine UPS) battery remaining time is unknown on the Synology DS420+ NAS, so the info transmitted to WinNUT Client also can not read the remaining time, so it is "Unavailable", and even if i set the "Shutdown if runtime lower than (sec)" is set to 0 (ZERO) the shutdown starts immediately.
ZERO value should disable the check for remaining battery runtime!

OR

There should be a logical operator to be able to set this one:
"Shutdown if battery lower than x%" OR "Shutdown if runtime lower than (sec)" will be the trigger (whichever comes true first)
or this one:
"Shutdown if battery lower than x%" AND "Shutdown if runtime lower than (sec)" will be the trigger if BOTH of them are true.

ZERO value disables the check for remaining battery percent, or battery remaining time.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'settings / shutdown options'
  2. Set runtime to '0'
  3. Test power outage
  4. Shutdown will be initiated when the UPS runtime is unavailable.

Expected behavior
I expect that WinNUT ignores the unavailable remaining time if i set the trigger to 0 sec. (and also the same for the remaining percent, if a UPS can not communicate this attribute to the SNMP server)

Screenshots

Additional context

Activity

  1. gbakeman commented on Nov 27, 2024

    @gbakeman
    Contributor

    Hi there,

    Sorry for taking awhile to get back to you. I want to say that it was intended for zero values to disable those checks, however I realize now that I may have introduced a slight bug here. WinNUT was designed originally such that when a variable was unavailable from the UPS, WinNUT would substitute the variable for a nominal value (so battery voltage would be set to 12V if it was unavailable, for example.) See #116. This probably worked fine in your scenario because the time remaining or percentage values would be nominal, thus effectively disabling those checks. However, I intentionally made it so that unavailable variables were set to out of range values, like 0 or -1. So I see now how this rendered the checks ineffective whenever a variable is missing.

    I'm going to have to think how to approach this one a little bit (and your feedback is always appreciated.) On the one hand, I do want to fix the underlying system of how we handle variables in WinNUT - ideally, if a variable is unavailable, we'd just mark it as such. This could potentially indicate a need for me to accomplish an even greater project in #132 which is to transition the client code in WinNUT to a new library I've been working on. That could take quite a lot of work, however. On the other hand, I also want to overhaul how WinNUT handles events (see #92) and create a user-customizable system so people can create custom event handlers for different events.

    I may have to think about this one for a little. In the meantime, does the Delay to Shutdown option let you at least delay the shutdown?

  2. GeraZsolt commented on Nov 29, 2024

    @GeraZsolt
    Author

    Thank You for the response! :)
    I appreciate the long explaining! :)
    Hope Your plans come true! :)
    You asked about the workaround, and yes, the delay works, and holds back WinNUT from shutdown the PC as soon as the UPS lost power from the wall.
    Have a great winter and coding! :)

    Zsolt

  3. SebastianOehm commented on Oct 19, 2025

    @SebastianOehm
    Contributor

    @gbakeman This is still having the same behaviour even after almost a year. But if it is so difficult finding a right approach, why not simply introduce a checkbox to ignore "time available?"

  4. gbakeman commented on Oct 19, 2025

    @gbakeman
    Contributor

    Hi @SebastianOehm,

    Unfortunately a lot of other things have come up, and besides me getting sidetracked on a translation-related project for WinNUT I haven't been dedicating much time to other things that are affecting people so I have to apologize for that.

    Looking back at this bug, I want to say that the simplest method for fixing it would be to modify this part of the code (note to future self) such that, if either of the two variables is set to -1 (indicating unavailable), WinNUT will not process that specific condition for powering down. Right now, my logic assumes that if one of the variables is unavailable, then both must be - which was obviously a faulty assumption.

    I can't make any promises, but I do want to fix this bug at some point. Please stay tuned for more info!

  5. SebastianOehm commented on Oct 19, 2025

    @SebastianOehm
    Contributor

    @gbakeman I have made a surgical fix for this issue, please view my PR at #217

    It targets only one line, making it that battery time left must not only be lower than specified floor but also not -1 (unavailable).

  6. gbakeman commented on Oct 21, 2025

    @gbakeman
    Contributor

    Thanks for your PR @SebastianOehm ! I was getting a few things merged and ready to deploy, when I started running into a mysterious error in our old deployment system (something I've been working on for awhile to replace) so this pre-release could take awhile longer before it arrives.

  7. added this to the 2.3 Stable Release milestone on Nov 2, 2025
  8. gbakeman commented on Nov 2, 2025

    @gbakeman
    Contributor

    Thanks again for your help troubleshooting this issue. A new Pre-Release build is out that I hope fixes this. I'll close this assuming all is well, but please comment back if issues persist.

  9. SebastianOehm commented on Nov 2, 2025

    @SebastianOehm
    Contributor

    tested, confirmed working! @gbakeman

  10. gbakeman commented on Nov 2, 2025

    @gbakeman
    Contributor

    Thanks again 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions