Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. Vera
  4. Is HTTPS request from LUUP code possible?

Is HTTPS request from LUUP code possible?

Scheduled Pinned Locked Moved Vera
6 Posts 3 Posters 3.9k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    samppa
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      samppa
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • hekH Offline
        hekH Offline
        hek
        Admin
        wrote on last edited by
        #3

        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.

        http://forum.micasaverde.com/index.php/topic,17627.0.html

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          samppa
          wrote on last edited by
          #4

          Thanks @hek

          I got it working with CURL:

          local pw = 'xxx'
          local un = 'xxx'
          
          --login request
          local url_1 = 'https://mypages.verisure.com/j_spring_security_check?locale=fi_FI'
          local command_1 = "curl -c '/tmp/log/cmh/cookie.txt' -d 'j_username="..un.."&j_password="..pw.." "..url_1
          local f_1 = assert(io.popen(command_1, 'r'))
          local response_1 = assert(f_1:read('*a'))
          f_1:close(f_1)
          luup.log("Verisure login response: "..response_1)
          
          --armed status request
          local url_2 = 'https://mypages.verisure.com/remotecontrol?_=14616968783849'
          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'))
          f_2:close(f_2)
          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.. :-)

          F 1 Reply Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • S samppa

              Thanks @hek

              I got it working with CURL:

              local pw = 'xxx'
              local un = 'xxx'
              
              --login request
              local url_1 = 'https://mypages.verisure.com/j_spring_security_check?locale=fi_FI'
              local command_1 = "curl -c '/tmp/log/cmh/cookie.txt' -d 'j_username="..un.."&j_password="..pw.." "..url_1
              local f_1 = assert(io.popen(command_1, 'r'))
              local response_1 = assert(f_1:read('*a'))
              f_1:close(f_1)
              luup.log("Verisure login response: "..response_1)
              
              --armed status request
              local url_2 = 'https://mypages.verisure.com/remotecontrol?_=14616968783849'
              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'))
              f_2:close(f_2)
              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.. :-)

              F Offline
              F Offline
              fillefilur
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              13

              Online

              11.7k

              Users

              11.2k

              Topics

              113.1k

              Posts


              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • MySensors
              • OpenHardware.io
              • Categories
              • Recent
              • Tags
              • Popular