#Automation not triggering

1 messages · Page 1 of 1 (latest)

ember venture
#

With some help from somebody else I made an automation where if a RSS Feed title contains a certain word or phrase, it would trigger a script.

Right now I did copy one of the automations I made and changed the entity, because I added a different RSS Feed. But the automation doesn't trigger and I can't figure out why. The entity also updates right and in the developer tools you also see the title from the entity.

This is my template:
{{ 'Tornado Warning' in state_attr('event.current_tornado_warning_events', 'title') }}

chilly hemlock
#

Are you using that template in a trigger or a condition?

ember venture
chilly hemlock
#

Yes, that is a trigger. A Template trigger only fires when the value that the template renders changes from false to true. So, if the template is true when you initialize the automation, the rendered value needs to change to false then back to true for the trigger to fire. This is probably going to cause issues for you because the event entity you are listening for will likely almost always have "Tornado Warning" in the title attribute.

A better option would be to use a State trigger, then add a Template condition to prevent action execution if the title doesn't contain the desired string:

triggers:
  - trigger: state
    entity_id: event.current_tornado_warning_events
    attribute: title
conditions:
  - condition: template
    value_template: |
      {{'Tornado Warning' in trigger.to_state.attributes.title}}
actions:
....