Trigger template for humidity sensor

Hello everyone, I’m struggeling to make a blueprint for a humidity control of my grow box. I have 3 triggers that compare an AHT10 sensor to a threshold:

  1. Start the fan/vacuum when the value is above the threshold value
  2. Stop the fan/vacuum when the value is below the threshold value -5% (to avoid several start/stop of the fan)
  3. Send a warning notification when the value is above the threshold value +5%

I am trying to template the 2. and 3. threshold, as the first is an input of the blueprint but if I use the numeric_state

input:
    humidity_sensor:
      name: Sensore di umidità
      description: Seleziona il sensore che controlla l'attivazione
      selector:
        entity:
          filter:
            domain: sensor
            device_class: humidity
      default: sensor.centralina_ambientale_serra_umidita_ambiente

    humidity_threshold:
      name: Soglia umidità
      description: Se l'umidità supera questo valore, l'aspiratore si accende
      selector:
        number:
          min: 1
          max: 100
          unit_of_measurement: "%"
          mode: slider
      default: 80

trigger_variables:
  humidity_sensor: !input humidity_sensor
  humidity_threshold: !input humidity_threshold
  humidity_threshold_low: humidity_threshold - 5
  humidity_threshold_warning: humidity_threshold + 5

triggers:

  # START ASPIRATORE
  - trigger: numeric_state
    entity_id: !input humidity_sensor
    above: !input humidity_threshold
    id: "humidity_high"

  # STOP ASPIRATORE
  - trigger: numeric_state
    entity_id: !input humidity_sensor
    below: humidity_threshold_low
    id: "humidity_low"

  # WARNING - Quando l'umidità supera la soglia +5%
  - trigger: numeric_state
    entity_id: !input humidity_sensor
    above: humidity_threshold_warning
    id: "humidity_warning"

But I have the error on the template:

Message malformed: expected float for dictionary value @ data['below']

I have also tried with template platform:

  # STOP ASPIRATORE

  - trigger: template
    value_template: "{{ (states('humidity_sensor')) < humidity_threshold_low }}"
    id: "humidity_low"

  # TRIGGER NOTIFICA - Quando l'umidità supera la soglia +5%
  
  - trigger: template
    value_template: "{{ (states('humidity_sensor')) > humidity_threshold_warning }}"
    id: "humidity_warning"

I did try many other ways without success, platform numeric_state doesn’t accept templates, and the documentation is not very clear regarding variables and trigger variables.
Someone have a solution? The only workaround I found is to use the 2. and 3. thresholds as input.

Those are nonsense. If you want to modify values, you need to use a template:

  humidity_threshold_low: "{{ humidity_threshold - 5 }}"
  humidity_threshold_warning: "{{ humidity_threshold + 5 }}"

Also…

In both your triggers you are using variables, but you have turned them into strings by wrapping them in quote marks. The variables for the entity ID should be unquoted like:

    trigger: template
    value_template: "{{ (states(humidity_sensor)) < humidity_threshold_low }}"
    id: "humidity_low"

But the bigger issue may be that trigger-based template sensors are not supported for Template blueprints in 2025.3 or earlier. They do seem to be working in 2025.4b15, so either join the beta or wait for the April update to drop later today. Keep in mind that I’ve only run a few basic tests, so there may still be incomplete functionality.

Thank you for your quick reply. Yes the expression was nonsense, but I did try also with the template.
This morning I have updated to 2025.0 stable and there are no changes, also with the trigger template the automation doesnt go thru when I force the humidity sensor to a value lower then the humidity_threshold_low from an aspirator run scenario, I think it’s the bug you were saying.

I forgot to mention that I had also variables that are used for the trigger_variables, as jinja doesn’t accept !input(correct me if I’m wrong!) my code after your suggestions now is:

input:
    humidity_sensor:
      name: Sensore di umidità
      description: Seleziona il sensore che controlla l'attivazione
      selector:
        entity:
          filter:
            domain: sensor
            device_class: humidity
      default: sensor.grow_box_umidita_ambiente

    humidity_threshold:
      name: Soglia umidità
      description: Se l'umidità supera questo valore, l'aspiratore si accende
      selector:
        number:
          min: 1
          max: 100
          unit_of_measurement: "%"
          mode: slider
      default: 75

variables:
  input_mode: !input mode
  input_enable_notifications: !input enable_notifications
  input_notification_service: !input notification_service
  humidity_threshold: !input humidity_threshold
  humidity_sensor: !input humidity_sensor

trigger_variables:
  humidity_threshold: !input humidity_threshold
  humidity_sensor: !input humidity_sensor
  humidity_threshold_low: "{{ humidity_threshold - 5 }}"
  humidity_threshold_warning: "{{ humidity_threshold + 5 }}"

triggers:
  # START ASPIRATORE

  - trigger: numeric_state
    entity_id: !input humidity_sensor
    above: !input humidity_threshold
    id: "humidity_high"

  # STOP ASPIRATORE

  - trigger: template
    value_template: "{{ (states(humidity_sensor)) < humidity_threshold_low }}"
    id: "humidity_low"

#  - trigger: numeric_state
#    entity_id: !input humidity_sensor
#    below: !input humidity_threshold_low
#    id: "humidity_low"

  # WARNING - Quando l'umidità supera la soglia +5%

  - trigger: template
    value_template: "{{ (states(humidity_sensor)) > humidity_threshold_warning }}"
    id: "humidity_low"