Running script from your dashboard with user input

Hi,

I’m not sure if I’m in the correct category, sorry if I missed it.

There is this section in the release notes of 2024.3:
Running script from your dashboard with user input

I would like to implement a similar config. I found no detailed walk-through, nor other information apart from the video (not very helpful) and the sample blueprints.
Can someone please explain to me how this works, how can I make a similar button on my dashboard like in the video?

I created a blueprint based on the samples, that looks good, but I cannot make a script out of it, or place a button which calls this blueprint (I suspect a blueprint cannot be called, but who knows, I’m out of ideas.)

When I true to create a script on the UI from my blueprint it expects me to fill in the inputs which defeats the whole purpose that I can provide them on the fly when I need it.

Thanks in advance for the help!

Cheers!

Post the blueprint… it sounds like you may have configured things that should be fields in the input section. Inputs are set when the blueprint is used to create a script. The script contains additional fields that can now be supplied with a value from the dashboard.

In the examples the blueprint itself is not being called, the script is.

Here it is. I tried to change things a bit based on what you wrote, but seems to be the same issue. (The commented part is the original stuff I had instead on the fields.)

blueprint:
  name: Manual watering
  description: Start watering manually
  domain: script
  # input:
  #   sprinkler:
  #     selector:
  #       entity:
  #         include_entities:
  #           - switch.locsolo1
  #           - switch.locsolo2
  #           - switch.locsolo3
  #     name: sprinkler
  #   duration:
  #     selector:
  #       duration:
  #         enable_day: false
  #     name: duration

mode: queued

fields:
  sprinkler:
    selector:
      entity:
        include_entities:
          - switch.locsolo1
          - switch.locsolo2
          - switch.locsolo3
    name: sprinkler
    required: true
  duration:
    selector:
      duration:
        enable_day: false
    name: duration
    required: true

sequence:
  - service: switch.turn_on
    target: 
      entity_id: "{{ sprinkler }}"
  - delay:
    minutes: "{{ duration }}"
  - service: switch.turn_off
    target: 
      entity_id: "{{ sprinkler }}"

You need to fix the delay, but other than that it looks fine and works as expected on my instance:

...
sequence:
  - service: switch.turn_on
    target: 
      entity_id: "{{ sprinkler }}"
  - delay: 
      hours: "{{ duration.hours }}" 
      minutes: "{{ duration.minutes }}"
  - service: switch.turn_off
    target: 
      entity_id: "{{ sprinkler }}"

Just FYI, you don’t need to use a Blueprint to get the UI control, it is available for standard scripts as well. You only need a Blueprint if your goal is to create multiple similar scripts. In that case you likely want to use an input to allow you to select the entities that are available to each script. An example of that would be as follows:

Blueprint Example
blueprint:
  name: On-Off with duration
  description: Turn an switch on, wait, turn it off
  domain: script
  input:
    allowed_switches:
      selector:
        entity:
          filter:
            domain: switch
          multiple: true
      name: Allowed Switches

mode: queued

fields:
  switch:
    selector:
      entity:
        multiple: true
        include_entities: !input allowed_switches
    name: Switch
    required: true
  duration:
    selector:
      duration:
        enable_day: false
    name: Duration
    required: true

sequence:
  - service: switch.turn_on
    target: 
      entity_id: "{{ switch }}"
  - delay:
      hours: "{{ duration.hours }}" 
      minutes: "{{ duration.minutes }}"
  - service: switch.turn_off
    target: 
      entity_id: "{{ switch }}"

I wanted to ask if I need the blueprint, thanks.

I was able to run the script from the Developer tools/services page, but not from the dashboard. What kind of card did you use?

1 Like

Entity, Entities, and Tile cards all work. I haven’t test any others.

Something was wrong with my script, so putting it on a card haven’t worked as expected. But I added my script again from the UI, then it started to work as expected.

Thanks for your help! I really appreciate it.

1 Like