Automation based on value from sensor

I think i’m making things more complicated than nescessary but i need some help with the folowing:
In my bathroom i have ventilation triggered by a seperate humidity sensor. This works fine, but now i want the trigger value to change with the metrological seasons.
So far:
i made a sensor to determine the metrological season which gives me a value of summer,spring, autumn or winter.
Next i created a sensor [sensor.lv_drempelwaarde] to set the trigger value based on the season. For example: ‘winter’ gives a value of 69 and summer a value of 80.
So far so good and working.
The big question:
How do i use the value from the sensor [sensor.lv_drempelwaarde] in my automation to control the ventilation?
My current automation:

- id: '1538217836354'
  alias: Badkamer Ventileren
  - above: '73' ## This value has to be the value from [sensor.lv_drempelwaarde] ##
    entity_id: sensor.vochtsensor_badkamer # This is my humidity sensor
    platform: numeric_state
  condition: []
  - alias: ''
    data: {}
    entity_id: switch.relais_badkamer_ventilator_switch_2
    service: switch.turn_on

So to be short:

  • above: ‘73’ <-- the ‘73’ must become the value from my custom sensor [sensor.lv_drempelwaarde]

Thanks for your help in advance!

Please have a read of this, particularly point 11.

First of all, you have alias listed twice
What I’d do is a trigger that simply tracks sensor changes and then add a condition:

- id: '1538217836354'
  alias: Badkamer Ventileren
  - platform: state
    entity_id: sensor.vochtsensor_badkamer
  - condition: template
    value_template: '{{ (states("sensor.vochtsensor_badkamer") | int) > (states("sensor.lv_drempelwaarde") | int) }}'
  - service: switch.turn_on
      entity_id: switch.relais_badkamer_ventilator_switch_2

note: this is untested, but the logic should work

Thank you! Your example works exactly as i wanted. I’m trying to understand how the value_templates work and with your help i’m learning a bit more.

Feel free to make it as a solution :wink:
A value_template basically performs a calculation based on one or more HA entities based on status, attributes, etc. Takes a bit getting used to it but very powerful