I’d like to trigger some automation based on the title attribute of a stream and when this title contains just a specific word, such as “example”.
Means, in case “example” is part of the actual stream title of the desired streamer, the automation shall trigger.
On the other hand, if “example” is not part of the title, it shouldn’t trigger.
trigger:
- platform: template
value_template: >
{{ 'example' in state_attr('sensor.twitch','title') or
'example2' in state_attr('sensor.twitch','title') }}
As two triggers:
trigger:
- platform: template
value_template: "{{ 'example' in state_attr('sensor.twitch','title') }}"
- platform: template
value_template: "{{ 'example2' in state_attr('sensor.twitch','title') }}"
No real advantage to either way. If you wanted to process them differently you could use trigger IDs more easily with the two-trigger option.
You could also do it that way:
trigger:
- platform: state
entity_id: sensor.twitch
attribute: title
condition:
- "{{ 'example' in trigger.to_state.attributes.title }}"
- "{{ 'example2' in trigger.to_state.attributes.title }}"