Automation: Action runs no matter what state is

Hi All,

I created the following Automation but the action (push) is still send even if the state is None:

   alias: Send push if today is Restafval
   description: ''
   trigger:
   - platform: template
     value_template: '{{ is_state(''sensor.afvalinfo_today'', ''restafval'') }}'
   - at: '11:50'
     platform: time
   condition: []
   action:
   - data:
       message: Grijze container buitenzetten
       title: Alert
    service: notify.mobile_app_PHONE

I’ve also tried:
value_template: '"{% if is_state(''sensor.afvalinfo_today'', ''restafval'') %}true{%endif%}"'

But that isn’t working also.
Regards,
Johan

value_template: "{{ is_state('sensor.afvalinfo_today', 'restafval') }}"

changed to :
"{{ is_state('sensor.afvalinfo_today', 'restafval') }}"
but still getting the push message

What does this resolve to in the developer tools template editor:

"{{ is_state('sensor.afvalinfo_today', 'restafval') }}"

It says “False”

Are you triggering this automation manually to test it by any chance ?
Your spacing is off, I count 3 spaces for some lines and 5 spaces for others (spacing should always be multiples of 2)

What about adding a condition (say) : -

    condition:
      - condition:  template
        value_template: "{{ states('sensor.afvalinfo_today') != 'none' }}"

I know that you specifically are triggering on == ‘restafval’
but the time trigger doesn’t

Binary sensors say false, how is that sensor constructed ?

I just move the time and wait.

I’ll get the following error:
Error rendering template: TemplateSyntaxError: unexpected ‘%’

I think that time means check on the time if state is ‘restafval’ or am I incorrect?

sorry, corrected above, i cut and pasted a more complex condition, then simplified it but i made an error, corrected now.

post the yaml for the sensor

Your automation is triggering by time, not by the template.

Remove the time trigger, job done.

1 Like

Seems to work when I change the state manually.
my interpretation of the time tigger is different that how it works
Thanks

It’s a pretty simple trigger. At the time you specify it triggers. How did you think it worked?

2 Likes