Automation that gets triggered on calculated value

I have a bathroom fan that comes on if the humidity is above 69%, and turns off when below 56%.

The only problem is if the fan is manually triggered and the humidity is already under 56%. The bottom 40% trigger is there to solve this problem. It works almost all the time, except if it is very dry winter time.

Is there a better approach besides setting a secondary, lower value to trigger?

I know I can calculate the average of other entities, all the humidity sensors in the house, let’s call it h. I would like to set the trigger to say h+5. So, the automation is triggered f the bathroom humidity crosses (average house humidity+5)%.

How would I do this?

alias: "-Base: bath: Fan: ON/OFF on humidity"
description: Turn on fan if too humid, off if okay in basement bath.
trigger:
trigger:
  - platform: numeric_state
    entity_id: sensor.weathersensor5_humidity
    above: 69
  - platform: numeric_state
    entity_id:
      - sensor.weathersensor5_humidity
    below: 56
  - platform: numeric_state
    entity_id:
      - sensor.weathersensor5_humidity
    below: 40
condition: []
action:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.weathersensor5_humidity
            above: 69
        sequence:
          - type: turn_on
            device_id: eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
            entity_id: ffffffffffffffffffffffffffffffff
            domain: switch
      - conditions:
          - condition: numeric_state
            entity_id: sensor.weathersensor5_humidity
            below: 56
        sequence:
          - type: turn_off
            device_id: eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
            entity_id: ffffffffffffffffffffffffffffffff
            domain: switch
mode: single

trigger:
  - platform: template
    value_template: "{{ states('sensor.weathersensor5_humidity')|float(0) >= states('sensor.average_house_humidity')|float(0) + 5 }}"
1 Like

Thanks. Fixed.

Glorious! Thank you.