plugins icon indicating copy to clipboard operation
plugins copied to clipboard

sysutils/nut: Added Nut widget

Open jamtur01 opened this issue 1 year ago • 11 comments

This is an (opinionated) widget for the Nut UPS plugin.

Screenshot 2024-09-15 at 1 32 33 PM

This is my first contribution, so I am happy to adjust or get any feedback.

jamtur01 avatar Aug 09 '24 04:08 jamtur01

@Monviech Thanks for your feedback. I'm not primarily a FE person, so it's useful! One issue since replacing the ajaxGet with the function from the Basewidget is that it's not returning any data. I know the UPS diagnostics can be a little slow, but I've tried it with some retries. Is there something obvious I am doing wrong here? I'll poke at it some more when I have a free minute.

jamtur01 avatar Aug 10 '24 19:08 jamtur01

Can you give me the json output of /api/nut/diagnostics/upsstatus then I can test the widget sometime later.

Also how long does the response take, longer than a second?

Cause when its really slow the action that gets the status might need to be cached.

https://github.com/opnsense/core/commit/06d507704ec6e4d97eddde2d5d08c056ec9f41c2

Monviech avatar Aug 10 '24 19:08 Monviech

{"response":"battery.charge: 100\nbattery.charge.low: 10\nbattery.charge.warning: 20\nbattery.mfr.date: CPS\nbattery.runtime: 17475\nbattery.runtime.low: 300\nbattery.type: PbAcid\nbattery.voltage: 26.2\nbattery.voltage.nominal: 24\ndevice.mfr: CPS\ndevice.model: CP1500AVRLCD3\ndevice.serial: BHPNY7002755\ndevice.type: ups\ndriver.debug: 0\ndriver.flag.allow_killpower: 0\ndriver.name: usbhid-ups\ndriver.parameter.pollfreq: 30\ndriver.parameter.pollinterval: 2\ndriver.parameter.port: auto\ndriver.paramer.synchronous: auto\ndriver.state: quiet\ndriver.version: 2.8.2\ndriver.version.data: CyberPower HID 0.80\ndriver.version.internal: 0.53\ndriver.version.usb: libusb-1.0.0 (API: 0x1000102)\ninput.voltage: 121.0\ninput.voltage.nominal: 120\noutput.voltage: 121.0\nups.beeper.status: enabled\nups.delay.shutdown: 20\nups.delay.start: 30\nups.load: 0\nups.mfr: CPS\nups.model: CP1500AVRLCD3\nups.productid: 0601\nups.realpower.nominal: 900\nups.serial: BHPNY7002755\nups.status: OL\nups.test.result: No test initiated\nups.timer.shutdown: -60\nups.timer.start: -60\nups.vendorid: 0764\n\n\n"}

In the Service itself, the Diagnostics data takes 1-2 seconds to return.

jamtur01 avatar Aug 10 '24 19:08 jamtur01

Maybe try to set a cache_ttl here as linked in my prior post. Maybe 30s and see if it gets better. Unsure though.

https://github.com/opnsense/plugins/blob/64a38846959331313ac3b13a8484d267bf177c16/sysutils/nut/src/opnsense/service/conf/actions.d/actions_nut.conf#L25

Monviech avatar Aug 10 '24 19:08 Monviech

Any updates on when this will be merged to production?

Thanks

shomilsaini avatar Sep 13 '24 17:09 shomilsaini

I haven't had a chance to look at this again. I'll try to take a look this w/e.

jamtur01 avatar Sep 13 '24 21:09 jamtur01

@Monviech @fichtner @mimugmail This should now be ready for another review. I refactored it to be more like the other UPS plugin and that resolved the issues.

jamtur01 avatar Sep 14 '24 02:09 jamtur01

And I noticed someone else wrote another plugin. shrugs Choose whichever suits you.

jamtur01 avatar Sep 14 '24 03:09 jamtur01

@mimugmail , @jamtur01 - How do i use this in my opnsense?

shomilsaini avatar Sep 14 '24 16:09 shomilsaini

It would be nice if this calculated the estimated load in watts

wogglenet avatar Sep 14 '24 23:09 wogglenet

calculated the estimated load in watts

Sure. Done.

jamtur01 avatar Sep 15 '24 17:09 jamtur01

After internal discussion we merged #4188 -- it was a fifty fifty but a choice had to be made. Thanks for your contribution in any case. ❤️

fichtner avatar Dec 06 '24 13:12 fichtner