How do I send a REST command?
-
Hi I just managed to integrate my first mysensors.org switch into domoticz. If I flick the switch it gets updated correctly in domotiz, and now I want to send a REST command witch look like this whenever the switch is switched:
"PUT 192.168.0.22:4455/devices/{udn} The body should be "application/json" as {"STATE": true } "
How do I do this? I guess i need to write a script somehow and place it in the right folder and then specifying it under the switch options.
But I have no idea of how to write a script for this.
-
An example of using the Domoticz api over http would be http://192.168.0.22:4455/json.htm?type=command¶m=switchlight&idx=99&switchcmd=On
Not sure where you got your info from but the API is detailed here.
Domoticz API -
But will that send a PUT command? And where do I enter the body info:{"STATE": true }
-
What are you trying to archieve with this? What is the receiving end?
I think you can send your "ajax call" from lua script with os.execute method using curl if you are in linux enviroment.
commandArray = {} if (devicechanged['NameOfYourSwitch'] == 'On') then os.execute('/usr/bin/curl -X PUT -d STATE=true 192.168.0.22:4455/devices/{udn}') else if(devicechanged['NameOfYourSwitch'] == 'Off') then os.execute('/usr/bin/curl -X PUT -d STATE=false 192.168.0.22:4455/devices/{udn}') end return commandArrayAnd give it a name with prefix: script_device_xxxxxxx.lua where xxxxxxx is name for your script. Then domoticz will launch it everytime some device state changes. Location for it is script/lua under your domoticz folder.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login