core icon indicating copy to clipboard operation
core copied to clipboard

Plex pushing all playback data except cover image when casting on a Google cast device.

Open maxi1134 opened this issue 11 months ago • 6 comments

The problem

It seems like the Plex integration and the Cast integration are only working at 98%. In the sense that the cover image is never pushed to the cast player, while the rest of the data is. (Title, duration and so on )

What version of Home Assistant Core has the issue?

core-2024.3.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Plex, Cast

Link to integration documentation on our website

https://www.home-assistant.io/integrations/cast/, https://www.home-assistant.io/integrations/plex/

Diagnostics information

No response

Example YAML snippet

{% set ns = namespace( cast_entity = "media_player.office_wiim_speaker" ) %}
                {% if state_attr( ns.cast_entity, "entity_picture") and states( ns.cast_entity) != "off"  %}
                      {{ state_attr( ns.cast_entity, "entity_picture") }}
                {% else %}                   
                      {# Look for a media player playing the same media as the main speaker in order to extract the media image #}
                      {# Pull all non-off media players#}
                      {% set ns = namespace( entities = [], final_entities = [],cast_entity = "media_player.office_wiim_speaker"  )%}                      
                      {% for media_player in states.media_player %} 
                        {% if  media_player.state != "off" and media_player.state != "unavailable" and "template" not in media_player.entity_id%}
                          {% set entity = media_player.entity_id %}
                          {% set ns.entities = ns.entities + [entity] %}
                        {% endif %}                  
                      {% endfor %}  
                      {# /Pull all non-off media players#}
                      {# Look for a player with the same song playing and output the entity_picture #}
                      {% for entity in ns.entities %}                                
                          {% set media_title = state_attr( entity, "media_title") %}
                          {% set media_album_name = state_attr( entity, "media_album_name") %}
                          {% set media_album_artist = state_attr( entity, "media_album_artist") %}                          
                          {% set cast_media_title = state_attr( ns.cast_entity, "media_title") %}
                          {% set cast_media_album_name = state_attr( ns.cast_entity, "media_album_name") %}
                          {% set cast_media_album_artist = state_attr( ns.cast_entity, "media_album_artist") %}
                          {% if media_title is not none and media_album_name is not none and media_album_artist is not none and cast_media_title is not none and cast_media_album_name is not none and cast_media_album_artist is not none and (( media_title | string | length ) > 0 and ( media_title | string ) in cast_media_title) and (( media_album_name | string ) in cast_media_album_name) and (( media_album_artist | string ) in cast_media_album_artist) and (( state_attr(entity, 'entity_picture') )) %}
                              {{state_attr(entity, 'entity_picture')}}
                              {% break %}
                        {% endif %}
                      {% endfor %}  
                      {#/Look for a player with the same song playing and output the entity_picture #}                  
                      {# /Look for a media player playing the same media as the main speaker in order to extract the media image #}
                {% endif %}


I am currently using this to extract the image with a third party integration called "template media player"

Anything in the logs that might be useful for us?

No response

Additional information

https://community.home-assistant.io/t/chromecast-entity-picture-null-when-casting-from-plex/315658/6?u=maxi1134

Somebody here thinks this part of the code might be the culprit.

maxi1134 avatar Mar 09 '24 15:03 maxi1134