Http request as action

I have a couple of homebrew devices that run http services that trigger events, mostly playing specific sounds in response to the contents of the http request. They (mostly) serve up web pages in response to the requests, but those are not important for what I’m trying to do - they can be ignored.

Is there a Home Assistant action which can be setup to fire an http:// GET request to a specific address:port/page when it’s triggered?

Perfect, thank you, working as expected.

1 Like

Followup: I’m thinking about writing a Qt app that exposes a web interface to trigger system calls - doing things like launching programs probably including xdotool to press keys for things like entering addresses, putting windows in full screen mode, etc.

The first use case would look like: this app launches at login in our home theater PC, then a Home Assistant automation can have the PC launch chrome, navigate to a webcam site and go fullscreen - when triggered.

Of course, it could also do many many other things, if you configure it to.

Has that type of solution already been well developed for the HA ecosystem?

It can be easily done insideout home assistant, using automation tools like NodeRed or n8n. There is a NodeRed Integration on HACS store. The communication can be done in both way, say you can use rest_command from home assistant to trigger the webhook on NodeRed or n8n. There is also webhook trigger on home assistant itself (e.g. curl -X POST -d 'key=value&key2=value2' https://your-home-assistant:8123/api/webhook/some_hook_id) which allow you to send data and trigger something in your hass instance.

You don’t need to drink the Node Red Kool-aid to do this. It can all be done within HA automations.

So, I’m looking in the opposite direction now - automations issuing http:// requests through the HA REST interface, said requests launching scripts on the receiving computer. I had a program pretty close to that already that I modified last night - now it runs on our HTPC and is getting scripts to “tune in our favorite channels” whether that’s a webcam on YouTube, or something from local cameras on VLC. I’ll polish that a little more and put it on github for anyone interested in a couple of days probably.

I’m just curious if there’s something like that (http request->script launcher) already developed and commonly in use? It’s got obvious security concerns, but within your local network, only running scripts you approve of, it can’t get too bad unless you let it.

And, here’s the Qt app source code: GitHub - MangoCats/Oliver: App to launch scripts from http GET or POST requests

Oliver is just a little web server which exposes scripts which you configure in a folder. When you GET or POST to an address corresponding to the script name, then Oliver launches the script via QProcess. I have a couple of sample scripts in there that I use on our media center PC, one closes vlc, kodi and chrome (the three apps we use most often on that PC) and the other launches chrome to show a webcam stream, using xdotool to press the “f” key to make it full screen 3 seconds after launching.

The fun part comes when you connect a hardware button and the single button press “changes the channel” on the PC. Of course you can also have “channels” to view your local camera streams, other webcams, and really launch or close any kind of program(s) on your computer.