Change media.png accordingly for Denon mediaplayer

Hey!
I have an expert question. I’m using these elements to stream audio to my denon:

Helper input select:

Automation, which reacts to what choose in my dropdownlist to stream:

alias: Denon audiostream automation
description: Denon play audiostream script
trigger:
  - platform: state
    entity_id:
      - input_select.denon_audiostream
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_select.denon_audiostream
            state: KinkFM
        sequence:
          - service: script.denon_speel_radiostream
            data:
              radio_station: KinkFM
              radio_stream: http://22593.live.streamtheworld.com/KINK.mp3
      - conditions:
          - condition: state
            entity_id: input_select.denon_audiostream
            state: Radio2
        sequence:
          - service: script.denon_speel_radiostream
            data:
              radio_station: Radio2
              radio_stream: aac://http://icecast.omroep.nl/radio2-bb-aac
      - conditions:
          - condition: state
            entity_id: input_select.denon_audiostream
            state: PinguinRadio
        sequence:
          - service: script.denon_speel_radiostream
            data:
              radio_station: PinguinRadio
              radio_stream: http://streams.pinguinradio.com/PinguinRadio320.mp3
      - conditions:
          - condition: state
            entity_id: input_select.denon_audiostream
            state: SLAMfm!
        sequence:
          - service: script.denon_speel_radiostream
            data:
              radio_station: SLAMfm!
              radio_stream: >-
                aac://https://25643.live.streamtheworld.com/SLAM_AAC_SC?dist=TUNEIN
      - conditions:
          - condition: state
            entity_id: input_select.denon_audiostream
            state: Sublime
        sequence:
          - service: script.denon_speel_radiostream
            data:
              radio_station: Sublime
              radio_stream: https://22723.live.streamtheworld.com/SUBLIME.mp3
      - conditions:
          - condition: state
            entity_id: input_select.denon_audiostream
            state: TV
        sequence:
          - service: media_player.select_source
            target:
              entity_id: media_player.denon_avr
            data:
              source: TV
      - conditions:
          - condition: state
            entity_id: input_select.denon_audiostream
            state: Game
        sequence:
          - service: media_player.select_source
            target:
              entity_id: media_player.denon_avr
            data:
              source: GAME1
      - conditions:
          - condition: state
            entity_id: input_select.denon_audiostream
            state: Blu-ray
        sequence:
          - service: media_player.select_source
            target:
              entity_id: media_player.denon_avr
            data:
              source: BD
mode: single

An automation resetter for my input list.

alias: Denon audiostreamlist reset helper.
description: Helper auto reset remote input zodat deze niet blijft staan
trigger:
  - alias: Wanneer input select device veranderd
    entity_id:
      - input_select.denon_audiostream
    platform: state
condition: []
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - alias: Zet terug op kies stand
    data:
      option: Kies
    service: input_select.select_option
    target:
      entity_id:
        - input_select.denon_audiostream
mode: restart

And the script to actually start the stream:

alias: Denon speel radiostream (automation)
sequence:
  - service: denonavr.get_command
    target:
      entity_id: media_player.denon_avr
    data:
      command: /goform/formiPhoneAppDirect.xml?Z2QUICK4 MEMORY
  - service: media_player.play_media
    target:
      entity_id: media_player.denon_dn_500av
    data_template:
      media_content_type: music
      media_content_id: "{{ radio_stream }}"
      extra:
        title: "{{ radio_station }}"
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
    enabled: true
mode: single
icon: mdi:radio
description: Denon speel radiostream (dropdown)

Now here is my question. I’d like to add to this specific part of the script:

  extra:
    title: "{{ radio_station }}"
    thumb: "/local/{{ radio_station }}.png"

So the thumnail also sets to the radiostation in the mediaplayer card. For example PinguinRadio.png

But it doesn’t work. Is this even possible to use a boolean like {{ radio_station }} to point to the file name of my .png
I’ve created the artwork with the same names as dropdownlist and placed it the www folder accordingly.

Boolean means two possible states.
Typically false/ true, but yes/no, open/close 0/1 or even 0/any other value.

If it is a boolean, then it does not make sense to use it like you do, but it could just be because you misunderstood the meaning of boolean and it is in fact another type of variable.

If it is a string then it makes sense, but sometimes line breaks can mess things up, so try to use {{- and -}} instead.
The minus will remove extra line break before or after respectively.
Alsobtry to remove the space inside the {{ and }}, because if it is inserted in your line, then it will break you url.

When working with paths, then be aware that the local path might be different from the path on the web service.
Check if you can open the path in a browser.

Sorry I mean string. I’ll try, thanks!

No does not work, does not set the background of the mediaplayer:
thumb: “/local/{{radio_station}}.png”
thumb: “/local/{{-radio_station-}}.png”

When testing http://192.168.66.6:8123/local/PinguinRadio.png it seems accesable.

thumb: /local/PinguinRadio.png also doesn’t work, so maybe I need to re-dig in the mediaplayer documentation how to set the background of the card.

Tried from the documentation ( Media player - Home Assistant )

thumb: "https://brands.home-assistant.io/_/homeassistant/logo.png"

and the mediaplayer background doesn’t change. So i’m puzzeled now why I can’t set the mediaplayer background card at all…

I see what you are trying to do now and it does not work that way.
Your extra: section is added to the script and not to the media_player entity.
The script do not know what to do with the extra: section, so it probably just ignores it.
I do not think HA have a default option to add attributes to an existing entity, other than through service calls.
There might be third party integrations that can do this, but HA might fight it in this case, because HA will regularly update the attributes that the media_player integration controls, so every 30 seconds or so it will detect a no picture attribue and set that and you will then have to set it back again to a picture.

Oke. I followed this “official” example also:

service: media_player.play_media
target:
  entity_id: media_player.chromecast
data:
  media_content_type: music
  media_content_id: "https://fake-home-assistant.io.stream/aac"
  extra:
    thumb: "https://brands.home-assistant.io/_/homeassistant/logo.png"
    title: HomeAssistantRadio

Replaced it with my code:

service: media_player.play_media
target:
  entity_id: media_player.denon_dn_500av
data:
  media_content_type: music
  media_content_id: http://streams.pinguinradio.com/PinguinRadio320.mp3
  extra:
    thumb: "https://brands.home-assistant.io/_/homeassistant/logo.png"
    title: PinguinRadio

In the HA services developer tool. Does not display the picture in the mediaplayer background. So this suggest an error in HA core right and I should open an issue? Or am I wrong?

Well, it could be a bug or it could be that your media_player provide the attribute itself, even though it is actually set to nothing/None.
I guess this is something someone else, like the devs, will have to answer, because I have not looked into the media_player code. :slight_smile: