Multiple automations to control a single mirror-heater (i.e. switch) without interference

I recently built a mirrored cabinet door in my bathroom with a Shelly-controlled mirror-heater. The obvious automation was to turn the mirror heater on when humidity is high (>70% say) and off when it drops later (<65% say). The goal being that when you get out of the shower, the mirror is not misted up. Unfortunately, the heater is a bit slow to warm up the mirror so this doesn’t work perfectly - it’s delisted 10 minutes after your shower, not right away.

So I’m thinking of what triggers I can use to turn on the heater a bit earlier – actions taken elsewhere in the house after getting up that could be used to trigger the mirror heater before getting into the shower. So I may have 2-3 other triggers & timings which predict I’m likely to take a shower soon and speculatively turn on the heater for, say, 10 minutes.

My challenge is how to avoid having these different automations turning OFF the heater when another one wants it on. I could have these automations turning the heater on, their timer(s) expire when I’m in the shower after the humidity has risen, and now they turn the heater off at exactly the wrong moment…

One solution is to create one input_boolean per automation, to store the “preference” of that automation to have the heater on or off. And then add 1 final automation which takes an “OR” of all the booleans and uses that to control the heater. If I add a new automation I need to do three things: (a) create a new input_boolean, (b) write the automation, (c) edit the final automation to be aware of the new input_boolean.

Is there a simpler or more elegant way to do this? Where adding a new automation is a single step (not 3), and where the final automation can implicitly be aware/told of other automation’s preferences for the heater to be on/off without needing the yaml code to be edited?

If I was writing code to do this, there would be, say, a HashMap variable attached to the heater, and anything that wanted it on/off would set a value in that Map - “automation 1 wants”->“On”, “automation 2 wants”->“Off”, etc. Then the ‘final automation’ takes an “OR” of all values in the Map (without even knowing how many there are). Can that be represented in Home Assistant somehow?

You really want to avoid multiple automations controlling the same hardware. It’s confusing and buggy very fast.

I’d do the following:

  1. Create an input_boolean called request_heater_on
  2. Create an atomation with multiple triggers:
    2a) Humidity high - trigger id = high
    2b) request on - trigger id = request
    2c) humidity low - trigger id = low

Then, based on the trigger id you can turn the heater on/off. You can have as many triggers as you want. In 2b, don’t forget to turn the request off.