Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks
GeraZsolt opened this issue Nov 21, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@GeraZsolt
Copy link

  • [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

@GeraZsolt GeraZsolt added the bug Something isn't working label Nov 21, 2024
@gbakeman
Copy link
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?

@GeraZsolt
Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants