[Twitch Integration] How to trigger an automation based on attribute "title" of a stream?

Hi,

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.

Would that somehow be possible?

Thanks!

Yes that is possible.

trigger:
  - platform: template
    value_template: "{{ 'example' in state_attr('sensor.twitch','titile') }}"

Awesome, thank you!

Would it also be possible to extend it in the way that it triggers when there are two words in the stream title (or condition)?

Means that it triggers when there is either the word “example” or “example2” part of the stream title?

Thanks!

As a single 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 }}"

Once again many thanks to both of you!
Actually it works as desired!