Rest PUT not working in OH2

I’m trying to use ResTask plugin to Tasker to set the state of an item. I was using /CMD in OH1 but it’s not there in OH2, I’m therefore trying to use the REST api to do the same.

It seems a PUT request to /rest/items/MyItem/state works (returns HTTP 202) however although it updates the state on the rest API, It does not actually control / send a command to the underlying item (a switch).

Also, TOGGLE, which seems to have been added to OH1, does not work in OH2, it gives 400 error.

EDIT: I’m using IFTTT and My.Openhab as a workaround, but it would be nice to do it locally

This is part of the Classic UI and still exists in OH2 as well. But it was never meant as an API for external integration, the REST API is indeed the way to go.

It does not actually control / send a command

You can find the docs here: https://www.eclipse.org/smarthome/rest/index.html
PUT does on MyItem/state does a status update, POST on MyItem sends a command.

TOGGLE, which seems to have been added to OH1

Toggle is no valid command, the CMD servlet only used that as a convenience function.

1 Like