Is there a way to target devices by type to act on them individually?

I’d like to streamline autoshutdown automations (e.g. lights) from a ton of individual automations (each has its own countdown) to just one that sort of forks itself to act only on the device that triggered it, rather than any device of similar type retriggering the same loop.

So I guess I can’t put on what the automation is going to act other than a placeholder variable of sorts that get filled in by the device that triggered it the whole sequence in the first place. If I remember correctly the option of running parallel loops exists already, and I think I just figured out the logic as I typed this, all that’s missing is creating a monitor of a specific type of device, capturing it on a variable, use that variable a little later, but one step at a time, I suppose.

I thought about repurposing areas for grouping device types or some trick like that. I know areas can be acted on, I don’t know if they can be used as triggers, much less their individual members.

Is any of this possible?

Thanks!

I can’t answer your question directly, but if I explain how I achieve something similar, maybe it will give you some ideas.

I have a lot of lights (and switches) that come on for different durations, and I like timers, but I’m too lazy to code all of the “off” routines. So I create each timer so that it matches the entity being turned on. So for example, light.kitchen has a corresponding timer timer.light_dot_kitchen. Then I’ve got one automation (in Node Red) that listens to any timer finishing, and if the entity id includes _dot_, I convert that back to an entity with string replacement and turn it off.

I’ve also extended it to handle conditions like timer.switch_dot_pihole_dot_turn_on to recognise there’s two _dot_ strings in there and set the action dynamically too.

1 Like

That sounds more or less like my bash scripts. I kinda low-key love bash. I’m very curious.

I’m too stupid for Node Red though. I tried using it years ago but I couldn’t figure out how to pull data from Home Assistant, there was nothing about it in the documentation. It felt like I would have to start over completely in Node Red so it had the whole infrastructure in it, which wouldn’t be a big deal if I was starting from scratch, but my setup had already been done for years prior in Insteon, Indigo Pro, and a couple of protocols more. I kept jumping between Indigo Pro, Home Assistant, and OpenHAB, learn to integrate them all and since the other two have very easy to use logic builders, I no longer needed Node Red.

At some point Home Assistant good enough to handle most of my rather mundane needs on its own that I hadn’t even remember about Node Red’s existence until just now. Maybe that [one’s documentation] got better too, it couldn’t hurt to check/try again, unlike the past times, I’m in no hurry that I will be in the dark or able unlock doors if I don’t finish by nightfall.

Thanks for answering, especially for that little _dot_ clue. If I fail, you gave me another idea: I can script in bash getting the objects from the API and build the automations’ syntax from a finished model. Python would be better I suppose, but I don’t know Python. :sweat_smile:

Thanks again!

I just realized that wouldn’t streamline anything :rofl: except for building things in the future…
I’ll take it as a win. Man, I’d suck as a sex worker. Figuratively too, I mean.

I’m not clear exactly what you’re trying to do, but it sounds like some of what you’re describing is already built into HA. You can supply multiple entity IDs for the same trigger, and then the trigger variable will have details about which entity caused the trigger. Furthermore, you can set the automation mode to parallel, so every trigger spawns a unique instance of your actions.