Managing items with curl


i have an openhab setup which works very fine with KNX and I would like to integrate some scenario with my smartphone events with macrodroid, in order to do this i tested the management of my items with curl :

retrieve state from an item is working fine

pi@raspberrypi:~ $ curl --user mylogin:mypassword

set state of an item is modifying the state of my item in the app, but does not turn on the light !

pi@raspberrypi:~ $ curl -X PUT --user mylogin:mypassword --header “Content-Type: text/plain” -d “OFF”

Additionnal question, is that possible to pass login/password directly in the URL ?

Thanks for your help ! used to permit Items but that was turned off due to abuse overloading the limited server resources,

The only current solution is to host your own copy of the cloud connector code.

your code is ok - apart of that the headline says turn on the light while the code contains “OFF”.
I am using this command in my private cloud setup.

Even in case login/password would work in the URL I would not do that. URLs can be sniffed on the network between your OH installation and the target. If login/password is part of the encrypted data stream although the packets can be sniffed they cannot be read in clear text.

1 Like

Why would it? It’s not supposed to. Item states are not commands. If you want a binding to take action, you need to command not state update.
For REST, that uses POST not PUT

1 Like

And, unless you have exposed your openHAB to the Internet, that would only work when connected to Wi-Fi on your local network.

OK thanks for your replies. Once I will have chosen between setup my own cloud server or access to my local openhab only from my WiFi, I’m not sure if my url is correct (Wolfgang says it was OK but rossko57 not)?

Thanks again

Follow rossko57 advice. I also use the POST command in my Personal Setup and testen your command. Both seem to work Herr nevertheless I would use the POST command.

Thanks again, i tried to reach my openhab private IP address from my local wifi and it works fine with the POST command.

This is funny because it works fine too with myopenhab cloud server :
pi@raspberrypi:~ $ curl --user mylogin:mypassword -X POST --header “Content-Type: text/plain” --header “Accept: application/json” -d “ON”

This command turns on the light.

Bye, and thanks again for your help, proxies the full OH REST API. It is and has always been possible to update and command Items through If that didn’t work, the UIs themselves wouldn’t work with

Anything you can do to OH through the REST API can be done through The only difference is having to deal with basic auth. No Items need to be exposed. The exposure of Items is only required for IFTTT integration as that’s how IFTTT gets the events that an Item has changed.

Wolfgang is correct. To see an example using Tasker see Tasker with (Screenshots for tasker)