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


Search the Community

Showing results for tags 'HttpClient'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • FIBARO Community
    • FIBARO Portal and Forum policy
    • FIBARO
    • Say hello!
    • Off-topics
  • FIBARO Update
    • FIBARO System Update
    • FIBARO Mobile Update
  • FIBARO Community Support
    • Scenes and Interface
    • FIBARO Products
    • FIBARO Mobile
    • FIBARO HomeKit
    • FIBARO Assistant Integrations
    • Other Devices / Third-party devices
    • Tutorials and Guides
    • Home Automation
    • Suggestions
  • FIBARO Społeczność
    • FIBARO
    • Przywitaj się!
    • Off-topic
  • FIBARO Aktualizacja
    • FIBARO System Aktualizacja
    • FIBARO Mobile Aktualizacja
  • FIBARO Wsparcie Społeczności
    • Sceny i Interfejs
    • FIBARO Urządzenia
    • FIBARO Mobilnie
    • FIBARO HomeKit
    • Integracja z Amazon Alexa i Google Home
    • Urządzenia Firm Trzecich
    • Poradniki
    • Automatyka Domowa
    • Sugestie

Categories

  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Google+


Skype


Website URL


WhatsApp


Country


Gateway/s


Interests

Found 8 results

  1. Hi Team, I try to develop some QuickApp on my HC3, but I have an problem with the http request : When I call an API (here switchbot api), the external API respond me an 403 error... The probleme isn't the API because the same request with an little php script works... I have tried much methods but I get only the response code 403. Recently, I have downloaded an quickapp on the marketplace. All review on it are good but for me, it's doesn't work. When I see the console logs, I can see the 403 error code from this downloaded QuickApp too. Do you have an idea for my problem ? You can find my function code here : function QuickApp:GetDeviceList() self.http = net.HTTPClient({timeout=10*1000}) local apikey = self:getVariable("apikey"); self:debug(apikey); --For debug an my token is successfuly loaded local address = "https://api.switch-bot.com/v1.0/devices" --local address = "http://10.0.10.10:1880/debug" self.http:request(address, { options = { headers = { ["Authorization"] = apikey, ["Content-Type"] = "application/json; charset=utf8", ["Accept"] = "application/json", ["User-agent"] = "Mozilla/5.0" --For try but no change }, checkCertificate = false, method = 'POST' }, success = function(response) self:debug(response.status); --return : 403 self:debug(response.data); --return: nothing self:debug(response.headers);--return: array self:debug(message); --return: nil end, }); end
  2. Hi, I'm trying to write a Scene in lua using the HTTPClient to get data from IC-Meter's API. I have tried the code on multiple endpoint all with the same result, the HTTPClient is not returning anything at all, looks like it's just skipped during the execution. My code: --[[ %% properties %% globals --]] print('Script start...') local requestUrl = 'http://app.ic-meter.com/icm/oauth/token' local httpClient = net.HTTPClient(); httpClient:request(requestUrl, { options = { headers={['content-type'] = 'application/x-www-form-urlencoded', ['user-agent'] = 'httpClient'}, method='GET' }, success = function(response) print(response) end, error = function(err) print(err) end }); print('Begin sleep...') fibaro:sleep(600000) It retuns only "Script Start" and "Begin sleep" as shown in the atteached screenshot. I have tried multiple examples from the net and from the form, but i can't even get the HTTPClient to print any thing at all. I have also tried multiple support cases but no luck. Any one have an idea on where to start? Best Jesper
  3. Hi all, I have an issue trying to make and HTTPS POST request from my LUA scnene in Fibaro HC. I am getting "short read" error with the URL "https://api2.magicair.tion.ru/idsrv/oauth2/token" This is my scene: ============================================= --[[ %% properties %% events %% globals --]] local authData = "username=XXX&password=YYY" function doTest() print('Test!') local requestUrl = "https://api2.magicair.tion.ru/idsrv/oauth2/token" local httpClient = net.HTTPClient() httpClient:request(requestUrl, { options = { method = "POST", headers = { ["Content-Type"] = "application/x-www-form-urlencoded", ["Content-Length"] = tostring(authData:len()) }, data = authData, timeout = 5000 }, success = function (response) fibaro:debug (response.data) end, error = function (err) fibaro:debug ("Error: " .. err) end }) setTimeout(doTest, 5*1000) end print('Script start...') doTest() ============================================= I am getting the following in my log: [DEBUG] 15:16:52: Script start... [DEBUG] 15:16:52: Test! [DEBUG] 15:16:52: Error: short read I have been trying to play with headers, data format, timeouts and all parameters I could find, however I always get the same error with the provided URL. Other HTTPS URLS I tried with GET method works just fine. Also I have been trying to do the same with cURL and it works fine with the exact same set of headers and payload (with full credentials string, of course). So the issue is somehow connected with this specific URL: "https://api2.magicair.tion.ru/idsrv/oauth2/token" The Internet is saying that short read problem in HTTPClient request might be related to ciphering protocols mismatch between the client and server. So there could be some parameter regulating this? 2 main versions, which I see: 1. Some tricky param is required to form the correct HTTPS request. 2. Some bug / missing feature in HTTPClient implementation in HC2. Anyway I am stuck and need the help from the community and HC developers. Has anyone seen something similar? Any clues? Please help! Many thanks in advance. PS Using the latest FW 4.51 of Fibaro Come Center 2
  4. I have an issue trying to make and HTTPS POST request. I am getting "short read" error with the URL "https://api2.magicair.tion.ru/idsrv/oauth2/token" This is my scene: ============================================= --[[ %% properties %% events %% globals --]] local authData = "username=XXX&password=YYY" function doTest() print('Test!') local requestUrl = "https://api2.magicair.tion.ru/idsrv/oauth2/token" local httpClient = net.HTTPClient() httpClient:request(requestUrl, { options = { method = "POST", headers = { ["Content-Type"] = "application/x-www-form-urlencoded", ["Content-Length"] = tostring(authData:len()) }, data = authData, timeout = 5000 }, success = function (response) fibaro:debug (response.data) end, error = function (err) fibaro:debug ("Error: " .. err) end }) setTimeout(doTest, 5*1000) end print('Script start...') doTest() ============================================= I am getting the following in my log: [DEBUG] 15:16:52: Script start... [DEBUG] 15:16:52: Test! [DEBUG] 15:16:52: Error: short read I have been trying to play with headers, data format, timeouts and all parameters I could find, however I always get the same error with the provided URL. Other HTTPS URLS I tried with GET method works just fine. Also I have been trying to do the same with cURL and it works fine with the exact same set of headers and payload (with full credentials string, of course). So the issue is somehow connected with this specific URL: "https://api2.magicair.tion.ru/idsrv/oauth2/token" The Internet is saying that short read problem in HTTPClient request might be related to ciphering protocols mismatch between the client and server. So there could be some parameter regulating this? 2 main versions, which I see: 1. Some tricky param is required to form the correct HTTPS request. 2. Some bug / missing feature in HTTPClient implementation in HC2. Anyway I am stuck and need the help from the community and HC developers. Help!
  5. Hi there, my first time here, I am trying to capture a multipart XML-alertstream from a Hikvision IP camera, but since the stream never closes I never receive a response. The information within the stream, such as VMD, LINEDETECTION, FIELDDETECTION etc. will be used to trigger other scenes or VD's in my HC2 (v4.080). This is my test scene so far: fibaro:debug(tostring(fibaro:countScenes())) --to indicate how many instances are running local http = net.HTTPClient() http:request ('http://10.1.1.115/Event/notification/alertStream', { options = { method = "GET", headers = { ['Authorization'] = 'Basic XXXXXXXXXXXXXXXXXXXXX' } }, success = function (response) fibaro: debug (‘OK’) end, error = function (err) fibaro: debug (‘ERROR’) end }) fibaro: debug (‘End of Script’) When running the code, no OK or ERROR will show up, but immediately shows this: 1 End of Script Running the code again shows: 2 <-- is this an indication that the HTTP connection from instance 1 is still open? End of Script Additional info: The GET method works fine directly from my browser (http://<user>:<pwd>@10.1.1.115/Event/notification/alertStream), but the connection stays open while xml data is continuously being added. There’s no authorization issue since I am able to get a good response (single XML response) from a simple GET request. Final goal, of course, is to read response.data in order to do nice things with it. But since nothing shows up… Can someone point me in the right direction? Thanks in advance.
  6. Hi, I am trying to connect to a secure web server, with a self-signed SSL certificate, using the net.HTTPClient() library in a scene. When I connect to the web server using my web browser, I get a warning telling me that the certificate is not certified by a valid authority, as you may have already seen on such certificate. In my web browser, I just click on the button to continue anyway. Firefox even allows me to add the certificate to the list of approved certificates. Problem solved But on HC2, I can't figure how to bypass the warning Here is the LUA code i use : local URL = "https://subdomain.domain.com/path" local httpClient = net.HTTPClient() httpClient:request(URL, { success = function(response) if response.status == 200 then -- Code to execute if successfull else fibaro:debug("Error : status=" .. tostring(response.status)) end end, error = function(err) fibaro:debug('httpClient:request() : Error : ' .. err) end, options = { method = 'GET', checkCertificate = false, } }) As you can see,I tried to use the "checkCertificate = false" option, but I doesn't seem to have any effect. I always get the following message : "sslv3 alert handshake failure" [DEBUG] 21:05:41: httpClient:request() : Error : sslv3 alert handshake failure The checkCertificate option seems to exist, as I found it as a string in the compiled binaries into the HC2. I tried both true and false boolean values, which seems to be accepted by the LUA interpreter, but I doesn't affect result as I would normally expect; If I try another value, such as a number or a string, I get a LUA Cast error and the script immediately ends. This is a proof that the checkCertificate parameter is used, but apparently with no effect. Can anyone confirm this strange behavior ? To Fibaro developers, can you confirm this parameter is correctly implemented ?
  7. Hi, I am using an httpclient request to get an address out of json array of google maps. It is working perfect but I would like to have the value out of the request scope/block. I get a value at 1 but I do not get a value at 2. I hope someone can help me. Thank you! longitude = 52.568197 latitude = 4.560753 http = net. HTTPClient () http : request ( 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' .. longitude ..',' .. latitude .. '&sensor=false', { options = { method = "POST" }, success = function (result) output = json.decode(result.data); address = (output.results[1].formatted_address); print("1:" .. address) end, error = function (err) fibaro: debug ("Errortje:" .. err); end }) print ("2: " .. address
  8. local daysoftheweek={"Söndag","Måndag","Tisdag","Onsdag","Torsdag","Fredag","Lördag"} local day = urlencode(daysoftheweek[os.date("*t").wday-1]) function urlencode(str) if (str) then str = string.gsub (str, "\n", "\r\n") str = string.gsub (str, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end) str = string.gsub (str, " ", "+") end return str end function MM(data) local function getMethod(requestUrl, successCallback, errorCallback) local http = net.HTTPClient() http:request(requestUrl, { options = { method = 'GET', headers = { }, }, success = successCallback, error = errorCallback }) end local url = 'http://192.168.0.137:8080/syslog?type=INFO&message='..data getMethod(url, function(resp) print(resp.data) end, function(err) print('error' .. err) end ) end MM(day..'+'..fibaro:getGlobal("yeasterdayKW")..'+'..'kWh') Result [DEBUG] 14:13:32: {"status":"success","payload":{"type":"INFO","message":"Söndag 34.96 kWh","timestamp":"2016-10-10T12:13:32.103Z"}} Should be [DEBUG] 14:13:32: {"status":"success","payload":{"type":"INFO","message":"Söndag 34.96 kWh","timestamp":"2016-10-10T12:13:32.103Z"}} so i think my header with utf8 is not correct. If i run url direct in browser it works with same data
×
×
  • Create New...