Hi All,
Is it possible to pass variables from HADashboard to a script?
I tried using the args in HADashboard and then reference them as variables with {{}} int he script, but couldn’t get it to work. I have a generic script that plays music based on the source passed in as a variable. I wanted to have multiple buttons with difference sources set as args in HADashboard.
Here is my code, but doesn’t seem to work, is it even possible?;
My script:
music_player:
alias: Music Player
sequence:
- service: media_player.sonos_join
data_template:
master: media_player.upstairs
entity_id: media_player.kitchen
- service: media_player.select_source
data_template:
entity_id: media_player.upstairs
source: "{{ play }}"
- service: media_player.volume_set
data_template:
entity_id:
- media_player.upstairs
volume_level: 0.5
- service: media_player.volume_set
data_template:
entity_id:
- media_player.kitchen
volume_level: 0.5
- service: media_player.turn_on
entity_id: media_player.upstairs
My HADashboard widget;
play_mowtown:
widget_type: script
title: Mowtown
icon_off: mdi-music
icon_on: mdi-music-off
entity: script.music_player
args:
play: "Mowtown"
I’m not seeing any errors in any log files, what actually happens is that SONOS plays the last item it already has loaded, so it’s as if the variable isn’t get populated.
Any thoughts?
Sam