Can't Change State Using REST API

Does anyone know why I cannot change the state of a light? Here’s the code from command line along with the result:

[grayson@homeassistant .homeassistant]$ curl -X POST -d '{"state": "on"}' http://localhost:8123/api/states/light.bedroom_lamp_l { "attributes": {}, "entity_id": "light.bedroom_lamp_l", "last_changed": "16:24:02 16-04-2016", "last_updated": "16:24:02 16-04-2016", "state": "on" }

The light did not get turned on. What I can do is get the state from a light:

[grayson@homeassistant .homeassistant]$ curl -X GET http://localhost:8123/api/states/light.bedroom_lamp_l{ "attributes": { "friendly_name": "Bedroom Lamp L" }, "entity_id": "light.bedroom_lamp_l", "last_changed": "16:24:15 16-04-2016", "last_updated": "16:24:15 16-04-2016", "state": "off" }

There’s nothing wrong with my light. I can control the state of the light from within the Home Assistant frontend.

The reason why I want to do this is so I can control the devices if I decide to build a custom web page and even control states of devices by using Tasker in Android.

The state machine holds the representation of the light for Home Assistant. Updating the representation does not update the device that it represents. To do that, call the light.turn_on service.

1 Like

I would really be nice if we had a RESTful API method similar to light.turn_on that would go ahead and update the state. Seems a bit redundant in my case to have to fire off 2 RESTful calls.

EDIT: I was mistaken. If I call the method to turn off/on a device, the state DOES get updated.