[Now with code for Nut discovery + UPS & outlet status] Support for UPS?

EDIT: Moved this to Get Started | Code Share as @guyeeba has added a set of drivers to discover and expose UPS's and their outlets if supported.

GitHub: Hubitat/Drivers at master · guyeeba/Hubitat · GitHub
Add all 3 to the system, configure a new virtual device of the "Nut UPS Driver" type and it will auto-populate child objects.


Original Post:

Hi all, doesn't appear Hubitat has support for UPS control. I've got my hubitat and a few other network devices away from my primary networking area and on it's own UPS. I guess part of the cool part of Hubitat for me is that it would keep working without internet, and even in some cases (door locks, sensors) without power (assuming hubitat and my network are on batteries). Any chance anyone else needs a NUT like package for UPS sensing and control? I'd like to keep track of battery % and do things on power outage/restore.

2 Likes

This would be a great feature, especially to make sure the hub properly shuts down. My NAS broadcasts that it’s on UPS. Unfortunately no confirmation that HE staff are considering this feature request.

Hi, in case your issue is still unresolved, I started to make a UPS driver that works via NUT.

It's still in beta... cough... pre-alpha stage, but in my very specific case it's working quite well. :slight_smile:

Available here if you're interested...

3 Likes

My UPS is hooked up to my NAS which can then broadcast to a list of IPs. Does your driver support that scenario and listen for the broadcast?

No, it connects to your NUT server using a TCP socket, collects the necessary info, builds the device tree (Server -> UPSes -> Outlets), and then starts polling the server periodically. I think it can coexist with your current solution, but the source code is there, I tried to keep the structure as simple as possible, so you can easily tailor it to your needs...

1 Like

Hey @guyeeba I took a peak at your drivers, they look good, interesting strategy auto-creating UPS's, I think it's cool and picked up my UPS from my NAS.

Couple suggestions:

  • You're switching on a parsed list of the items returned to break out different areas, which I think is a good idea, but you're not accounting for the third level. For instance, my battery and battery runtime are incorrect because your code isn't recognizing that there may be sub-children of battery.charge and battery.runtime, and my UPS has those:

image

This means that my "battery" state get set to charge (proper), charge.low and then charge.warning in quick succession, same thing with my runtime and runtime.low.

  • You're logging all the variables you'd don't recognize with log.error, generally I assume there will be some differences from UPS model to UPS model, and it's likely better to log those as something else and only if logging is enabled.

Nice work!! I'm definitely going to integrate it into my setup and get some rules and notifications around it. Props to picking up a need and putting something back out there there into the community.

1 Like

@guyeeba I made a pull request but github attempted to change the encoding on the file hosing your name, apologies, but the pull simply puts the unkown parameters when parsing a device into the optional debug log.

Thanks for the suggestions!

I realized those weaknesses as well, but.. you know... this DTH wasn't meant for the public, and... once it started to work for my setup, I lost interest in fixing those glitches... but you're right, now that it's in the wild, I should fix them asap... and I will remove the accents from my name as well :smiley:

1 Like

That's the upside of the community, no need to take the burden on yourself alone.

Damn, I have issues with github as well... whatever, thanks for the pull request! In the meantime I managed to commit a change to fix the first issue you mentioned... could you please check if it works for you?

A simple set of questions:
I have my Hubitat (and router, modem, NAS, etc.) on a APC UPS.
It's been useful, when I've had to turn off the power.
Why do I need any special software?

I think the answer is in the opening post...

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

Download the Hubitat app