hello,
is there someone who already dealed with this interface with "hidden" ip api ?
I found someone who made a script:
	
	
	
is there someone who already dealed with this interface with "hidden" ip api ?
I found someone who made a script:
Code:
--[[
%% properties
%% events
%% globals
--]]
-- les variables globales ci-dessous sont initialisées avec des valeurs par défaut
-- ces valeurs seront normalement écrasées par le passage de paramètres lors de l'appel de la scène.
local VeluxDebug = true
local programme = "2"
local password = "xxxYYYzzz"
local KLF_ip = "192.168.yyy.zzz"
local params = fibaro:args()
if (params) then
    for k, v in ipairs(params) do
        if (v.programme) then 
            programme = v.programme
        end
        if (v.adresseIP) then
            KLF_ip = v.adresseIP
        end
        if (v.password) then
            password = v.password
          end
    end
end
local urlLogin = 'http://'.. KLF_ip .. '/api/v1/auth'
local urlLogout = 'http://'.. KLF_ip .. '/api/v1/auth'
local urlScenes = 'http://'.. KLF_ip .. '/api/v1/scenes'
local datasLogin = '{"action":"login","params":{"password":"'.. password .. '"}}'
local datasLogout = '{"action":"logout","params":{}}'
local datasAction = '{"action":"run","params":{"id":"' ..programme ..'"}}'
if (VeluxDebug) then
    fibaro:debug("Démarrage de la scène avec les paramètres suivants")
    fibaro:debug("adresse IP = " .. KLF_ip) 
    fibaro:debug("Password = " .. password)
    fibaro:debug("Programme = " .. programme)
    fibaro:debug(datasAction)
end
local klf = net.HTTPClient()
klf:request(urlLogin , {
    success = function(response)
        if tonumber(response.status)  == 200 then
               if (VeluxDebug) then
                fibaro:debug("Call for LOGON successfull")
                fibaro:debug("Valeur de response")
                fibaro:debug(json.encode(response))
            end
                
            -- récupération du token
            local temp = json.encode(response) 
            local token = temp:match('\\\"token\\\":\\\"(.+)\\\",\\\"result')
            token = string.gsub(token, '\\', '')
               if (VeluxDebug) then
                fibaro:debug("Valeur du token : "..token)
            end
            
               klf:request(urlScenes, {
                      success = function(response)
                          if tonumber(response.status) == 200 then
                              if (VeluxDebug) then 
                            fibaro:debug("Call for ACTION successful")
                            fibaro:debug("response\n")
                            fibaro:debug(json.encode(response))
                              end
                        klf:request(urlLogout , {
                            success = function(response)
                                if tonumber (response.status) == 200 then
                                    if (VeluxDebug) then
                                        fibaro:debug("Call for LOGOUT successful")
                                        fibaro:debug("response\n")
                                        fibaro:debug(json.encode(response))
                                        -- fibaro:debug("response.data\n")
                                          -- fibaro:debug(response.data)
                                      end
                                  else
                                       if (VeluxDebug)then
                                        fibaro:debug("LOGOUT Failed : Status =" .. response.status)       
                                       end
                                  end
                            end,
                            error = function(err)
                                  print ("Erreur de LOGOUT")
                                print('error = ' .. err)
                            end,
                            options = {
                                method = 'POST',
                                headers = {
                                       ["content-type"] = 'application/json, charset=utf-8',
                                       ["Authorization"] = "Bearer "..token,
                                    ["Connection"] = 'close',
                                   },
                                data = datasLogout
                            }
                        })
                    else
                           if (VeluxDebug)then
                            fibaro:debug("RUN ACTION Failed : Status =" .. response.status)       
                           end
                    end
                end,
                  error = function(err)
                    print("Erreur lors du RUN ACTION")
                    print('error =' ..err)
                end,
                  options = {
                       method = 'POST',
                       headers = {
                           ["content-type"] = 'application/json, charset=utf-8',
                        ["content-length"] = "34",
                        ["Authorization"] = "Bearer "..token,
                        ["Connection"] = 'Keep-Alive',
                       },
                    data = datasAction
                }
            })                            
           else
               if (VeluxDebug)then
                fibaro:debug("Login Failed : Status =" .. response.status)       
               end
           end           
    end,
    error = function(err)
        print ("Erreur lors du LOGIN")
        print('error = ' .. err)
    end,
    options = {
           method = 'POST',
        headers = {
            ["content-type"] = 'application/json, charset=utf-8',
            ["connection"] = 'close',
        },
        data = datasLogin
    }
})
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
	
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
 
 

 

 
 

