Automation trigger on (string) attribute change


I want to trigger an automation everytime the media_title attribute of the media_player (spotify) component changes.

Couldn’t find or figure out any solution. Did anyone already have a solution or a suggestion I can try out?

Thanks in advance.

you need to set up a sensor for the specific attribute in the configuration.yaml like:

  - platform: template
        value_template: "{{ states.media_player.apple_tv.attributes['media_title'] | default('Nothing playing') }}"
        friendly_name: Apple TV

the “friendly_name” is optional and the " | default(‘Nothing playing’)" can be skipped if there already is a default value or you don’t need one.

after that you can create an automation with “entity_id: sensor.apple_tv_media_title” as trigger.

1 Like

Thank you Walhalla,

This actually solved it!

It’s important to use states before the component name. One of my mistakes when I tried it nearly the same way :man_facepalming:

you need to set up a sensor for the specific attribute

Is not necessary to create new sensor. See solution here: Using attribute as trigger for automation