Small format problem with trigger.entity_id

I am trying to send what’s playing in J.River Media center, but I know I am doing something wrong. In LUA I would concatenate with … but I don’t know how to do it here. This does not work:

 Playing now: "{{ states.trigger.entity_id.attributes.media_title }}"

I think it’s the trigger.entity_id that needs to be tied to the rest of the sentence differently,. This is an example of a trigger: media_player.hytteserver_tor, so it should actually become {{ states.media_player.hytteserver_tor.attributes.media_title }}

The trigger variable contains the entire state object, so it’s rare to need to use states if you have trigger.

You haven’t provide much detail, but I think what you are going for is:

Playing now: "{{ trigger.to_state.attributes.media_title }}"

If you really want to query the attribute’s value, you could do the following instead:

Playing now: "{{ state_attr( trigger.entity_id, 'media_title') }}"

In both options above I have left the quote marks, though they are also likely problematic… it’s hard to tell without any context.

1 Like

Thank you very much! :smile: The quotation marks are there to give the full sentence, and that works like it should! The full display on the web page is now Zone Tor is now playing Kryptan with "Let Us End This" from the album "Violence, Our Power" (only in Norwegian. I changed it to “now playing” instead of “Playing now:” since I found a better way of phrasing it.)