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
Question
wpeters 1
In order to obtain information from "non FIBARO" devices, I have setup a small Webserver which I would like to call from my HC2 via FIBARO LUA scenes. Unfortunately my HC2 executes the "http:request" after executing the main LUA scene (pls. see a small example and scene output). I currently have created a workaround to start another scene (which submits the http:request) and wait for it´s result. This seems to me quite complicate My questions to the experts are:
Thank you for your help!
Wilfried
--[[
%% properties
%% events
%% globals
--]]
function sendRequest(url) -- url to execute
fibaro:debug("... start sendRequest.");
local http = net.HTTPClient();
http:request(url, {
success = function(response)
if ((response.status == 200 or response.status == 201)) then
fibaro:debug("Status: " .. response.status);
fibaro:debug("Data: " .. response.data);
else
fibaro:debug("Error: " .. responce.status);
end
end,
error = function(err)
fibaro:debug("Error: " .. err);
end
})
fibaro:debug("... end sendRequest.");
end
fibaro:debug(os.date("%x") .. " ENTER");
sendRequest("http://192.168.1.190:8080/info/myDevive001");
fibaro:debug(os.date("%x") .. " EXIT");
The output is:
[DEBUG] 19:53:26: 03/15/19 ENTER
[DEBUG] 19:53:26: ... start sendRequest.
[DEBUG] 19:53:26: ... end sendRequest.
[DEBUG] 19:53:26: 03/15/19 EXIT
[DEBUG] 19:53:26: Status: 200
[DEBUG] 19:53:26: Data: {"datapoints" {"idp0000":"22","idp0001":"1","idp0002":"0","idp0003":"0"}}
9 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.