Template trigger

Hi guys!

I’m kind of new to home assistant and I have bumped into a problem so I’m hoping someone can help me with this…

This is the automation I’m struggling with:

  • id: “dehumidifier_off”
    alias: “dehumidifier off”
    initial_state: true
    hide_entity: false
    trigger:
    platform: numeric_state
    entity_id: sensor.135_humidity
    below: ‘{{states.input_number.slider1.state | float}}’
    action:
  • service: homeassistant.turn_off
    entity_id:
    - switch.fibaro_system_fgwpef_wall_plug_gen5_switch_18_0

So I would like to be able to change the “below value” with a slider.
Is it even possible to do something like this or does it have to be a number after “below”?

This is the error i get in the log:

Invalid config for [automation]: expected float for dictionary value @ data[‘trigger’][0][‘below’].

Thankful for any help i can get :smiley:

1 Like

I think the problem is with float, try to use int instead.

You can’t do it like that. Templates can only go in places where they are expected.
What you can do however is a template trigger like this:

  trigger:
    platform: template
    value_template: "{{(states.sensor.135_humidity.state | float) < (states.input_nmber.slider1.state | float)}}"
1 Like

Thanks for the reply! however I get another error with that code:

Invalid config for [automation]: invalid template (TemplateSyntaxError: expected token ‘)’, got ‘_humidity’) for dictionary value @ data[‘trigger’][0][‘value_template’]. Got None.

1 Like

it may not like the name of your sensor. Try naming it something that starts with lower case letters.

You mean “sensor.135_humidity”? The letters are all lower case.

Edit… Aaaahaaa! I see what you mean now… Yeah I will try that…

Thanks @treno, you solved my problem! I fixed the sensor name, a typo in the template trigger and changed from float to int and now it’s working like a charm!

Posting the working automation.

- id: "dehumidifier_off"
  alias: "Dehumidifier off"
  initial_state: true
  hide_entity: false
  trigger:
    platform: template
    value_template: "{{(states.sensor.basement_humidity.state | int) < (states.input_number.slider1.state | int)}}"
  action:
  - service: homeassistant.turn_off
    entity_id:
    - switch.fibaro_system_fgwpef_wall_plug_gen5_switch_18_0
4 Likes