Reuse of logic & states across multiple spaces without maintaining multiple versions

I have some logic I want to use as an automation in various rooms. There are three automations per room, so I would like to use an input_boolean to prevent them from running over each other.

Example, per room:

1/ Turn on fan after someone has been in the room >10 minutes, start 2 minutes after they leave

2/ Turn on fan 5 minutes every hour when nobody is at home

3/ Turn on fan when humidity reaches 47%, run until humidiity < 45% or 30 minutes, whichever is sooner.

As these automations affect the same unit, I would use an input_boolean helper to stop them from interfering with each other, with first one that runs wins.

Is there any way to write this code and setup the helper once, but use it separately in several rooms? Or do I have to repeat the code and helper per room?

Actually that’s easier than you think.
What you need to do is put all 3 of these functions in the same automation, and set the automation to single mode. Then when one of the functions is running, another function is automatically locked out. Put your triggers in with separate trigger_id’s, then use a choose in the action to do the thing based on the trigger_id.

2 Likes

Fantastic, you’ve reduced my workload by 66%. Is there anyway to abstract the entity involved so I can reuse the automation across several different rooms?

Once you create the first automation, convert it to a blueprint.

1 Like

That is perfect. It’s not often you get a question completely and correctly answered. Thank you very much.

If I may, is there a Home Assistant tutorial or youtube channel you’d recommend that would be a good substitute for RTFM? I’ve been working with HA for a few years now and there are so many features like blueprints I feel I’m not aware of.

Kinda like Bearded Tinkerer YT.
Otherwise some of the volunteers here have come up with this:
The Home Assistant Cookbook - Index.

If One of my suggestions solves your problem, please consider clicking the solution button to close the thread.

1 Like

hi @notmax welcome to the community. since you’re new and got an answer you liked, i thought i’d suggest a bit about how best to support the forum and folks answering your questions.

when you get an answer to your question, please be sure to pick whichever post @Sir_Goodenough has given that you think best answers the question and hit the ‘solution’ button on that post. maybe also give him a heart.

the ‘solution’ button puts this answer associated at the top with the question which then helps future people who may search for the same question… they’ll be led straight to the answer. and the heart helps the system recognize who’s contributing well to the forum and ends up trusting them a bit more.

cheers!

2 Likes