🚽 Toilet Exhaust Fan - Time Delay - Trigger Wait Time - Time

Hey @Blacky can I get some help please?
I have both this automation installed and running and bathroom humidity exhaust fan automations. They seem to be conflicting with each other - and switching the fan off when it shouldnt be turned off (even though technically it should be turned off due to derivative sensor).
So I have a binary sensor that shows the state of a physical switch from a Shelly 2.5. This is what I use to facilitate toilet exhaust fan operation. A person needs to turn the switch on (to turn on non smart lights) when having a shower (shower is also in the same bathroom as the toilet). The same goes for using the toilet - turn on the physical switch to turn the light on in the bathroom - HA knows when the bathroom light is on due to the Shelly.

  • ‘Toilet Exhaust Fan’ automation should turn on the fan after 2 minutes of binary_sensor.bathroom_light_switch being turned on. This works fine.
  • ‘Toilet Exhaust Fan’ automation should turn off the fan after 5 minutes of binary_sensor.bathroom_light_switch being turned off. This works fine in isolation.
  • ‘Bathroom Humidity Exhaust Fan’ automation turns the fan on when sensor.ensuite_bathroom_humidity_derivative rises to +2.5%. This works fine.
  • ‘Bathroom Humidity Exhaust Fan’ automation turns the fan off when sensor.ensuite_bathroom_humidity_derivative drops to -2.3%. This works fine in isolation.

However, what I am seeing is the fan going off while someone is showering - humidity derivative appears to have master control as the values are telling HA to turn the fan off. Overall this isnt good because I am the only one (of 4) that opens the window when showering (better to get the humidity out naturally as well as via the fan). Sadly, I have noticed as of yesterday mould has started to build up very quickly.

What I want to happen is ‘Toilet Exhaust Fan’ to take the lead - if the light is on for more than the 3 minute timer, turn on the fan regardless of humidity levels. Then, when someone turns off the bathroom light, if the humidity is still too high, the ‘Bathroom Humidity Exhaust Fan’ to continue to bring down the humidity level
What I dont want to happen is the ’ Bathroom Humidity Exhaust Fan’ take the lead and turn off the fan even though the bathroom light is on.

Can you help?
Here are the yaml configs:

Bathroom Humidity Exhaust Fan

alias: Fan - Ensuite - Toilet Exhaust Fan
description: ""
use_blueprint:
  path: Blackshome/toilet-exhaust-fan.yaml
  input:
    entity_trigger: binary_sensor.bathroom_light_switch
    fan_switch: fan.ensuite_fan_combined
    trigger_bypass: input_boolean.ensuite_fan_automation
    include_bypass:
      - bypass_enabled
      - bypass_enabled_turn_on
    time_delay: 5
    trigger_wait_option: wait_for_trigger
    bypass_fan_on:
      - input_boolean.ensuite_bathroom_fan_automation_link_bypass
    include_bypass_auto_off:
      - bypass_auto_off_enabled_on
    trigger_wait_time: 2

Bathroom Humidity Exhaust Fan

alias: Fan - Ensuite - Bathroom Humidity Exhaust Fan
description: ""
use_blueprint:
  path: Blackshome/bathroom-humidity-exhaust-fan.yaml
  input:
    trigger: sensor.ensuite_bathroom_humidity_derivative
    fan_switch:
      entity_id:
        - fan.ensuite_fan_combined
        - input_boolean.ensuite_bathroom_fan_automation_link_bypass
    bathroom_humidity_sensor: sensor.ensuite_humidity_sensor_humidity
    rising_humidity: 2.5
    falling_humidity: -2.3
    include_max_humidity: maximum_humidity_enabled
    max_humidity: 75
    fan_speed_low:
      - fan.fan_idle_speed
    time_out: 40
    include_fan_speed: fan_speed_disabled
    winter_include_max_humidity: maximum_humidity_disabled
    winter_max_humidity: 85
    include_winter_mode: winter_mode_disabled
    month_winter_mode:
      - "1"
      - "2"
      - "3"
      - "10"
      - "11"
      - "12"
    winter_rising_humidity: 2
    winter_falling_humidity: -2
    winter_time_out: 40
    winter_include_fan_speed: fan_speed_disabled
    manual_fan_switch: []
    include_manual_fan_switch: disable_manual_fan_switch
    include_automation_link: disable_automation_link
    automation_link:
      - input_boolean.ensuite_bathroom_fan_automation_link_bypass
    include_bypass: bypass_disabled
    bypass_options: []