Hi all,
Is there a way to get the tittle or name of the media that is currently playing on a media player?
I would like to use specific media as a trigger.
Thanks for the help!
kind regards,
kevin
Hi all,
Is there a way to get the tittle or name of the media that is currently playing on a media player?
I would like to use specific media as a trigger.
Thanks for the help!
kind regards,
kevin
yes, the easiest way is to create a template_sensor that will retrieve the media_playerâs attribute
Hi, thanks for the response.
are thee docs related of how i could implement t in the template?
Open the States page and find your media_player
in the list. Look at the right-hand column showing your playerâs attributes. Youâll find attributes like media_title
and media_author
.
Letâs say you want to do something when media_title
is âBest Jazzâ. You can create a Template Binary Sensor that indicates on
whenever the title is âBest Jazzâ. You can then create an automation that is triggered whenever the binary_sensor is on
and then proceeds to perform an action.
Alternately, you create an automation that is triggered directly by the media_title
attribute using a Template Trigger.
Try this:
- platform: template
sensors:
media_player_title:
entity_id: media_player.house
value_template: '{{((state_attr("media_player.house", "media_title")}}'
friendly_name: Media Player Title
Replace house
with the name of your media_player
It works!
Thanks!
Follow up question,
Can i differentiate when music and when movies are played?
tnx for the help
Some media players have the âmedia_content_typeâ attribute, which you would also have to create a template sensor for.
I know this is forever old, but this worked for me:
{{((state_attr("media_player.office_speaker", "media_title")))}}