Hey All,
just a short background: I have multiple Chromecast Audio devices connected to speakers around the house and I have a di.fm subscription plus some radio stations that I would like to listen to. I’m looking for a convenient way to select what to play and where to play.
The plan is/was to create two input_selects and a single script that reads the entity_id and the media source from the two input selects and pushes those into a media_player.play_media service call.
This looks like the following in yaml:
the input_selects:
media_source:
name: Music Styles
initial: http://prem2.di.fm:80/chillout?
options:
- http://prem2.di.fm:80/chillout?
- http://prem2.di.fm:80/lounge?
- http://prem2.di.fm:80/chillntropicalhouse?
- http://prem2.di.fm:80/club?
- http://prem2.di.fm:80/deepnudisco?
- http://prem2.di.fm:80/liquidtrap?
- http://prem2.di.fm:80/undergroundtechno?
- http://79.172.212.151/chfm_en.mp3
- http://stream.musicfm.hu:8000/musicfm.mp3
- http://stream4.radio1.hu:8000/high.mp3
icon: mdi:headphones
media_players:
name: Speakers
initial: media_player.living_room_speaker
options:
- media_player.bedroom_speaker
- media_player.kitchen_speaker
- media_player.lg_tv_remote
- media_player.living_room_speaker
- media_player.office_speaker
- media_player.whole_flat
icon: mdi:speaker
The script:
'1536007986550':
alias: Play Music of Your Choice
sequence:
- data:
entity_id: '{{ states("input_select.media_players") }}'
media_content_id: '{{ states("input_select.media_source") }}'
media_content_type: mp3
service: media_player.play_media
and it looks really tidy in Lovelace as well
Sounds good so far isn’t it?
Well the only problem is that every time I run the script it logs an error:
Invalid service data for media_player.play_media: Entity ID {{ states("input_select.media_players") }} is an invalid entity id for dictionary value @ data['entity_id']. Got '{{ states("input_select.media_players") }}'
This can mean two things:
- the templates in the script parameters are not supported
- I’m making a mistake somewhere
Have you ever tried templates in scripts? is it supported?
Could you please check my yaml snippets to see what could be the problem?
Thanks in advance!
B