Curl question

So been playing around with HA today and got most things working but this…

Situation sending a curl to turn on or off a switch

If i use it like the document tells me to do with this ccommand

curl -v -X POST -H “Content-Type: application/json” -d ‘{“entity_id”: “zwave.telldus_tzwp100_plugin_switch_4”}’ http://192.168.1.15:8123/api/services/switch/turn_on

Nothing happens

if i run this command

curl -v -X POST -H -d ‘{“entity_id”: “zwave.telldus_tzwp100_plugin_switch_4”}’ http://192.168.1.15:8123/api/services/switch/turn_on

it turns on the switch however it turns on ALL zwave switches

why does the first one not work and why do the second one turn on all switches ?

Because “zwave.xxx” is not a switch. It’s the zwave entity associated with the switch. You need to figure out what the name of the “switch.xxx” entity is.

Probably the second one “works” because -H requires a parameter, which is probably sucking up the -d. The data (in quotes) is probably being interpreted (by curl) as another URL, but it’s ignoring it because it’s not correct. The end result is you’re calling the service without specifying an entity_id, which means operate on all the entities in that domain (i.e., switch.)

1 Like

That entity is what i used in the automations and that turns on the single zwave switch?

Just realized how simple the answer was to my question its
curl -X POST -H “Content-Type: application/json”
-d ‘{“entity_id”: “switch.telldus_tzwp100_plugin_switch_switch”}’
http://192.168.1.15:8123/api/services/switch/turn_off

DOH!

Yes, that’s exactly what I meant. If you use the switch.turn_on service, it needs to be used with a switch entity. Glad you got it working!