J'ai mixé un peu le tout, ça doit donner un truc comme ça.
Reste àrajouter les icônes.
Merci àmprinfo pour la façon de créer la table des icônes. On oublie trop souvent qu'en LUA les indexes d'une table peuvent être aussi des caractères.
local icone = {
["Ensoleillé"] = 0000,
["Nuit claire"] = 0000,
["Ciel voilé"] = 0000,
["Nuit légèrement voilée"] = 0000,
["Faibles passages nuageux"] = 0000,
["Nuit bien dégagée"] = 0000,
["Brouillard"] = 0000,
["Stratus"] = 0000,
["Stratus se dissipant"] = 0000,
["Nuit claire et stratus"] = 0000,
["Eclaircies"] = 0000,
["Nuit nuageuse"] = 0000,
["Faiblement nuageux"] = 0000,
["Fortement nuageux"] = 0000,
["Averses de pluie faible"] = 0000,
["Nuit avec averses"] = 0000,
["Averses de pluie modérée"] = 0000,
["Averses de pluie forte"] = 0000,
["Couvert avec averses"] = 0000,
["Pluie faible"] = 0000,
["Pluie forte"] = 0000,
["Pluie modéree"] = 0000,
["Développement nuageux"] = 0000,
["Nuit avec développement nuageux"] = 0000,
["Faiblement orageux"] = 0000,
["Nuit faiblement orageuse"] = 0000,
["Orage modéré"] = 0000,
["Fortement orageux"] = 0000,
["Averses de neige faible"] = 0000,
["Nuit avec averses de neige faible"] = 0000,
["Neige faible"] = 0000,
["Neige modérée"] = 0000,
["Neige forte"] = 0000,
["Pluie et neige mêlée faible"] = 0000,
["Pluie et neige mêlée modérée"] = 0000,
["Pluie et neige mêlée forte"] = 0000
}
HC2 = Net.FHttp("127.0.0.1",11111);
local response, status, errorCode = HC2:GET("/api/settings/location");
fibaro:debug(errorCode);
if (tonumber(errorCode) == 0) then
jsonTable = json.decode(response);
fibaro:debug(jsonTable.latitude);
fibaro:debug(jsonTable.longitude);
end
local lat = jsonTable.latitude;
local lng = jsonTable.longitude;
HC2 = Net.FHttp("www.prevision-meteo.ch",80);
-- documentation : http://www.prevision-meteo.ch/uploads/pdf/recuperation-donnees-meteo.pdf
local response, status, errorCode = HC2:GET("/services/json/lat=" .. lat .. "lng=" .. lng);
if (tonumber(errorCode) == 0) then
jsonTable = json.decode(response);
fibaro:debug("aujourd'hui : " .. jsonTable.current_condition.tmp .. "°c - " .. jsonTable.current_condition.condition);
fibaro:debug(jsonTable.fcst_day_1.day_short .. ":" .. jsonTable.fcst_day_1.tmin .. "/" .. jsonTable.fcst_day_1.tmax .. "°c - " .. jsonTable.fcst_day_1.condition);
fibaro:debug(jsonTable.fcst_day_2.day_short .. " : min : " .. jsonTable.fcst_day_2.tmin .. "°c - max : " .. jsonTable.fcst_day_2.tmax .. "°c - " .. jsonTable.fcst_day_2.condition);
fibaro:debug(jsonTable.fcst_day_3.day_short .. " : min : " .. jsonTable.fcst_day_3.tmin .. "°c - max : " .. jsonTable.fcst_day_3.tmax .. "°c - " .. jsonTable.fcst_day_3.condition);
fibaro:debug(jsonTable.fcst_day_4.day_short .. " : min : " .. jsonTable.fcst_day_4.tmin .. "°c - max : " .. jsonTable.fcst_day_4.tmax .. "°c - " .. jsonTable.fcst_day_4.condition);
fibaro:debug(jsonTable.current_condition.icon_big);
else
fibaro:debug("error "..errorCode )
end
local METEO_J = ("aujourd'hui : " ..jsonTable.current_condition.tmp .."°c - " ..jsonTable.current_condition.condition);
local METEO_J1 = (jsonTable.fcst_day_1.day_short .. " : min : " .. jsonTable.fcst_day_1.tmin .. "°c max : " .. jsonTable.fcst_day_1.tmax .. "°c " .. jsonTable.fcst_day_1.condition);
local METEO_J2 = (jsonTable.fcst_day_2.day_short .. " : min : " .. jsonTable.fcst_day_2.tmin .. "°c max : " .. jsonTable.fcst_day_2.tmax .. "°c " .. jsonTable.fcst_day_2.condition);
local METEO_J3 = (jsonTable.fcst_day_3.day_short .. " : min : " .. jsonTable.fcst_day_3.tmin .. "°c max : " .. jsonTable.fcst_day_3.tmax .. "°c " .. jsonTable.fcst_day_3.condition);
local METEO_J4 = (jsonTable.fcst_day_4.day_short .. " : min : " .. jsonTable.fcst_day_4.tmin .. "°c max : " .. jsonTable.fcst_day_4.tmax .. "°c " .. jsonTable.fcst_day_4.condition);
fibaro:call(fibaro:getSelfId(), "setProperty", "ui.Label1.value", METEO_J);
fibaro:call(fibaro:getSelfId(), "setProperty", "ui.Label2.value", METEO_J1);
fibaro:call(fibaro:getSelfId(), "setProperty", "ui.Label3.value", METEO_J2);
fibaro:call(fibaro:getSelfId(), "setProperty", "ui.Label4.value", METEO_J3);
fibaro:call(fibaro:getSelfId(), "setProperty", "ui.Label5.value", METEO_J4);
fibaro:call(fibaro:getSelfId(), "setProperty", "ui.Label211.value", os.date("%H:%M:%S"));
local condition = jsonTable.current_condition.condition
local Num_Icone = icone[condition]
fibaro:call(fibaro:getSelfId() , "setProperty", "currentIcon", Num_Icone)
fibaro:call(fibaro:getSelfId(), "setProperty", "ui.Label211.value", os.date("%H:%M:%S"))
--fibaro:debug(fibaro:getValue(262, "log"))
fibaro:log(METEO_J)
fibaro:sleep(6*60*1000) -- 6 minutes