Template Trigger doesn't work!

PLease help. I have this automation and it won’t fire. I change the state to test and nothing. Any ideas?

alias: Dehumidifier On
description: ""
trigger:
  - platform: template
    value_template: "{{ states('sensor.dehumidifier_humidity') | float >= 60 }}"
    enabled: true
condition:
  - condition: time
    weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
    after: "07:30:00"
    before: "19:30:00"
    enabled: true
action:
  - type: turn_on
    device_id: 7390b40dd9c131eb46a74738b25d54e9
    entity_id: 3fa2b6fe0a449b1ecc88d35b327e5f0a
    domain: humidifier
mode: single

It might help to look at the Traces to see where the automation failed, whether it didn’t trigger, got hung up, or thinks it completed.

Out of curiosity, why not just use a Numeric State trigger? To include 60, you could just set it to above 59.9, and I think it would do what you are intending.

Why are you using a template trigger for this?

The exact same thing can be accomplished with a much simpler numeric state trigger.

trigger:
  - platform: numeric_state
    entity_id: sensor.dehumidifier_humidity
    above: 60 # or 59.99 if you want above or equal to 60

And to test it you it needs to go from below 60 to above 60, so first change it to eg 59 and then to 61
That is the case for both the template trigger as the numeric_state trigger.

I do agree that I don’t see a reason to use a template trigger here

I managed to get this working with this so no matter what value when its >= 70 it will fire.

alias: Dehumidifier On
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.dehumidifier_humidity
condition:
  - condition: time
    weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
    after: "07:30:00"
    before: "19:30:00"
    enabled: true
  - condition: template
    value_template: "{{ states('sensor.dehumidifier_humidity') | float(0) >= 70 }}"
action:
  - type: turn_on
    device_id: 7390b40dd9c131eb46a74738b25d54e9
    entity_id: 3fa2b6fe0a449b1ecc88d35b327e5f0a
    domain: humidifier
mode: single

The problem with this is it needs to go from 59 to 61 in order to fire but I dont want it to fire during the night because it will wake my wife up and that means death!

So during the night the humidity rises to above 70 and stays there because the condition stops the trigger from firing. I need an automation to look at the current value and fire if it’s anything over 70.

Make sense? I might have not explained myself correctly.

The problem with this is it needs to go from 59 to 61 in order to fire but I dont want it to fire during the night because it will wake my wife up and that means death!

So during the night the humidity rises to above 70 and stays there because the condition stops the trigger from firing. I need an automation to look at the current value and fire if it’s anything over 70.

Make sense? I might have not explained myself correctly.

Your template trigger won’t do that either.

What time do you want it to turn on in the morning?

It’s okay thank you I managed to solve it. Posted my solution. Further up. Might not be the best way but it works.

Correct me if I’m wrong, but it looks like what you did was trigger the automation at any state change on the dehumidifier humidity sensor, which means that the automation will likely be triggered every few minutes, or even more often, depending on the rate of humidity change and frequency of reports from the device, including when the dehumidifier has already been turned on and the humidity is going down. This would be quite the unnecessary burden on your Home Assistant instance when you could construct a much more targeted trigger using the Numeric State trigger, which would then only trigger the automation at the prescribed threshold. While it may work, it will also waste resources that could cumulatively bog down your system if you have too many things going like this.

On another note, if you haven’t already, don’t forget to make an automation (or add to this one by using trigger ids/additional actions) to turn your dehumidifier off again, either once it has reached a certain humidity level or has run for a certain amount of time. Alternatively to this whole setup, you could make a Threshold Sensor for the humidity range you want to keep it in, and use the position (above/below) to trigger the automation to turn the dehumidifier on and off.

Thanks for the suggestions. I does all if on every time the value changes on that specific sensor but will only execute the automation if the value is >= 70. I’ve tried numeric state but that will only fire if the value goes from 69 to 70 and not if the value is 70 and above so i needed something to check the value on every value change. That’s the reason why i did it this way.

Ah, yes, I suppose it wouldn’t trigger again in the morning if it were foiled when it reached 70 overnight, so here is my final suggestion before moving on. Use two triggers. One would be the Numeric State threshold trigger that would be conditional based on the time of day, and the other would be a Time trigger in the morning when you want it to possibly turn back on to check if it reached 70+ overnight. Achieves both requirements, and isn’t constantly running the automation.

Thanks, I actually thought about that this morning. It’s probably better than an event every time the value goes up or down. Great minds… thanks again.