JSON request syntax in Domoticz - [Solved]
Posted: Saturday 07 December 2019 20:30
Dear friends,
Help deal with JSON in dzvents.
Through the CURL system utility, everything works fine.
Through dzvents - does not work.
Debug log
I use this API protocol to control my SONOFF DIY devices in Domoticz
https://github.com/itead/Sonoff_Devices ... %20v1.4.md
What am I doing wrong, where is the mistake?
Thanks
Help deal with JSON in dzvents.
Through the CURL system utility, everything works fine.
Code: Select all
curl -H "Content-Type: application/json" http://192.168.100.32:8081/zeroconf/switch -X POST --data '{"deviceid":"10008fce77","data":{"switch": "off"}}'
Code: Select all
return {
on = {
timer = { 'every minute' }
},
execute = function(domoticz, timer)
domoticz.openURL({
url = 'http://192.168.100.32:8081/zeroconf/switch',
method = 'POST',
postData = {
deviceid = '10008fce77',
data = '{"switch": "off"}'}
})
end
}
Code: Select all
2019-12-07 21:59:00.273 Status: dzVents: Info: ------ Start internal script: POST:, trigger: every minute
2019-12-07 21:59:00.274 Status: dzVents: Debug: OpenURL: url = http://192.168.100.32:8081/zeroconf/switch
2019-12-07 21:59:00.274 Status: dzVents: Debug: OpenURL: method = POST
2019-12-07 21:59:00.274 Status: dzVents: Debug: OpenURL: post data = {"data":"{\"switch\": \"off\"}","deviceid":"10008fce77"}
2019-12-07 21:59:00.274 Status: dzVents: Debug: OpenURL: headers = {["Content-Type"]="application/json"}
2019-12-07 21:59:00.274 Status: dzVents: Debug: OpenURL: callback = nil
2019-12-07 21:59:00.274 Status: dzVents: Info: ------ Finished POST
2019-12-07 21:59:00.274 Status: dzVents: Debug: Commands sent to Domoticz:
2019-12-07 21:59:00.274 Status: dzVents: Debug: - OpenURL = {["method"]="POST", ["postdata"]="{"data":"{\"switch\": \"off\"}","deviceid":"10008fce77"}", ["URL"]="http://192.168.100.32:8081/zeroconf/switch", ["headers"]={["Content-Type"]="application/json"}}
2019-12-07 21:59:00.274 Status: dzVents: Debug: =====================================================
https://github.com/itead/Sonoff_Devices ... %20v1.4.md
What am I doing wrong, where is the mistake?

Thanks