Assigning a picture to music send to a ChromeCast

I have followed the excellent script from @Bob_NL
All works fine, I would just like to assign/set the title, as per the bottom entries:

radio:
  alias: Cast Selected Radio on Chromecast Speakers
  sequence:
    - service: media_player.volume_set
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom
          {% elif is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen
          {% elif is_state("input_select.chromecast_radio", "Onkyo") %} media_player.onkyo_txnr656_e0ee71
          {% elif is_state("input_select.chromecast_radio", "Downstairs") %} media_player.downstairs
          {% elif is_state("input_select.chromecast_radio", "House") %} media_player.house
          {% endif %}
        volume_level: '{{  states.input_number.volume_radio.state  }}' 
    -  service: media_player.play_media
       data_template:
         entity_id: >
          {% if is_state("input_select.chromecast_radio", "Downstairs") %} media_player.downstairs
          {% elif is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen
          {% elif is_state("input_select.chromecast_radio", "Onkyo") %} media_player.onkyo_txnr656_e0ee71
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom
          {% elif is_state("input_select.chromecast_radio", "House") %} media_player.house
          {% endif %}
         media_content_id: >
          {% if is_state("input_select.radio_station", "RTL2") %} http://streaming.radio.rtl2.fr:80/rtl2-1-44-96
          {% elif is_state("input_select.radio_station", "Absolute Radio") %} http://icy-e-bab-04-cr.sharp-stream.com/absoluteradio.mp3
          {% elif is_state("input_select.radio_station", "Absolute Radio Classic Rock") %} http://icy-e-bab-04-cr.sharp-stream.com/absoluteclassicrock.mp3
          {% elif is_state("input_select.radio_station", "Hit West") %} http://broadcast.infomaniak.ch/hitwest-high.mp3
          {% elif is_state("input_select.radio_station", "Chill") %} http://media-the.musicradio.com/ChillMP3
          {% elif is_state("input_select.radio_station", "Custom Station") %} {{states.input_text.custom_station.state}}
          {% endif %}
         media_content_type: 'audio/mp4'
         media_title: >
          {{states.input_select.radio_station.state}}
         entity_picture: >
          {% if is_state("input_select.radio_station", "RTL2") %} https://HA_URL/local/RTL2.jpg
          {% elif is_state("input_select.radio_station", "Absolute Radio") %} https://HA_URL/local/Absolute_Radio.jpg
          {% elif is_state("input_select.radio_station", "Absolute Radio Classic Rock") %} https://HA_URL/local/Absolute_Radio_Classic_Rock.jpg
          {% elif is_state("input_select.radio_station", "Hit West") %} https://HA_URL/local/Hitwest.png
          {% elif is_state("input_select.radio_station", "Chill") %} https://HA_URL/local/Chill.jpg
          {% elif is_state("input_select.radio_station", "Custom Station") %} https://HA_URL/local/Radio.png
          {% endif %}

but I get this error message:

2018-01-20 22:10:27 ERROR (MainThread) [homeassistant.core] Invalid service data for media_player.play_media: extra keys not allowed @ data['entity_picture']. Got 'https://HA_URL/local/RTL2.jpg'
extra keys not allowed @ data['media_title']. Got 'RTL2'

Any idea how I could assign the media title and entity_picture?

Hello,

Did you get this to work?

yes, though it required using a separate python script as the service: media_player.play_media does not accept a picture sent as a parameter.
The end result/script is described here:

1 Like