Input_select state as variable in script

Hi
I’m trying to make a input select where I can choose my google home speaker and then use that as a variable to play a playlist on spotify. However, my syntax/code doesn’t seem to be ok, as it keeps telling me:

Could not find device with name {{ states('input_select.chromecast_radio') }}

this is my code:

play_playlist_test:
  alias: Play a Spotify track on Chromecast
  sequence:
  - data:
      device_name:  {{ states('input_select.chromecast_radio') }}
      uri: spotify:playlist:4uiuEkTCXHAlDwE0vZqEeR
    service: spotcast.start

thanks!

  - data_template:
      device_name:  "{{ states('input_select.chromecast_radio') }}"
1 Like

Works like a charm, you’re my hero of the day :smiley:

Hi I’m trying to use that to send my shark vacuum to clean a specific room, sending a command to alexa. I was successful creating a script for each room, but I’m wondering if I can use the list of rooms I created to trigger the automation. Here is how my script looks like:

clean_room:
  sequence:
    - service: media_player.play_media
      data:
        media_content_type: custom
        media_content_id: ask shark to clean the "{{ states('input_select.room') }}"
      target:
        entity_id: media_player.echo_kitchen
  mode: restart
  alias: Clean Room

Thank you

make an automation. Use input_select.room as the state trigger.

- alias: Vacuum room changer
  trigger:
  - platform: state
    entity_id: input_select.room
  action:
    - service: media_player.play_media
      data:
        media_content_type: custom
        media_content_id: ask shark to clean the "{{ trigger.to_state.state }}"
      target:
        entity_id: media_player.echo_kitchen

Thank you… I’ll try this, it will probably keep it simpler… I actually chose to go with the script because for some reason, the Alexa shark skill keeps asking “which robot?” even if I only have one. So I added a delay and sent alexa another msg with the robot name. I’ll try your way.

Hey @tom_l
I know its an old post, but liked the input_select state given here.
I came across this post in search of trying to get google home assistant to give me a device select for speakers… i.e. "Hey G… Play plex playlist xx ", her response “what device would you like to play it on”.
I have it working via a HA script that’s exposed to google, but I can only pick target devices, not a variable select. can say “Hey G, play Plex 80s Music” but with no choice of speaker variable.
Is that possible? Either google or HA with Nabu or google script editor.
Speakers are google puck minis.
Would be really cool if I could voice a playlist and have a input select that google recognizes for me to choose.

been searching for a few hours now. could be oblivious to what’s available in UIs

Thanks!