Support for PowerSource capability

I created a driver for my UPS (via NUT). It works quite well, and supports the PowerSource capability, ie it sets its powerSource attribute to mains or battery as it should.

It would be nice to use RM to e.g. send a notification, make a HTTP request, or do this and that when power outage is detected. I'm aware of a dozen or more workarounds, but it would be more elegant to access this capability directly from RM...

Any chance?

1 Like

I'm not entirely clear what you are trying to do but one suggestion -

I would think you could use one of the smart outlets that reports voltage, plug it into a non-UPS outlet, and set a rule to send your alerts when the voltage drops to zero. Of course all the other infrastructure to get the alerts through would have to be on UPS . . .

Except smart outlets don't report when they have no power going to them.... :slight_smile: Or are there some that do?

Seems like HE supporting the PowerSource capability [in RM] is the right long term answer.

1 Like

Yeah, that's a workaround, if there's a smart plug with battery backup... :slight_smile:

Btw I have the input voltage exposed, so I could use that value as well, but they're not the same. E.g. when voltage drops below or above a specific level, the UPS switches to battery, even if the input voltage was more than zero. I could make complex rules based on voltage, but I'd leave it to the controller of the UPS, all I need to know if it's on battery.

Details, details. DOH!

I guess you would have to poll to detect an outage . . . not pretty.

You wouldn't have to poll anything. If the driver changes state from Mains to Battery when the ups changes to battery mode, everything you need is done. It's all controlled within the driver. I'm assuming @guyeeba you have NUT (Network UPS Tools in Linux for those that are unfamiliar) you're broadcasting to HE when the switch to Battery is occurring, correct? Or is the driver polling NUT to find the state? Either way, it's all contained within the driver, correct?

I believe what the ask here is if the PowerSource capability can be added to the list of triggers and conditions that are supported by Rule Machine, so that rules and triggers could be build off the reporting of the driver.

You could use WATO to modify a virtual switch based on this. That way, the virtual switch is called Battery and it would be on when the UPS is on battery. Also, if you've gone to the trouble of writing your own driver, you could always just add the switch capability to it and do that all within the driver you already have and save the trouble of having something else modify a virtual switch.

Since the capability is not native to HE (at least I've not seen it) getting it added might be a tall ask. Tagging @bravenel. If anyone can answer it, it would be him. Maybe another idea to throw into the hopper for future releases.

@guyeeba, you mind sharing your driver? I was going to try and use NUT to get my UPS talking to my system this weekend. If you've already got a driver built, that would be a lot of the effort done already.

First of all, the PowerSource capability is supported by HE, or at least the documentation mentions it.

You're right that I could emulate a switch with power source, but I don't like the idea of abstracting things to unrelated virtual devices. It's working, it's just... butt ugly. E.g. abstracting an outlet to a switch (even I do it in my driver) is okay for me, because a switchable outlet is a kind of switch. But power source is not a switch, and creating a virtual switch just to be able to use it in RM - when a perfectly matching capability already exists - is meaningless, and causes confusion.

However, I agree that the UPS device should be a switch, but that switch should control its main output, or even shutdown the whole UPS - it should work in the opposite direction and have a switch-like function. And if the switch capability of my UPS is reserved to an unrelated fuction... should I create one more virtual device? That would defeat the whole one-device-multiple-capabilities logic.

That's why I wrote that I'm aware of numerous workarounds, but why should I use them? There is a pretty straightforward solution, it just simply not implemented everywhere...

Btw. the DTHs are available here.

If you read my whole post I said that was a workaround that would work today and then tagged Bruce who's the guy who wrote RM and is the only one that comment about adding it to RM. Sorry that isn't good enough but that's the best any one but Bruce can do.
Good luck.

Why not create your own small app and use the RM API? You could use it to set a private boolean to true, then chain however many actions you need onto that. Nice and clean, and no abstracted devices.

Its already supported in HE, just not in RM.

PB isn't a trigger. There are tons of workarounds you could use...but the request is for integration as a trigger and condition. So, why doesn't @bravenel answer that so we can put this issue to bed.

PB can be a Trigger Event or a Condition, or a Restriction.

1 Like

The question was about adding the powersource capability to the list of triggers and conditions @bravenel. That's the question that needs answering.

And yes, pb for one rule can be a trigger for another. There are 100's of different workaround to the situation. That wasn't the OPs ask. It's not even my request!! Why is it so hard to get a simple question answered?

Because I'm super busy and don't have time to read all of the posts. What's the question you want answered?

Can the PowerSource capability be added to the list of triggers and conditions in Rule Manager?

It's on the list to do.

4 Likes

Thank you!!!

Thank you guys for the cooperation, mission accomplished! :smiley:

2 Likes

well, @bravenel, it seems something's wrong with it...

The rule can be set up perfectly, but it never gets triggered.

I made 2 rules, one for mains->battery, and one for battery->mains transition, enabled all 3 logging options, and unplugged-replugged my UPS many times (the powerSource attribute of the corresponding device changed accordingly), but nothing happened. Logs are empty. "Run this trigger" buttons sends the message, so the action is working fine.

Here is my rule:

and here are the attributes of my UPS when plugged in:
image

...and when unplugged:
image

Tried deleting/recreating the rules... nothing changed.

Did I miss something?

(v2.1.0.123)

I know that he's going to want to see the events for the rule and/or the device so you might want to grab them now.

okay, thanks! :smiley: