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

Stop substituting default/fallback values for UPS variables #116

Open
2 tasks
gbakeman opened this issue Nov 4, 2023 · 0 comments
Open
2 tasks

Stop substituting default/fallback values for UPS variables #116

gbakeman opened this issue Nov 4, 2023 · 0 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@gbakeman
Copy link
Contributor

gbakeman commented Nov 4, 2023

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 battery.voltage
    image

  • UPS data retrieval subroutine

    With UPS_Datas.UPS_Value
    .Batt_Charge = Double.Parse(GetUPSVar("battery.charge", 255), ciClone)
    .Batt_Voltage = Double.Parse(GetUPSVar("battery.voltage", 12), ciClone)
    .Batt_Runtime = Double.Parse(GetUPSVar("battery.runtime", 86400), ciClone)

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

@gbakeman gbakeman added bug Something isn't working enhancement New feature or request labels Nov 4, 2023
@gbakeman gbakeman added this to the 2.3 Stable Release milestone Nov 4, 2023
@gbakeman gbakeman self-assigned this Nov 4, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant