Shared countdown rule for several devices?

Can anyone confirm I can't do this before I struggle with it...

I have 6 devices that I'd like to turn off 2 hours after being turned on. Ie, these 6 devices are named as triggers to the rule. If I turn on device1 at 2pm, and device2 at 3pm, I'd like device1 to turn off at 4pm and not have its countdown cancelled by device2 turning on.

A workaround I thought of was to launch a custom app with a countdown in it. Can we have multiple instances of one app running without having multiple instances installed? And if I were to manually turn off and on device1, is there a way to find its half-run app and cancel it so I get the full two hours countdown from the new instance?

The simplest way is to make one rule per device. But there is something irritating about that idea lol.

It might be irritating to setup multiple rules, but it may be the simplest way and the easiest to maintain over time. If nothing else, it will be a way to setup what you need now, then improve it over time....

1 Like

In terms of a countdown, pretty sure Bryan has something along these lines, but I think it was more of a dashboard utility than something that may serve this purpose. Still make be worth looking through his catalog...

You're probably right, and it does mean I can temporarily disable individual timers without editing a rule to remove devices from it.

I'd approach it with the view.... Get it working, then let's discuss how to make it better... But I can't offer any advice beyond a simple rule per device...

2 Likes

Thinking about it some more, I expect it would be a simple app (for someone else) to create with a configurable timeout. There is a timeout on one of the virtual drivers, but I don't think it would extend to hours.

Well one way would be to have a permanently running app that listens to events from particular devices and maintains a timer for each. Logically that could work, but that would waste hub resources during long periods that no countdown was actually required (ie none of the devices were on). Unless it exits when no timer has remaining value...

I would have thought not, but HE staff can probably comment more on this if you decide to go down that path. I haven't ventured into developing apps myself, but feel like I will likely do so soon. I can't image an app listening for a trigger is any different to a RM rule listening, they are basically the same, from what I understand...

They are the exact same thing - a rule is just a child app of RM. Small app (if one doesn’t already exist) would be easy to construct just needs a list of devices to listen on, and the ability to kick off a scheduled job to send the turn off.

2 Likes

Exactly what I was thinking.... without wanting to give that impression.... have enough projects of my own... while always happy to help out.... happy for anyone else to pick this one up.... or hopefully there is something already out there....

1 Like

The only tricky part I see on the surface is how to unschedule/reschedule if someone were to manually flip the switch.

Yes, I think it could be done in an app. In one RM rule, turning on any of the 6 devices would turn on a virtual switch. The switch is the trigger to the app starting. When the app starts it subscribes to turn on and off events for the devices, and checks which ones are already on (almost certainly just the one at this point) and starts their timers.

The virtual switch won't change state from On so it won't trigger the app to restart.

When it hears one of the devices turn on it starts or restarts their timers. When they turn off it resets the timer to zero. When any timer reaches zero the app turns off the device. When all timers are zero the app turns off the virtual switch and exits.

While running the app loops each minute reducing each timer by 1.

I still see duplication here though as I have to select the same devices twice once in the rule and once in the app.

A bit more complex once you add in the possibility that @thebearmay mentioned about the user turning the device off and back on, but still not too bad. :smiley: This app should handle any combination of things you want in that regard:

You will probably want to configure it something like this:

That being said, Basic Rule can probably do this with only a few more clicks nowadays, but if you're setting up a lot (like I was before I wrote this), it's definitely a lot easier than a Rule per switch.

4 Likes

That probably wouldn't be optimal for me because I am already finding my device list a bit unwieldy and it relies on each device also having a sibling virtual switch. When I get a few free hours I'll see what I can come up with as an app along the lines of what I described above.

No, it doesn't...that's an option, if you don't use the configuration I posted above.