-
Notifications
You must be signed in to change notification settings - Fork 18
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
Stop substituting default/fallback values for UPS variables #116
Labels
Milestone
Comments
gbakeman
added a commit
that referenced
this issue
Feb 18, 2024
- Battery and voltage properties are now set to an invalid value (-1) when they are unavailable, rather than the previous method of setting them to a "fallback" value. Partially addresses #116 - Attempt to calculate battery charge fails and leaves a log message if the battery voltage is unavailable. - Attempt to calculate battery runtime fails if other consequential values are unavailable. This may be problematic for calculations that rely on a "good enough" default value. However, I currently don't see any scenario where that would be acceptable to someone relying on an accurate calculation. - When UPS status is on battery, log an error if battery variables are unavailable when trying to determine if a stop action is needed. Will need to follow this up and warn the user that stop actions are unavailable if battery info isn't present. - When battery runtime is unavailable to WinNUT, display localized message instead.
This was referenced Feb 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The WinNUT variable update system has a design that causes it to substitute in default/fallback values for when there's an error retrieving a variable. This is a problem because the user may be unaware of when a variable is being substituted, and when it is a true value.
Examples
Missing
![image](https://private-user-images.githubusercontent.com/28630321/308719799-6458cc04-f42d-4e94-8ef8-24818f7434ff.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg4NTMxNDQsIm5iZiI6MTcxODg1Mjg0NCwicGF0aCI6Ii8yODYzMDMyMS8zMDg3MTk3OTktNjQ1OGNjMDQtZjQyZC00ZTk0LThlZjgtMjQ4MThmNzQzNGZmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjIwVDAzMDcyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk4OTEyMjY5Zjc4ZDE1NDhkNGMyYWJhNDdjOTY4MzJhZGNjYmMyMzBhMmZlYWEyNjllOTM2M2E0MjdkZjRkYzMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.9fXn3kifr417Zznqm6x69r-ldq9crqRkX_DBpnvSoso)
battery.voltage
UPS data retrieval subroutine
WinNUT-Client/WinNUT_V2/WinNUT-Client_Common/UPS_Device.vb
Lines 265 to 268 in 1d9fe47
Solution
First, the concept of having fallback values should be removed. When an error is encountered retrieving a variable, that error (exception) should be passed along to the calling method. It will be up to the variables management system to handle errors. Most likely, an error will occur due to a variable not being available on the NUT server. In which case, the variable should be marked so that WinNUT knows how to handle it, and the variable is no longer fetched during periodic update calls.
Items
Related
The text was updated successfully, but these errors were encountered: