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

Huawei UPS missing load display #150

Closed
gbakeman opened this issue Apr 28, 2024 · 9 comments · Fixed by #151
Closed

Huawei UPS missing load display #150

gbakeman opened this issue Apr 28, 2024 · 9 comments · Fixed by #151
Assignees
Labels
bug Something isn't working

Comments

@gbakeman
Copy link
Contributor

gbakeman commented Apr 28, 2024

@MaxMadcc (Link)

I took a look at the NUT (Network UPS Tools) driver source code.

https://github.com/networkupstools/nut/blob/9e029270d7914df27c9743c95aad219d7ea2e32e/drivers/huawei-ups2000.c#L552 https://github.com/networkupstools/nut/blob/9e029270d7914df27c9743c95aad219d7ea2e32e/drivers/huawei-ups2000.c#L553

.power is apparent power. .realpower is active power.

So .realpower is actually the amount of power my UPS is consuming.

UPS variables
battery.capacity (Battery capacity (Ah)) : 9
battery.charge (Battery charge (percent of full)) : 100.0
battery.charger.status (Battery charger status) : charging
battery.packs (Number of battery packs) : 4
battery.runtime (Battery runtime (seconds)) : 2418
battery.voltage (Battery voltage (V)) : 54.4
device.mfr (Description unavailable) : Huawei
device.model (Description unavailable) : UPS2000A
device.serial (Description unavailable) : 2102290503HGJ7000056
device.type (Description unavailable) : ups
driver.debug (Current debug verbosity level of the driver program) : 1
driver.flag.allow_killpower (Safety flip-switch to allow the driver daemon to send UPS shutdown command (accessible via driver.killpower)) : 0
driver.name (Driver name) : huawei-ups2000
driver.parameter.pollinterval (Description unavailable) : 3
driver.parameter.port (Description unavailable) : /dev/ttySVA100
driver.parameter.synchronous (Description unavailable) : no
driver.state (Description unavailable) : updateinfo
driver.version (Driver version - NUT release) : 2.8.1
driver.version.internal (Internal driver version) : 0.05
input.bypass.frequency (Description unavailable) : 50.0
input.bypass.voltage (Description unavailable) : 232.6
input.frequency (Input line frequency (Hz)) : 50.0
input.voltage (Input voltage (V)) : 232.6
output.current (Output current (A)) : 1.7
output.frequency (Output frequency (Hz)) : 50.0
output.power (Description unavailable) : 300.0
output.realpower (Description unavailable) : 200.0
output.voltage (Output voltage (V)) : 219.5
ups.beeper.status (UPS beeper status) : enabled
ups.delay.reboot (Interval to wait before rebooting the UPS (seconds)) : 60
ups.delay.shutdown (Interval to wait after shutdown with delay command (seconds)) : 60
ups.delay.start (Interval to wait before (re)starting the load (seconds)) : 60
ups.firmware (UPS firmware) : V2R1C1SPC40
ups.firmware.aux (Auxiliary device firmware) : P1.0-D1.0
ups.load (Load on UPS (percent of full)) : 18.0
ups.mfr (UPS manufacturer) : Huawei
ups.model (UPS model) : UPS2000A
ups.power.nominal (UPS power rating (VA)) : 2000
ups.serial (UPS serial number) : 21
ups.status (UPS status) : OL CHRG
ups.temperature (UPS temperature (degrees C)) : 28.4
ups.timer.reboot (Time before the load will be rebooted (seconds)) : -1
ups.timer.shutdown (Time before the load will be shutdown (seconds)) : -1
ups.timer.start (Time before the load will be started (seconds)) : -1
ups.type (UPS type) : online

The output power should be calculated according to the following.
P = I*V
It appears that my UPS variables include output.realpower and output.power, but the the load wattage graph show 0W and percentage of real power.

Log (part)
2024/4/28 23:06:08 [30336, Nut_Socket]: NUT server reports VER: 2.8.1 NETVER: 
2024/4/28 23:06:08 [30336, UPS_Device]: Retrieving basic UPS product information...
2024/4/28 23:06:08 [30336, UPS_Device]: Determining best method to calculate power usage...
2024/4/28 23:06:08 [30336, UPS_Device]: ups.realpower is not supported by server.
2024/4/28 23:06:08 [30336, UPS_Device]: ups.realpower.nominal is not supported by server.
2024/4/28 23:06:08 [30336, UPS_Device]: input.current.nominal is not supported by server.
2024/4/28 23:06:08 [30336, UPS_Device]: Unable to find a suitable method to calculate power usage.
2024/4/28 23:06:08 [30336, UPS_Device]: output.frequency.nominal is not supported by server.
2024/4/28 23:06:08 [30336, UPS_Device]: Apply Fallback Value when retrieving output.frequency.nominal
2024/4/28 23:06:08 [30336, UPS_Device]: Completed retrieval of basic UPS product information.
2024/4/28 23:06:08 [30336, WinNUT]: Connection to Nut Host Established
2024/4/28 23:06:09 [30336, UPS_Device]: UPS statuses have CHANGED...
2024/4/28 23:06:09 [30336, UPS_Device]: Current statuses: OL,CHRG
2024/4/28 23:06:59 [30336, UPS_Device]: UPS device updating status is now [False]
2024/4/28 23:06:59 [30336, UPS_Device]: UPS device updating status is now [True]
2024/4/28 23:28:29 [30336, UPS_Device]: UPS device updating status is now [False]
2024/4/28 23:28:29 [30336, UPS_Device]: UPS device updating status is now [True]
2024/4/28 23:37:27 [30336, Pref_Gui]: Opened UI window to log location.
2024/4/28 23:37:39 [30336, WinNUT]: Disconnected from Nut Host
2024/4/28 23:37:39 [30336, WinNUT]: Client UPS_Connect subroutine beginning.

