networkupstools / nut

The Network UPS Tools repository. UPS management protocol Informational RFC 9271 published by IETF at https://www.rfc-editor.org/info/rfc9271 Please star NUT on GitHub, this helps with sponsorships!
https://networkupstools.org/
Other
2.12k stars 354 forks source link

Added ups.beeper.status support for Masterpower MF-UPS650VA #2661

Open yonesmit opened 1 month ago

yonesmit commented 1 month ago

Hi, Recently I start using a Masterpower MF-UPS650VA with nut. The device is detected correctly, it uses usbhid-ups driver and MGE HID 1.49 subdriver. My problem was I couldn't control the beeper to silence it (ups.beeper.status). After some debugging I found that the feature was found in a different path than the ones that driver support (driver already support the feature in 2 different paths and it uses the first one it founds). Driver support ups.beeper.status in this 2 paths:

UPS.BatterySystem.Battery.AudibleAlarmControl
UPS.PowerSummary.AudibleAlarmControl

And my ups uses this path:

UPS.AudibleAlarmControl

So I added the 3 lines needed to support the beeper status feature in the path used by my ups and compiled the driver.

    { "ups.beeper.status", 0 ,0, "UPS.AudibleAlarmControl", NULL, "%s", HU_FLAG_SEMI_STATIC, beeper_info },
...
    { "beeper.disable", 0, 0, "UPS.AudibleAlarmControl", NULL, "1", HU_TYPE_CMD, NULL },
    { "beeper.enable", 0, 0, "UPS.AudibleAlarmControl", NULL, "2", HU_TYPE_CMD, NULL },

Now the feature is correctly supported.

battery.charge: 100
battery.charge.low: 10
battery.runtime: 7200
battery.type: PbAC
device.mfr: KSTAR
device.model: UPS HID
device.serial: HID-C01
device.type: ups
driver.debug: 0
driver.flag.allow_killpower: 0
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.product: UPS HID
driver.parameter.productid: 0001
driver.parameter.serial: HID-C01
driver.parameter.synchronous: auto
driver.parameter.vendor: KSTAR
driver.parameter.vendorid: 0463
driver.state: quiet
driver.version: 2.8.2.1081-1081-g78e0525d3
driver.version.data: MGE HID 1.49
driver.version.internal: 0.57
driver.version.usb: libusb-1.0.24 (API: 0x1000108)
input.frequency: 49.9
input.voltage: 230.5
outlet.1.status: on
output.voltage: 230.4
ups.beeper.status: disabled
ups.firmware:
ups.load: 8
ups.mfr: KSTAR
ups.model: UPS HID
ups.productid: 0001
ups.serial: HID-C01
ups.status: OL
ups.vendorid: 0463

I'm attaching the file with changes for your reference.

mge-hid.zip

Can the changes be added to project so this ups is supported directly in future releases? Thanks in advance

Best Regards

yonesmit

jimklimov commented 1 month ago

Sounds great, thanks for sharing!

Would you care to post the change as a pull request, so it is attributed in your name in Git history?

yonesmit commented 1 month ago

Sounds great, thanks for sharing!

Would you care to post the change as a pull request, so it is attributed in your name in Git history?

I would but I don't know how to create a git pull request. I'm not sure if I need to create a branch, make changes in it and then submit comparing it with master branch or there is any other easier way. I'm not used to git yet (I've been out of world for last years XD ) Can you add the changes? if not I will try to do as soon as I learn how to do.... TIA best regards,

yonesmit commented 1 month ago

Finally I managed (?) to create the pull request. Tell me if there is something wrong. Sorry this is my fist time. best regards

callegar commented 1 month ago

@yonesmit Nice to see better support for this UPS! Thanks! A quick question: does a manual exist for this thing? I have one and it came with no manual apart from a single page with no useful info.

yonesmit commented 1 month ago

A single manual page, And another page to tell you the download link of kpower. That's all I got. But it was really cheap and works quite well, the only problem I got is I needed to silence it.

jimklimov commented 1 month ago

Thanks, looks good for a first shot! :)

To answer your earlier question, yes it is recommended to make a new branch in your repository for each feature you work on, so you don't have problems e.g. updating to changes from remote master branch as it changes over time while your large pull request awaits a review.