Toggle a Swirtch via REST API

it is possible to toggle a Switch Item via rest API?

Many Thanks

Yes. See wiki.
Sample to switch ON MyLight.
curl --header 'Content-Type: text/plain' --request POST --data 'ON' 'http://openHAB_IP:8080/rest/items/MyLight'

I am not aware of a way to TOGGLE the switch directly, you should first read the state of it and then send an opposite command.

Hi @JjS
I know how turn on and off. I need a way to toggle, without read status before.


I set up proxy item that receives the REST command which triggers a rule to toggle the “real” switch.

In short, yes you can…

In practice, the TOGGLE command does not work for all bindings I’ve gathered from postings in the forum, so I was hesitant to recommend it.

I was under the impression the REST service would interrogate the items current value and send the appropriate ON/OFF command when you called TOGGLE. I could be mistaken however.

REST API work with command TOGGLE and it’s fully supported.
Many thanks

In openHAB 1.x, the CmdServlet accepts URLs like http://openhabserver:8080/CMD?MySwitchItem=TOGGLE, but I see no evidence that the REST API actually supports TOGGLE in any way. @marcolino7, could you elaborate?

Hi @watou TOGGLE work with REST API, I did test last night. If i sent TOGGLE instead ON or OFF, the switch will toggle its status


Ah, I now see it has since been added. Thanks very much.