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

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

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

Post 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
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

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

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest