I want to control things just by clicking some icons on my phone, and therefore not having to open the web page all the time. This is possible with the app “HTTP Shortcuts” for Android.
I’ve configured it as good as I can, but still nothing happens. I know that the HA gets the signal, because if I change my password in the get to a wrong password, HA notifies me that a faulty password has been used.
Also, HTTP Shortcuts says that the signal was delivered without any errors. But why doesn’t my light turn on then? Can you see any obvious reasons for that, based on the screenshot attached?
Awesome. A good tip: test everything in the services dev tool (bottons at bottom of sidebar) first - especially when you’re looking to use the REST API. It’ll save you lots of headaches.
Here’s a way to figure out the URL for any API call:
Open the services dev tab (icon at bottom of sidebar that looks like a remote control)
Hit F12 in your browser (or whatever turns on developer tools for your browser). Switch to the network tab of your browser’s developer tools.
Pick the service you want a URL for and enter the appropriate service data
(it’ll be in JSON format. A typical value is {“entity_id”:“switch.switchname”}
Press the “call service” button and watch for an entry to appear in your network tool below. In Chrome, if I click on the entry, it’ll display the full URL
In practice, you’ll need to remember a few things:
You’ll need to append (assuming you’ve set one up) the API password to that URL, so it’ll look like what’s in @Jojojo’s example: http://your_server/api/services/light/turn_on?api_password=your_passwd
You need to format this as a POST (URLs that you put in your address bar are GETs). Postman is a good tool for testing POSTs
The service data (that JSON code) gets passed as the body or data for your call. If you’re using IFTT with a service that doesn’t require data (like calling a scene directly rather than using scene.turn_on), you may need to pass empty JSON like: {}
With this system I need to understand JSON commands, a bit too much work.
Any other way to do it more easily? Like an app or something where you run the command and it gives you the URL?
I want just to use existing commands (for example a scene for Philips Hue) run it, copy the URL, paste the URL in Http shortcut, and have a simple button on my smartphone home doing the command
If you’re going to use the API for anything, understanding a bit of JSON is required. It maps to the same data you’d send to a service in HASS. The service page even gives you the possible arguments.
Just think of JSON as a list with attribute/value pairs. A semicolon splits the attribute/value pair, a comma splits multiple groups of attributes/values.
{
“attribute1”:“value1”,
“attribute2”:“value2”,
}
Hi, I’m glad to hear that you’ve got it working! It’s pretty neat to just click an icon on your homescreen rather than open home assistant just to turn a light on or off.
Sorry, but I don’t know the commands to control Philips Hue. But I’m sure you will find it on home assistants website!
Like I said - look at the network tab in your browser’s dev tools. Click on the entry in the network log and it’ll give the whole URL. You’ll have to append the ?api_password=xxx part.