Home › Forum › Community › Fibaro Home Center 2 integration › Reply To: Fibaro Home Center 2 integration
May 29, 2018 at 11:42 pm
#5790
Participant
I don’t think that is the direction of the project.
I have been trying to implement it in my Fibaro HC2, and have been able to import the json string into the system.
Tho, my unit have no wifi network atm, so I need to get the unit fixed before I can continue.
This is the code so far:
--[[
-- %% autostart
%% properties
%% events
%% globals
--]]
MyId = fibaro:getSelfId()
local PI1 = Net.FHttp("192.168.8.106", 80);
res, status, errorCode = PI1:GET("/j");
fibaro:debug ("status "..status.."; errorCode ".. errorCode.."; res ".. res);
arrData = json.decode(res);
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
local jstr = '{"data":{ "id":"8200007A","type":"8","detector":"SI29BG","voltage":382,"cpm":14,"temperature":9.45,"humidity":48.29,"pressure":100281,"voc":12800000,"co2":399,"noise":39,"ch2o":0.00,"pm25":3,"uptime": 107787}}'
local j = json.decode(jstr)
print(dump(j))