Prompting for input in a script

There’s probably a really obvious way to do this, but I haven’t figured it out yet…

I’d like to set up a script that will take a short input string from the user and use that to set a value in the script. Ideally, the user would trigger the script with a button from a control panel and the script would use the custom text. I found the ‘input_text’ integration, but I’m not quite seeing how to tie everything together. Any pointers would be appreciated.

Thanks!

I am not familiar with a “pop-up” option in HA. Having that said, I don’t think this is how scripts are intended to be used.

What I’d suggest is having your ‘input box’ in the HA GUI where you enter a string and afterwards click the button to execute the script or automation. I’d by the way use an automation so you can also use for example a sentence. Especially since v2023.08 supports wild cards, you can have a spoken text as the input text.

Edit: Added link to the specific release note

Thanks, yes I was thinking I would just add a dashboard view that contains a button and an input box. When the button is pressed, it would run a script that would grab the current text from the input box. However, I don’t see a card or entity type that I could add to the view that allows user input as text. Any pointers would be appreciated.

I figured out the UI part of this! Previously I was using the ‘Entity’ card, which only displays the current value of the input controls, rather than allow the user to change the value. When I switched to the ‘Entities’ card, this is exactly what I wanted:

Now I’m on to using the value of the inputs in my script and am running into issues there. I’ll create a separate topic to relay that issue. Thanks!

1 Like

Following. Would be great to hear your findings on using these values in a script once you figure this out.

My combination of media player / Plex / Chromecast audio offers very rudimentary functionality in HA, so I’ve been sporadically hacking away at building my own “Player” card like your entities card above. But with input helper dropdowns for speaker names and playlist names and a input button that triggers an automation that plays the specified playlist on the specified speakers. Hacking away but no joy so far. I can trigger the automation via the button but having trouble getting the values out of the input helpers.

Could you post additional details or link(s) to other related posts?

Here’s the related post on how to pull the values from the input helpers: