[DRIVER] NUT Discovery + UPS & Outlet Status

The latest changes have my UPS all reporting properly.

@jtmpush18 the purpose of this is to not only keep the systems online but also to notify and take action via your smart home that the power is out. For example, I will send a push notification that the power is out and subsequent notifications about the % of battery remaining in a given UPS and I'll know based on the battery powered water sensors if my backup sump pump is working properly. In the winter I'll know just how cold the house is getting without power, etc. This information will help me determine if I need to either go home if I'm nerby or have someone go over if I'm not (disasters strike at the worst times!) and turn on / cut over to generator power.

@ChrisUthe here's an other related topic in case you're interested...

@Guyeeba I think adding powersource as a trigger option is ideal but I'll probably add code to flip a virtual switch on/off depending on power source, and work off that for now, I may also have it change the mode to "power outage" or something that lets me trigger otherwise spammy messages ("When in this mode send a text every X minutes with battery % etc). I think all those items can be accomplished with RM when powersource is added or temporarily via the virtual switch for now.

would this allow me to safely shutdown hubitat if my UPS was low on battery? My Synology does this and it would be great with Hubitat as well.

not in its current iteration, no, it's more geared toward doing things in response to the power being out, not self preservation of the hub. I'm not sure if shutting down is an option from an app tbh...

Someone like @bravenel might know: Can an application initiate a hub shutdown?

If it sends a POST to the right endpoint (/hub/shutdown), then yes. But not if security is enabled.

Thank you for the info @bravenel, appreciate it.

So @jasonbalsor you could have this shut down the hub automatically if you're willing to not have the security (user login) setup.

1 Like

I am having an issue connecting ang getting status. I am using a raspberry Pi for my nut server. It appears to be running. I see that the parent is using telnet to connect. I have yet to get status in the device. More than likely the Pi is refusing the connection because telnet wants a user/password to allow the connect? I can use Putty to connect either through ssh or telnet, using u/p.

I think this is a great idea!
Thanks

For the record the nut server I'm connecting to (running on a synology) acted like it was timing out until I didn't put a username/password in. You might try it with those blank.

Once it said it was getting ups names now just waiting for events. It should be giving me the status and other info correct?

That is without a usernamd and password

What a difference the night makes. My impatience to see the UPS found in HE was rewarded this morning! Thank you so much for this effort!!

A couple of questions:

  1. There are some attributes from NUT that aren't passed to the Child. Here is what I get from running NUT
    battery.charge: 100
    battery.charge.low: 10
    battery.charge.warning: 50
    battery.date: 2001/09/25
    battery.mfr.date: 2012/04/02
    battery.runtime: 36000
    battery.runtime.low: 120
    battery.type: PbAc
    battery.voltage: 13.7
    battery.voltage.nominal: 12.0
    device.mfr: American Power Conversion
    device.model: Back-UPS ES 750G
    device.serial: 3B1214X00646
    device.type: ups
    driver.name: usbhid-ups
    driver.parameter.pollfreq: 30
    driver.parameter.pollinterval: 2
    driver.parameter.port: auto
    driver.parameter.synchronous: no
    driver.version: 2.7.4
    driver.version.data: APC HID 0.96
    driver.version.internal: 0.41
    input.sensitivity: high
    input.transfer.high: 136
    input.transfer.low: 96
    input.transfer.reason: input voltage out of range
    input.voltage: 124.0
    input.voltage.nominal: 120
    ups.beeper.status: enabled
    ups.delay.shutdown: 20
    ups.firmware: 841.I4 .D
    ups.firmware.aux: I4
    ups.load: 0
    ups.mfr: American Power Conversion
    ups.mfr.date: 2012/04/02
    ups.model: Back-UPS ES 750G
    ups.productid: 0002
    ups.realpower.nominal: 450
    ups.serial: 3B1214X00646
    ups.status: OL
    ups.test.result: No test initiated
    ups.timer.reboot: 0
    ups.timer.shutdown: -1
    ups.vendorid: 051d
    For Instance if I wanted to add battery voltage and UPS real Power nominal Where would I do that? And the other thing that comes to mind is the Status message for instance: OnLine and mains to indicate that the UPS is online and that it is powered by the mains.

Don't know if this can happen or not. I tried to setup a RM notification for when it switches to battery, but there is nothing to work with in RM for the UPS Child.

Anyway thanks so much for sharing, My opinion this is a great idea!!

Open live logs, and turn on debugging on the Child UPS device, you'll see any variables that the driver doesn't display scroll by. The request gets everything then uses a series of case statements to display the relevant/useful ones.

@guyeeba or myself or you could easily add others, but it does run into a bit of an issue in general:

Different UPS's put out different parameters, so we'd likely need to create different sets of support variables per device mfr/model combos.

If you want to add a few specific ones look in the child driver for the case statements (it takes the variables and breaks them up using period as the breakpoint, so it flips through all the battery variables, then all the device variables etc). Just follow the pattern and add an attribute and set it within the loops.

I'll probably add battery.voltage and ups.realpower.nominal too, as they seem to generally be available for most UPS's based on a quick search. I think the nominal real power would be useful as HE supports doing a few things with power readings.

As for the RM, that's something that we need to add something addition for as Hubitat can't yet use any of the parameters that are defined as triggers for rules. They have stated that adding "powersource" is on the to do list, but there are a few easy work arounds I should be able to get in this weekend so you can have rules triggered when the power goes out (which was my ultimate goal).

We should also create a little how to, @guyeeba's method of auto-adding is slick but doesn't tell you that it added UPS's as children to go look at, which sounds like caught you up for a bit.

Thanks Chris

I figured that there would be some "missing" stats people would want. Its not like there are only a couple of UP manufacturers out there. Anyway I was gifted this one and I am not going to look that horse in the mouth. I will look at the Child driver to see what I can do. Yeah the RM notification was / is a goal for me as well. Knowing when all my stuff is without power is some good info.

Looking at the live logs I see that my telnet session is not connecting. In fact th eChild isn't listed in live logging. Do I need to figure out how to have the Pi allow a non-authenticated telnet session? The Parent askes for the NUT user/password but nothing for the telnet session itself.

Thanks alot!

I just uploaded a version that supports batteryVoltage. And moved inputVoltage to voltage, so now it properly implements the VoltageMeasurement capability...

2 Likes

In fact it's not a telnet connection t your raspi, just a TCP socket to NUT's port. Can you open the NUT port (3493 by default) on your raspi with telnet/putty?

Using putty /telnet on port 3493 I get an "error command unknown" I am assuming that means it is open ?

After some fiddling around and leaving the user/password blank in the parent setup, I am now getting info in the live log and the dashboard is updating.
Thanks guys for all your help. I might tweek the info for my UPS.

I just uploaded a new version that authenticates properly to NUT... 10 hours late... :slight_smile:

:smiley::smiley::smiley::smiley: