Log file shows error on service call for switch

Hi, having some trouble when I make the following call with curl to a service:

curl -X POST -H "x-ha-access: <mypassword>" -H "Content-Type: application/json" 

-d '{"entity_id": "switch.living_room_lamp_2","state": "on"}'<mypassword>

The following error shows up in the log files:

Invalid service data for switch.turn_on: extra keys not allowed @ data['state']. Got 'on'

Any ideas? Much appreciated.

I’ve done a little research and it appears that the error message is saying that I’m trying to send an extra dictionary key in my data for the “state” collection.

Should it be

“state”: “on”


“state: on”?

Hey, I ended up using the following and it worked:
curl -X POST -H "x-ha-access: <myPassword>" -H "Content-Type: application/json" -d '{"entity_id": "switch.living_room_lamp_2"}'<myPassword>

Somewhere in the documentation I got the notion that I needed to pass the “state” property. I found another example where I did not. Once I got the curl request working I was also able to post via Tasker with this JSON. Thanks for the help!

1 Like