Media player script

Hi,
I’m trying to make a script which will send a media source to a chromecast. I have previously used the same service and data in a automation where it works perfectly, but when I tried to put the same lines into a script it just creates errors and does not work. Could anybody see a obvious problem with the code below?

radioON:
  sequence:
    - service: media_player.play_media
      data:
        entity_id: media_player.kjkken
        media_content_id: http://lyd.nrk.no/nrk_radio_p3_mp3_h
        media_content_type: audio/mp3

You may need to put your URL in quotes:
media_content_id: 'http://lyd.nrk.no/nrk_radio_p3_mp3_h'

Also I use mp4 for my radio streams:
media_content_type: 'audio/mp4'
What does your log say?

kjkken or kjokken ?

Thanks for the quick answers
@lolouk44 Ok, that’s good input, I will try that. But is there any reason why that was not a problem when it was put into an automation? I do not have my system available now, but I will share the log later today.

@bonterra good question, but kjkken is correct. The chrome name is Kjøkken, so I guess HA removed the norwegian letter.

Ha! I don’t speak Norwegian :smiley:
Not sure why it would work in an automation and not in a script. but my script has the quotes and in the past mp3 would stop it from working whereas mp4 did work.
might be an idea to name your kitchen kjokken without special characters at least for entity_id names?

Strange, when I use Swedish letters they are replaced rather than omitted (åäö becomes aao)

automation.slack_lampor_en_timme_efter_soluppgang (Släck lampor en timme efter soluppgång = Turn off lights one hour after sunrise)

@lolouk44
This is from the log:

Invalid config for [script]: [radioON] is an invalid option for [script]. Check: script->script->radioON. (See /home/homeassistant/.homeassistant/configuration.yaml, line 451). Please check the docs at https://home-assistant.io/components/script/

However I managed to get it to work! To me it looks like it does not accept capital letters in the script name. I.e. “radioON” will not work, but “radioon” will work. I did not now it was case sensitive.

ahh good spot.
Generally yes it’s best / good practice to name all entities, automations, etc in lowercase. Only use Uppercase and Special characters for the front end