HTTP Post from tasker help

I am trying to get tasker to turn on a single light using an HTTP Post task.

My task settings are

Server:Port
http://xxx.xxx.x.xxx:8123/api/services/light/turn_on?api_password=MYPASSWORD

Data / File

{
    "entity_id": "light.kitchen"
}

User Agent

application/json

The task connects but it is turning on all the lights, not just light.kitchen. When fired from the services menu of HAss it works just fine. I’ve found a few similar threads but the ones with examples have used pictures that are now deleted and everything else I have found seems to suggest I’ve set it up correctly.

Any ideas where I’m going wrong?

I’m also using Tasker to pass info to HASS.

The only thing that jumps out at me is that in my setup, I have just the server part in “Server:Port”

http://xxx.xxx.x.xxx:8123

Then in my path, I have the rest:

/api/services/light/turn_on?api_password=MYPASSWORD

I’m using mine to rtrigger scripts. I’m not seeing any issues where it affects other scripts.

Thanks @ih8gates. I tried splitting it like that, mapping port 80 to 8123 and so on. All seem to connect and have the same result - every single light turns on. I might try changing from light/turn_on to homeassistant/turn_on but that will have to wait until I can deal with a million things all turning on at once.

What I’m actually trying to do is get around a presence tracking issues and set off a front door light when I get home in the dark, maybe I might borrow another one of your ideas and use an “enable first morning trigger” style input boolean to my presence activated lights.

That technique is nice because you can have lots of rules to turn that boolean on or off. It can simplify automations.

I just tested with light.turn_on and was able to turn on a single light. I do have the data all on one line:
{"entity_id": "light.kitchen"}

I just installed tasker on a new phone yesterday so maybe I’m missing some other bits, I’ll try restoring my previous tasker stuff and plugins and try again.

I tried many variations of the entity line including that one, the one above I’m using was copied directly from home assistant.

Nmap half works but I don’t want my lights going off and on all night each time my phone checks out so the boolean limiting it to a once off will work. On my old phone this wasn’t a problem, I suspect Nougat is saving battery by disconnecting.

Got it!

User Agent

application/json

is wrong.

User Agent should be blank and use Content Type field instead.

Content Type

application/json

3 Likes