Call parameterized script via a dialog form requesting values for fields

I have a couple of scripts that take fields as parameters and I’m looking for an easy way to invoke them. Ideally, I think it would be nice to have a widget/shortcut on my phone that would open a “form” ready to invoke the service, and ask values for the fields (potentially, would be nice that i could configure a distinct shortcut for a set of pre-filled items, so that if 1 of my “fields” is the media player I wanna play music on, I can have a shortcut directly for my Living Room and another for Bedroom).

Currently, I’m using Developer Tools > Service to get this behaviour, but it’s cumbersome and not easy to create shortcuts.

If such feature already exists, please let me know!

i’m not sure exactly what you’re looking for. perhaps if you sketched your ideal cx, it may help. however if you want an arbitrary form, you could serve up an html page that collected a form, then submitted a post back to ha. you can catch that post with an automation webhook trigger. a warning to be careful about security however… be careful how publicly you expose these access points and limit what it can do.

to serve up external dirs, look at allowlist_external_dirs. this serves up pages on http://homeassistant.local:8123/local/… you can put an html page there that posts to an automation webhook.

So, have you tried script blueprints?
They could be set-up kinda like you describe. Plug in the variables. Can use fields in tandem or separately.

It would be the same kind of form you get in the Developer Tools:


This is called “call service”, and I’m proposing a “call a script” UI.

Blueprints are just templates afaik. Which means, for each different combination of fields as inputs, I would need to create a new Automation from it. Suppose you wanna play white noise in a speaker like my pic above, but you wanna accept the volume as a parameter as well, and maybe select from a list of possible music (water, thunder, nature). A form to trigger it would let me choose during execution, instead of having me saving all possible combinations.

So you might be wondering:

why does this Developer Tools> Service doesn’t work for you?

Well, it does. The problem is getting the proper info. I need to:

  1. Launch the app
  2. Hit the hamburguer menu
  3. Select Developer Tools
  4. Select Services
  5. Type in the name of my script
  6. Fill any inputs I have

Ideally, these would all come from a “pre-filled” shortcut to this (or a similar) form. Similar to how you can create pre-filled link on Google Forms.

Again going back to the White Noise example, I should be able to click 1 thing, get a form where I select the speaker, and hit “call”.

I’m assuming there would be a limited number of choices here that could be put into a select statement possibly, pick from the list. That would work with a script or a blueprint.

I had something similar with a select helper showing in the dashboard. My daughter had a house alert, she would select from about 10 statements in the list and whatever she selected would play on speakers. There were 3 select lists in the card, ons whole house, one that excluded the bedroom when I was up and Mom was asleep, and one that hit the phones with a text if we were outside.

Also consider building an intent_script and just tell HA what you want to do with what device.

Just brainstorming here with things you may not have considered.

I don’t believe there is a construct exactly like you are requesting in HA, and adding something like that is a hard sell with the core group. Finding a suitable workaround in the short term at least would be a smart move.

you can skip steps 1-4 using a direct link: http://homeassistant.local:8123/developer-tools/service

and if the choices are constrained what i said above would work. you could build a super simple web form with prefilled defaults and send a post to a webhook triggered automation which then calls your custom script with the params.

I don’t know how old this is, but I just realized that on the scripts list, if I select one and I hit “Run”, I get the following error:

However, if I open the script and select Run Script, I get the exact type of form I have in mind:

So it seems that (1) there’s a bug on the list of scripts, and (2) I would just need a way to get a shortcut/direct link to this type of form, rather than clicking many screens to get there.

if you’ve update to this month’s release that just came out hours ago pops up that dialog when you try to invoke your script and it has required fields. so with the 2024.3.0 release, go put that script in the dashboard and give it a go.

I totally missed that on the release notes, thanks! Anyone coming here later: 2024.3: Drag 'n Drop it like it's hot! 🎉 - Home Assistant

@armedad is it just me or did this break in 2024.4.0?

hmmm… not to my knowledge