Hello HA users,
I am trying to do something that should be easy, but I can’t put the pieces together.
I am using the Youtube Music add-on and it works great.
I would like to have some type of picture entity in my dashboard that displays the current artist’s name and album cover image.
The player has these entities:
volume_level: 0.38
is_volume_muted: false
media_content_type: music
media_duration: 238
media_position: 134
media_position_updated_at: 2024-04-24T13:12:47.779575+00:00
media_title: Skinny Love
media_artist: Bon Iver
media_album_name: For Emma, Forever Ago
shuffle: true
repeat: all
entity_picture_local: /api/media_player_proxy/media_player.ytube_music_player?token=b3047796b202879eb8dff139931e1da992eaee4******************
remote_player_state: playing
likeStatus: INDIFFERENT
current_playlist_title: Acoustic Doze-Off
videoId: 95FyXUHv8hk
_media_type: playlist
_media_id: RDCLAK5uy_kIMj6ScYWghk2sQarkFf0gL**************
current_track: 18
remote_player_id: media_player.vlc_telnet
entity_picture: https://lh3.googleusercontent.com/2GJInRG2_894G-p7F3_MscBbPRHL_MRRgw=w544-h
icon: mdi:music-circle
friendly_name: Youtube Music Player
supported_features: 450495
Note: I modified some of the links and identifiable keys above.
How do I extract the entity_picture: URL (near the bottom) and use it in one of the picture entity cards, and have it update when the song changes.
I came across a few similar posts, but nothing matches. Possibly an answer to my question will help others.
Thank you.
nickrout
(Nick Rout)
April 24, 2024, 9:24pm
2
So do you not see entity_picture in your media_player card?
The current album cover does appear in the Media Player, but it is small and truncated. I want to have a larger picture beside the media player.
nickrout
(Nick Rout)
April 25, 2024, 1:45am
4
Ok, well the url of the image is
http://YOURIP:8123{{state_attr('media_player.kitchen', 'entity_picture')}}
Naturally your media player entity id will be different.
I tried that with:
http://192.168.20.2:8123{{state_attr('media_player.ytube_music_player','entity_picture')}}
I also tested with entity_picture_local , because that seemed more like a local URL vs. the one hosted on the google site.
And unfortunately, it did not work.
Is there a way to test these expressions to see the results?
I need to learn so much more about HA, but it is so flexible, it makes it difficult. I’m almost 70. My friends play Suduko to exercise their minds. I play Home Assistant and Smart Home.
My house has 140+ devices hooked to the router, plus 65 hooked to Lutron, plus 15 on Zigbee. The airwaves are full.
nickrout
(Nick Rout)
April 25, 2024, 10:50am
6
Place that string in developer tools.
Copy the resulting string into your browser.
nickrout
(Nick Rout)
April 25, 2024, 10:55am
7
I think your quoting may be wrong.
{{state_attr('media_player.ytube_music_player','entity_picture')}}
Wow! I just learned something. Thank you.
I was not sure where in Developer Tools, but then it was obvious - in the Template Editor.
It returned the path for both entity_picture and for entity_picture_local.
Unfortunately, it seems that you cannot past the {{state_attr()}} string into the Image Path fields in any of the 3 different picture cards. Is there a way you can make a path that the picture cards will accept?
nickrout
(Nick Rout)
April 26, 2024, 3:58am
10
I think I have figured it out.
Make a template image with the template that gets the correct image. In my case it was
template:
image:
- url: http://myip:8123{{state_attr('media_player.kitchen', 'entity_picture')}}
name: mediapic
verify_ssl: false
after restart you will have an entity image.mediapic. Put that into a picture card.
Unfortunately, it is not quite working.
This template code, when added to configuration.yaml, creates an image entity called image.mediapic.
When I examine the entity in Developer Tools → States it appears to contain the local path to the image under /api/…
But, no image is displayed in a Picture Card, even though the Image field offers image.mediapic as the only option available.
I got it to work. I used
template:
image:
- url: http://myip:8123{{state_attr('media_player.kitchen', 'entity_picture')}}
name: mediapic
verify_ssl: false
I changed entity_picture to entity_picture_local .
Thank you!
nickrout
(Nick Rout)
April 29, 2024, 7:51pm
13
Yes I think that is a difference between media player integrations.