I get the following everytime i try to cast a radio to my Chromecast Audio:
“Invalid service data for media_player.play_media: Entity ID media_content_id: > ‘http://icecast-qmusic.cdp.triple-it.nl/qmusic_nl_live_96.mp3’ media_content_type: ‘audio/mp3’ is an invalid entity id for dictionary value @ data[‘entity_id’]. Got “media_content_id: > ‘http://icecast-qmusic.cdp.triple-it.nl/Qmusic_nl_live_96.mp3’ media_content_type: ‘audio/mp3’”
required key not provided @ data[‘media_content_id’]. Got None
required key not provided @ data[‘media_content_type’]. Got None”
Where is the problem, and how to fix?
Can you show us the automation/script please?
(properly formatted in a code block)
radio_start:
alias: Play Radio on Chromecast Audio
sequence:
- service: media_player.volume_set
data_template:
entity_id: >
{% if is_state(“input_select.radio_speakers”, “Living Room Audio”) %} media_player.salotto_audio
{% elif is_state(“input_select.radio_speakers”, “Chromecast Salotto”) %} media_player.salotto
{% elif is_state(“input_select.radio_speakers”, “Chromecast Camera Letto”) %} media_player.camera_da_letto
{% elif is_state(“input_select.radio_speakers”, “Gruppo Media Player”) %} group.media_player
{% endif %}
volume_level: ‘{{ states.input_number.radio_volume.state | float }}’
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state(“input_select.radio_speakers”, “Living Room Audio”) %} media_player.salotto_audio
{% elif is_state(“input_select.radio_speakers”, “Chromecast Salotto”) %} media_player.salotto
{% elif is_state(“input_select.radio_speakers”, “Chromecast Camera Letto”) %} media_player.camera_da_letto
{% elif is_state(“input_select.radio_speakers”, “Gruppo Media Player”) %} group.media_player
{% endif %}
media_content_id: >
{% if is_state(“input_select.radio_station”, “Q-Music”) %} http://icecast-qmusic.cdp.triple-it.nl/Qmusic_nl_live_96.mp3
{% elif is_state(“input_select.radio_station”, “3FM”) %} http://icecast.omroep.nl/3fm-bb-mp3
{% elif is_state(“input_select.radio_station”, “100% NL”) %} http://stream.100p.nl/100pctnl.mp3
{% elif is_state(“input_select.radio_station”, “Veronica”) %} http://8543.live.streamtheworld.com/VERONICACMP3
{% elif is_state(“input_select.radio_station”, “Sky Radio”) %} http://19993.live.streamtheworld.com:80/SKYRADIO_SC6
{% elif is_state(“input_select.radio_station”, “Arrow Classic Rock”) %} http://91.221.151.155/listen.mp3
{% elif is_state(“input_select.radio_station”, “Classic FM”) %} http://19143.live.streamtheworld.com/CLASSICFM_SC
{% elif is_state(“input_select.radio_station”, “BNR Nieuwsradio”) %} http://icecast-bnr.cdp.triple-it.nl/bnr_mp3_96_03
{% elif is_state(“input_select.radio_station”, “SLAM! Hardstyle”) %} http://vip-icecast.538.lw.triple-it.nl/WEB17_MP3
{% elif is_state(“input_select.radio_station”, “Sleep Radio”) %} http://37.59.28.208:8453/stream
{% elif is_state(“input_select.radio_station”, “Ambient Sleeping Pill”) %} http://perseus.shoutca.st:8447/h
{% elif is_state(“input_select.radio_station”, “Radio Art - Sleep”) %} http://live.radioart.com/fSleep.mp3
{% elif is_state(“input_select.radio_station”, “Ambi Nature Radio”) %} http://94.23.252.14:8067/stream
{% elif is_state(“input_select.radio_station”, “Calm Radio - Sleep”) %} http://streams.calmradio.com/api/39/128/stream
{% elif is_state(“input_select.radio_station”, “Dinamo.FM Sleep”) %} http://channels.dinamo.fm/sleep-aac
{% elif is_state(“input_select.radio_station”, “Hot 108”) %} http://jbmedia-edge1.cdnstream.com:80/hot108
{% elif is_state(“input_select.radio_station”, “The Beat”) %} http://live.leanstream.co/CKBTFM-MP3
{% elif is_state(“input_select.radio_station”, “Alt Rock”) %} http://149.56.23.7:20254/stream
{% elif is_state(“input_select.radio_station”, “Energy 98”) %} http://174.127.85.10:8800
{% elif is_state(“input_select.radio_station”, “Hit Remixes”) %} http://149.56.23.7:20252/stream
{% elif is_state(“input_select.radio_station”, “Play Radio”) %} http://176.9.31.78:8222
{% elif is_state(“input_select.radio_station”, “Elium-Rock”) %} http://listen.radionomy.com/Elium-Rock
{% elif is_state(“input_select.radio_station”, “Classic Rock Florida”) %} http://listen.shoutcast.com/Classic-RockFlorida
{% endif %}
media_content_type: ‘audio/mp4’
radio_stop:
alias: Stop Radio on Chromecast
sequence:
- service: media_player.media_stop
data_template:
entity_id: >
{% if is_state(“input_select.radio_speakers”, “Living Room”) %} media_player.salotto_audio
{% elif is_state(“input_select.radio_speakers”, “Chromecast Salotto”) %} media_player.salotto
{% elif is_state(“input_select.radio_speakers”, “Chromecast Camera Letto”) %} media_player.camera_da_letto
{% elif is_state(“input_select.radio_speakers”, “Gruppo Media Player”) %} group.media_player
{% endif %}
radio_change_speakers:
alias: Change Radio Speakers
sequence:
- service: media_player.media_stop
data_template:
entity_id: >
{% if previous_speakers == “Living Room” %} media_player.salotto_audio
{% elif previous_speakers == “Chromecast Salotto” %} media_player.salotto
{% elif previous_speakers == “Chromecast Camera Letto” %} media_player.camera_da_letto
{% elif previous_speakers == “Gruppo Media Player” %} group.media_player
{% endif %}
- service: input_boolean.turn_off
entity_id: input_boolean.radio_play
The error states ‘http://icecast-qmusic.cdp.triple-it.nl/qmusic_nl_live_96.mp3’ but your script has ‘http://icecast-qmusic.cdp.triple-it.nl/Qmusic_nl_live_96.mp3’ (Uppercase Q for Qmusic)
I’m not sure if this is a bug or not but it sounds like HA is taking the lowercase version of your URL, and the URL with a lowercase Q doesn’t work.
Have you tried to enclose the URL in single or double quotes?
I think the lines media_content_id: >
and media_content_type
are indented too far, so homeassistant is reading them as part of the template for the media player, hard to tell on pastebin, but there should be an identical number of spaces to the left edge for each of the three keywords.
So @anon43302295 we meet again
This is a script from @Bob_NL (Chromecast Radio with station and player selection)
I’ve implemented it on my setup and it works, I don’t have as many stations, but I believe @Bob_NL does
@maurizio53 Can you try and remove some stations to test @anon43302295 suggestion?
I copied your code in Notepad++ and indentation appears ok…
Can’t tell who’s stalking whom
Also worth noting that the error message mentions ‘audio/mp3’ but in the example you pasted the reference is audio/mp4 - do you have another similar script somewhere? Might be that one causing the issue.
I did notice the mp3 bit but after checking the code I did see he had mp4 which is what is needed. are the error and code in sync?