Automation priorities possible?

I was wondering if it is somehow possible to have priorities of automation using Home Assistant.

For example: is used to control my ventilation at home based on humidity level. What I want it to do now, is having the following setup:

  1. if I’m at home, run ventilation at level 2
  2. if I’m not at home, run ventilation at level 1
  3. If humidity is higher then x, run ventilation at level 3 despite the fact if someone is home or not.
  4. if humidity is back to normal, go back to 1. or 2.

So 3. would always win aka have the highest prio. I know that I could just add conditions to check if someone is home for all the rules in order to work, but that seems to be a not so nice solution.

Also is it possible to define something like constants in automation so you don’t have to repeat values all the time like when having multiple rules with the same humidity values?

I think it’s not that difficult as automations are based on a trigger and conditions. So they are triggered when you get home and leave home. You can add a condition to these two automations to check if humidity is lower as x so both automations to not change the ventilation level. The humidity > x automation is simple. For the humidity back to normal you could use a template or split it up in two with a condition home or away.

You might even do it in one automation using templates but that probably takes some more time to figure out.

1 Like

This can be managed with a single automation.

Trigger on both humidity level and home status.

Action is to use a template to set the ventilation (input_number) level. It would look something like

{{3 if humidity > x else 2 if home else 1}}

Done. You now have what you wanted in your example and you don’t need to implement a solution that will be significantly more complicated.


yeah it doesn’t work this way. I have several sensors here reporting humidity or air qualitty level and I want my ventilation to be triggered based on that values in a way that:

if one of the sensors a b c d e is higher then 70% turn on ventilation level 3
if one of the snesors a b c d e is between 60 and 70 turn on ventilation level 2
if all of the sensors a b c d e are below 55% turn on ventilation level 1

my problem now is, that the second rule will overrule the first one if one of the sensors is between 60 and 70 turning ventilation to level 2 only although 3 is the proper one. So what I need here is to define rule 1 as the one with highest priority and only if no of the sensors a b c d e is higher then 70, it will check the states of rule 2.

like: if rule 1 was triggered, skip rule 2. if rule 1 wasn’t triggered, try rule 2. and then back to normal with rule 3.

I can’t see how to model this state machine with HA’s automation.

Ok so what I did, is to check when the other rule with the higher prio was triggered last time. I hope this will mitigate my issue:

- condition: template
  value_template: '{{(as_timestamp(now())-as_timestamp(states.automation.luftung_4.last_updated)) > 300}}'

this is connected with a condition and with the humidity check. Will report, if it is not working :slight_smile:

You could also use a template sensor that reports the max humidity of all of the sensors, and then use a template like the one @nordlead2005 purposed.