Prośba o pomoc.
Jakich zmian dokonać, żeby odświeżało pobieranie danych.
W ty stanie tylko ręcznie pobiera dane.
local delay_second = 10;
selfId = fibaro:getSelfId();
HC2 = Net.FHttp("monitor.pogodynka.pl")
dane, status = HC2:GET("/api/station/hydro/?id=152200130")
ajson=json.decode(dane)
fibaro:debug("dane:"..dane);
stan=ajson.status.currentValue
fibaro:debug("stan:"..stan);
waring=ajson.status.warningValue
alert=ajson.status.alarmValue
fibaro:debug("alert:"..alert);
trend=ajson.status.trend
fibaro:debug("trend:"..trend);
fibaro:call(selfId,"setProperty","ui.Label1.value",stan)
if (tonumber(stan)<tonumber(alert))
then
if (tonumber(stan)<tonumber(waring))
then
fibaro:call(selfId,"setProperty","ui.Label2.value","stan optymalny")
fibaro:log("stan optymalny "..stan)
else
fibaro:call(selfId,"setProperty","ui.Label2.value","stan ostrzegawczy przekroczony")
fibaro:log("stan ostrzegawczy przekroczony")
end
else
fibaro:call(selfId,"setProperty","ui.Label2.value","stan alarmowy przekroczony")
fibaro:log("stan alarmowy przekroczony")
end
if ( tonumber(trend) == 0) then
fibaro:call(selfId,"setProperty","ui.Label3.value","bez zmian")
elseif ( tonumber(trend) > 0) then
fibaro:call(selfId,"setProperty","ui.Label3.value","rosnący")
elseif ( tonumber(trend) < 0) then
fibaro:call(selfId,"setProperty","ui.Label3.value","malejący")
end
fibaro:sleep( delay_second * 1000 )
HC3 = Net.FHttp("monitor.pogodynka.pl")
danem, statusm = HC3:GET("/api/station/meteo/?id=252200120")
ajsonm=json.decode(danem)
opadg=ajsonm.status.precip.value
opadd=ajsonm.status.precipDaily.value
opad6=ajsonm.status.precip6HoursSum
fibaro:call(selfId,"setProperty","ui.Label4.value",string.format(" %g ", opadg))
fibaro:call(selfId,"setProperty","ui.Label5.value",string.format(" %g ", opad6))
fibaro:call(selfId,"setProperty","ui.Label6.value",string.format(" %g ", opadd))
fibaro:setGlobal('rzekaNarew', stan)