Passing variables from HA Dashboard (appdaemon)

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

Anyone know this can be done?

no that wont work.
you need to create a script for all seperate music, or an input select with the choices and then an automation connected to it, or switches or input booleans that trigger your script

HAdasboard is just another way to view what you already have in home assistant, not something to use to take automations or scripts out of home assistant.

all widgets and the arguments you can use can be found in the docs:
https://appdaemon.readthedocs.io/en/latest/DASHBOARD_CREATION.html#widget-reference