I have a lot of lights and devices that only I care about turning off after leaving a room.
I have a few RuleMachine entries but what I would really like to do is to have one to rule them all. Can I reference the triggering device and use that in RM4 to start a (cancellable) timer to turn off said device?
Ideally I would like to have a list of "auto-off devices* and a variable global time that determines how long they are allowed on.
Not really--the closest you can get is that the built-in %device% variable will refer to the name (but not the underlying "device object") of the triggering device. As a proof of concept, I did once demonstrate that you could write conditionals based on the device name to act accordingly to which device it was that triggered the actions to run, but this has obvious downfalls (prone to typos, needing change if the device name changes, and just generally being an awkward workaround). This is not something I'd generally recommend, though like many things in RM, it's certainly possible.
I'm not sure if there's really a good reason to combine these rules into one if it's what it sounds like: separate triggers and separate actions. If so, you'd really be making it more work for your hub, having a giant rule with a lot of device/event subscriptions and a complicated "Actions" section full of conditionals where it figures out what to do when. There's no reason to not prefer separate rules in this case, except that I understand you might not like having multiple "child apps" (rules) in your list. (If all your devices just have different "off" intervals but those are all triggered by, say, the same motion sensor, that that's easy to do and is actually a great candidate for having all these actions in the same rule.) There's no harm in that, but if it still bothers you, it may be a good case for a custom app. I don't have one nor am I aware of one that would suit your needs, though Timed Switch Helper comes close. Unfortunately, that's also one child app per device, not one giant app to rule them all.
I considered making that app as well but at the end of the day it wasn't much time to create one rule and copy it 15 times and replace the motion sensor and light to shut off. Then the rules started mutating and doing other weird things too so I'm sort of glad I did the rules.
I was surprised to see %device% not available as an object when using Rule machine. I have just one Webcore piston left running (out of around 30). This relies on Smartthings hub and a link back to Hubitat (legacy as part of move from Smartthings). All because I can't easily flip automation switches back to 'ON' after 1 hour.
Currently, if we want automations in a room to stop for a while, we ask Google to turn off said automation, the switch state is passed to Smartthings, then Webcore and a piston runs that has all the automation devices selected as triggers, but the piston can see which device triggered to off, set a schedule for 1 hour, and turn back on that one switch. If we switch off others, it just sets additional schedules.
Dead simple routine that should be easy in Rule machine, but I cannot work it out. I don't think it's possible. So I have to keep a Smartthings hub just for this. I know I could set up a routine for every automation switch but that seems even more ridiculous than what I have already.
It will probably take a while before HE adds this reference so I just finished the app over at:
It only does auto-off right now but I could add an invert option easily to make it auto-on. Open up an issue for an invert option over at my app repository and let's get rid of that last piston https://github.com/MFornander/Hubitat/issues