Page 1 of 1

how to Read ContextID and Cookie from http request with dzvents?

Posted: Monday 27 August 2018 19:17
by papoo
hello,
i want to replace Curl request like this

Code: Select all

curl -s -o "/home/pi/domoticz/scripts/lua/ContextID.txt" -X POST -c "/home/pi/domoticz/scripts/lua/cookie.txt"  -H "Content-Type: application/x-sah-ws-4-call+json" -H "Authorization: X-Sah-Login" -d "{\"service\":\"sah.Device.Information\",\"method\":\"createContext\",\"parameters\":{\"applicationName\":\"so_sdkut\",\"username\":\"admin\",\"password\":\"123456\"}}" http://192.168.1.1/ws
with dzvent/lua, to read ContextID and Cookie.
is it possible? i don't find in DZvents documentation

Re: how to Read ContextID and Cookie from http request with dzvents?

Posted: Monday 27 August 2018 22:26
by papoo
i've test this but not work

Code: Select all

return {
   active = true,
   on = {
      timer = { 'every minute' },
      httpResponses = { 'loggedin' , 'data' },
   },
   execute = function(domoticz, item)
        if (item.isTimer) then
            domoticz.openURL({
                url = 'http://192.168.1.1/ws',  --Change IP  to your livebox settings
                method = 'POST',
                postData = { ['parameters'] = {['applicationName'] = 'so_sdkut' , ['password'] = '12345678' , ['username'] = 'admin' }, ['Content-Type'] = 'application/x-sah-ws-4-call+json' , ['Authorization'] = 'X-Sah-Login' ,  
                ['service'] = 'sah.Device.Information' , ['method'] = 'createContext' },--Change YourPassword and YourUsername to your password and username for livebox settings
                callback = 'loggedin'
         })
        end
loggedin is empty