Notes

We seem to be missing output.current, output.voltage, and output.realpower for load calculation. output.power doesn't immediately appear to have any utility.

@gbakeman gbakeman added the bug Something isn't working label Apr 28, 2024
@gbakeman gbakeman added this to the 2.3 Stable Release milestone Apr 28, 2024
@gbakeman gbakeman self-assigned this Apr 28, 2024
@gbakeman gbakeman mentioned this issue Apr 28, 2024
@gbakeman
Copy link
Contributor Author

@MaxMadcc I'm noticing that the calculation for power based on current and voltage (219.5*1.7=373.15) is quite a lot different than your output.realpower reading. Can you confirm which if any of the variables/calculations represents the true power draw of your UPS?

@MaxMadcc
Copy link
Contributor

MaxMadcc commented May 4, 2024

According to the official manual and nut huawei-ups2000 driver. I think "output.realpower" is appropriate for reading values.
I think that in certain UPS, "output.realpower" may not be readable, so use P=I * V * 0.8 (note: PF).

@gbakeman
Copy link
Contributor Author

gbakeman commented May 4, 2024

Thank you for finding that information! As I'm understanding it for now, it seems like output.power doesn't really have any use to us so I think I'll ignore that unless you have other ideas.

I'd like to propose a few tests if you wouldn't mind running them for me. I'm going to work on the power calculation method first so it supports your UPS, then I'd like you to give that build a try for me and report how it works. After that, I'll implement the direct reading from output.realpower as that seems to be the most convenient and accurate measurement available to us. Then I'd like you to test that and let me know how it works, then I'll have a pre-release up.

Let me know what you think about this.

gbakeman added a commit that referenced this issue May 4, 2024
- Added output current as new `UPS_Value`
- Renamed a few `PowerMethod` enums to be more descriptive of what they do
- Trying a new well-known variable initialization method that utilizes nullable values. Variable is left null if there's a problem retrieving it from the NUT server, then it will not be updated in the future. Only applying this to `output.current` since its use is limited to power calculation only. Applying this to other variables will likely require greater structural changes throughout WinNUT.
- Added power calculation method involving output voltage and current, doable in a Huawei UPS (see #150)
- GetUPSVar no longer prints a line assuming that the raised exception will go unhandled if a fallback value was not provided.
@gbakeman gbakeman linked a pull request May 4, 2024 that will close this issue
@gbakeman
Copy link
Contributor Author

gbakeman commented May 4, 2024

Just put up a new debug build here, please download and test when convenient. This should cause WinNUT to calculate power based on your UPS's output voltage and current only. More direct variable reading will come in the future.

@gbakeman gbakeman added the question Further information is requested label May 4, 2024
@MaxMadcc
Copy link
Contributor

MaxMadcc commented May 5, 2024

Just put up a new debug build here, please download and test when convenient. This should cause WinNUT to calculate power based on your UPS's output voltage and current only. More direct variable reading will come in the future.

Thanks for your build.

20240505105317
It seems to need round 1 or 2 number to the decimal places.

@gbakeman
Copy link
Contributor Author

gbakeman commented May 5, 2024

🤦

I'll try using NUT/upsd to put up a virtual UPS with your variables next time so I catch simple mistakes like this! I think the extra decimal places fix may be best applied at the gauge its self. I'm tempted to wrap that work into #136, especially since they too are missing the battery.voltage reading.

But in the meantime, I'll work on applying the next sub-feature here which is reading directly from output.realpower. Do you feel the current reading is fairly accurate then? Your realpower last time was ~200W and the power variable was around ~300W, so I wonder if you may have just been using more power when taking this picture.

@gbakeman
Copy link
Contributor Author

gbakeman commented May 6, 2024

I was able to emulate your UPS based on the variables you gave me earlier, so hopefully I catch issues in the future!

image

I'll look into rounding that Load calculation and implement the next step.

@gbakeman
Copy link
Contributor Author

gbakeman commented May 6, 2024

Another build is up now, this time with direct reading of output.realpower as well as correcting the decimal places. Please give it a try and let me know how it goes. I'll take a look at your translation PR then have a pre-release up soon.

@MaxMadcc
Copy link
Contributor

MaxMadcc commented May 6, 2024

Another build is up now, this time with direct reading of output.realpower as well as correcting the decimal places. Please give it a try and let me know how it goes. I'll take a look at your translation PR then have a pre-release up soon.

Thanks for your fix. It seems to be working well.

Low Load.
20240506231723
40% Load.
20240506231908

@gbakeman gbakeman removed the question Further information is requested label May 6, 2024
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

Successfully merging a pull request may close this issue.

2 participants