Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

netatmo welcome - local cam finder


boomx

Question

Hi,

 

it is possible to use the jpg-stream of the netatmo welcome in your own lan and without the netatmo api. I've written a scene to detect the correct url for the camera settings of the HC2 over the netatmo api. (See screens)

 

Somebody interested? It is a first beta version because the url could change from times to times. At the moment I don't know and we have to test it. 

 

Please login or register to see this code.

 

Greetings :)

 

Please login or register to see this attachment.

 

 

Please login or register to see this attachment.

Please login or register to see this attachment.

Edited by boomx
Link to comment
Share on other sites

Recommended Posts

  • 0
  • Inquirer
  • It is a scene to get this url. It is different for every netatmo-account. I update the original post, cause I fix something in the scene right now

     

    Edited by boomx
    Link to comment
    Share on other sites

    • 0

    Great code again boomx!! Thank you! I use your code for reading measurement from Netatmo rain and wind gauge and it is working perfectly!Keep up a good work. 

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Yes, it based on the same code ;) Thank you. 

     

    Do you get any errors on the code for the rain/wind gauge after some time. I've updated the script for testing purpose.... 

    Link to comment
    Share on other sites

    • 0
    5 minutes ago, boomx said:

    Yes, it based on the same code ;) Thank you. 

     

    Do you get any errors on the code for the rain/wind gauge after some time. I've updated the script for testing purpose.... 

    No, no errors for few months now that is running on my HC2! I just removed it's own loop and I call that scene for rain/wind every 5 minutes from my one and only looping Main scene. Problem with VD refreshing I solved by calling another scene that refreshes VD's with certain delay. It is prefect!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • You have to use the whole link and put it in the jpg-stream and in the mjpeg-stream.

     

    Please login or register to see this code.

     

    Edited by boomx
    Link to comment
    Share on other sites

    • 0

    Hallo 

     

    Tolle arbeit mit der Welcom Cam hat super funktionirt. Heute habe ich die Presence erhalten .....

    und der Kod fur die Presence  Cam :-D habe nur   das geendert in deinen Kod: 

     

    function oAuth(nextFunction)
     local request_body = 'grant_type=password&client_id=' .. client_id .. '&client_secret=' .. client_secret .. '&username=' .. username .. '&password=' .. password .. '&scope=read_presence access_presence'

     

     

     

     

    und hir der gesamte cod zum einfahen einkleben. 

     

    --[[
    %% properties
    %% globals
    --]]
     
    -- DIESE DATEN ANPASSEN
    local client_id = '55xxxxxxxxxxxxxxxxxxxxxx69'
    local client_secret = 'quoLyxxxxxxxxxxxxxxxxxxxtuRlwnpNPbP5'
    local username = 'dkonecko@xxxxxxxxx'
    local password = 'xxxxxxxxxx'
     
    local language = 'german' -- german/english
     
    -- AB HIER NICHTS MEHR ANPASSEN
    local token = ''
    local request_body = ''
     
    Debug = function ( color, message )
      if (debug == 1) then
      fibaro:debug(string.format('<%s style="color:%s;">%s', "span", color, message, "span"))
      elseif (debug == 0) then
      end
    end
     
    DebugChange = function ( color, message )
      fibaro:debug(string.format('<%s style="color:%s;">%s', "span", color, message, "span"))
    end
     
    DebugError = function ( color, message )
      fibaro:debug(string.format('<%s style="color:%s;">%s', "span", color, message, "span"))
    end
     
    fibaro:debug('netatmo welcome cam finder v1.0b')
     
    if (language == 'german' or language == 'english') then
      DebugError( "green", "Debug: " ..language)
    else
      DebugError( "red", "Please choose a language for debug")
      fibaro:abort();
    end
     
    local sourceTrigger = fibaro:getSourceTrigger();
     
    function oAuth(nextFunction)
     local request_body = 'grant_type=password&client_id=' .. client_id .. '&client_secret=' .. client_secret .. '&username=' .. username .. '&password=' .. password .. '&scope=read_presence access_presence'
     getResponseData('https://api.netatmo.net/oauth2/token', request_body, 
         function(data)
          if (data.access_token ~= nil) then
            token = data.access_token
              gethomedata()
          else
            if (language == 'german') then
              DebugError( "red", "oAuth-API-Call konnte nicht durchgeführt werden! oAuth 2.0 lieferte keinen Wert zurück")
            elseif (language == 'english') then
              DebugError( "red", "oAuth-API-Call Error. oAuth 2.0 returns nothing.")
            end
          end
        end
        )
    end
     
    function getResponseData(url, body, func)
     local http = net.HTTPClient()
     http:request(url, { 
     options = { 
     method = 'POST', 
             headers = {
     ['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
     },
     data = body
     },
     success = function(response) 
     func(json.decode(response.data))
     end
     })   
    end
     
    function gethomedata()
       request_body_cam = 'access_token=' ..token.. ''
       getResponseData('https://api.netatmo.net/api/gethomedata', request_body_cam, 
          function(getData)
          --fibaro:debug(request_body_cam)
          if (getData.body ~= nil) then
            if (language == 'german') then
              DebugError( "green", "API-Call durchgeführt.")
            elseif (language == 'english') then
              DebugError( "green", "API-Call was done.")
            end
            for w, v in pairs(getData.body.homes) do
              for a, b in pairs(v.cameras) do
                if (b.is_local) then
                 if (language == 'german') then
                    DebugError( "green", "Lokale IP der Kamera gefunden.")
                 elseif (language == 'english') then
                    DebugError( "green", "Local IP of cam was found.")
                 end
                 findLocalPresence(b.vpn_url)
                else
                 if (language == 'german') then
                    DebugError( "green", "Lokale IP der Kamera NICHT gefunden.")
                 elseif (language == 'english') then
                    DebugError( "green", "Local cam NOT found.")
                 end
                end
              end
            end
          else 
            if (language == 'german') then
              DebugError( "red", "API-Call fehlgeschlagen")
            elseif (language == 'english') then
              DebugError( "red", "API-Call Error")
            end
          end
     end
     )
    end
     
    function findLocalPresence(url)
    local selfhttp = net.HTTPClient({timeout=2000})
    url = url..'/command/ping'
    selfhttp:request(url, {
        options={
          headers = selfhttp.controlHeaders,
          method = 'GET',
          timeout = 5000
        },
        success = function(status)
          if status.status == 200 then
            if status.data ~= nil then
             --print(json.decode(status.data))
             for k,v in pairs(json.decode(status.data)) do 
              if (k == 'local_url') then
                local cam_url = v
                local url_new = string.sub(cam_url, 8, #cam_url)
                one, two = url_new:match("([^,]+)/([^,]+)")
                fibaro:debug('Cam-IP: '..one)
                fibaro:debug('JPG-Stream: /'..two.. '/live/snapshot_720.jpg')
                DebugError( "green", "coded 4 siio.de/siio.com")
              end
             end
            end
          else
            print ("failed")
            print(status.data)
          end
        end,
        error = function(error)
          print "ERROR"
          print(error)
        end
    })
     
    end
     
    oAuth()

    Link to comment
    Share on other sites

    • 0

    I am currently thinking of buying a Netatmo Presence aswell. 

    Is it possible to derive actions in HC2 from lets say, someone is driving with the car infront of my house?

    I think it is not possible to know who (which person) is coming home, right? Only that a person is coming home, unlike with Netatmo welcome...correct?

     

    Cheers

    joystick

     

    Link to comment
    Share on other sites

    • 0

     

    It is a pity that the "presence" does not recognize the face. Is there a possibility of including lamps in the "presence" with the counsel of a virtual device ?

    Link to comment
    Share on other sites

    • 0

     

    Is there a possibility to create a virtual device as in the case "netatmo welcome" ?

     

     

     

    Please login or register to see this link.

    Link to comment
    Share on other sites

    • 0

    Hey guys,

    do you get it to work in 4.104 beta? I got the address and the stream from lua code withou any issue but i can not get the camera to work. I add the IP and feeds and camera can not be seen anyway.

    Link to comment
    Share on other sites

    • 0

    hey guys,

    does this VD works for Netatmo Presence as well? Customer is trying it but all he gets is 

    API-Call was done - Call -Error. oAuth 2.0 returns nothing.

     

     

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...