igorspro
(Igorspro)
October 13, 2025, 8:05am
1
Hi!
I am looking to create YAML script to play sonos radio. This script is not working. Can you help me to fix it please?
sequence:
play_sonos_radio:
alias: “Play Sonos Radio Station”
sequence:
- service: media_player.volume_set
target:
entity_id: media_player.saundbar # Your Sonos entity ID
data:
volume_level: 0.3 # Volume (0.0 to 1.0, e.g., 0.3 = 30%)
- service: media_player.play_media
target:
entity_id: media_player.saundbar # Sonos entity ID
data:
media_content_type: favorite_item_id
media_content_id: “FV:2/31” # Your radio station ID
mode: single
zoogara
(Daryl)
October 13, 2025, 8:20am
2
Hi, because yaml is very indentation dependant, you need to edit your post to enclose the yaml in code tags. They are accessed by the </> button on the posting toolbar.
It should then look something like:
sequence: play_sonos_radio:
alias: “Play Sonos Radio Station”
etc...
What is the error you get?
igorspro
(Igorspro)
October 13, 2025, 2:08pm
4
Message malformed: extra keys not allowed @ data[‘play_sonos_radio’]
@PeteRage
igorspro
(Igorspro)
October 13, 2025, 2:39pm
5
Solved it, thanks. Here is a script someone might want:
alias: Play Sonos Radio Station
sequence:
target:
entity_id: media_player.saundbar
data:
volume_level: 0.1
action: media_player.volume_set
target:
entity_id: media_player.saundbar_obiazatelnyi
data:
media:
media_content_id: FV:2/11
media_content_type: favorite_item_id
metadata: {}
action: media_player.play_media
mode: single
description: “”