Is HTTPS request from LUUP code possible?

  • Does anyone know if I can make HTTPS request from luup code with cookie support?
    I would login to my pages on Verisure website and get the alarm status to be used in automation as home/away switch. I can do this successfully with two wget HTTPS calls: 1) login and 2) access status page with cookies that store the session authentication. But no luck so far with luup.

    So can that even be done with lua from a scene with luup code?

  • @hek Do you know who could know if saving the cookies is possible with https POST request in luup code?

  • Admin

    Hmm.. this thread might give you a hint on how to do ssl requests from lua. Setting cookies is just a matter of setting the cookie header.,17627.0.html

    But it will require some hacking to pick up the cookie response from the login request and forward it.

  • Thanks @hek

    I got it working with CURL:

    local pw = 'xxx'
    local un = 'xxx'
    --login request
    local url_1 = ''
    local command_1 = "curl -c '/tmp/log/cmh/cookie.txt' -d 'j_username="..un.."&j_password="" "..url_1
    local f_1 = assert(io.popen(command_1, 'r'))
    local response_1 = assert(f_1:read('*a'))
    luup.log("Verisure login response: "..response_1)
    --armed status request
    local url_2 = ''
    local command_2 = "curl -k -b '/tmp/log/cmh/cookie.txt' "..url_2
    local f_2 = assert(io.popen(command_2, 'r'))
    local response_2 = assert(f_2:read('*a'))
    luup.log("Verisure status response: "..response_2)

    This returns the alarm status of Verisure system:

    [{"date":"Today 8:47 PM","notAllowedReason":"","name":"Samppa Turunen","changeAllowed":true,"id":1,"label":"Armed stay","type":"ARM_STATE","status":"armedhome"}]

    Now I need to parse the response string into a variable.

    Then I could make a device for it to be used as home / away switch.
    What would be the easiest example to start packaging the code into a device file for Vera? This would be my very first handmade device.. 🙂

  • Admin

    I would have a look at one of the existing plugins to get some inspiration... that's how I learned the device file format and "normal" structure of Vera plugins.

  • @samppa This is very interesting, did you Manage to get this to work? Could you please share?

Log in to reply





Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.