pepite Posté(e) le 20 novembre 2015 Signaler Posté(e) le 20 novembre 2015 @sebcbien, du beau boulot :: Je crois que jai deja une cle WU avec un autre VD?? Vais verifier.. gros boulot et merciiiii 1
Dyscus Posté(e) le 21 novembre 2015 Signaler Posté(e) le 21 novembre 2015 Du super travail merci bien ! Comment trouver une PWS localement s'il vous plait ? D'autre part pour le code vile j'ai mis : -- WU settings WU.APIkey = "291f91ba6b1add09" -- Put your WU api key here WU.PWS = "" -- The PWS location to get data for (Personal Weather Station) WU.LOCID = "FRXX0059" -- The location ID to get data for (City location) WU.station = "PWS" -- PWS or LOCID -- Other settings WU.translation = {true} WU.language = "FR"; -- EN, FR, SW, PL (default is en) WU.smartphoneID = iPhone_Christophe -- your smartphone ID WU.sendPush = true -- send forecast as push message WU.push_fcst1 = "07:00" -- time when forecast for today will be pushed to smartphone WU.push_fcst2 = "18:15" -- time when forecast for tonight will be pushed to smartphone WU.GEA = true -- subst % with %% when storing in the VG's (because gea bug with % in push messages) WU.CreateVG = true -- will atomaticaly create global variables at first run if = true updateEvery = 30 -- get data every xx minutes Et quand je fais débogage j'obtiens ce ci : [DEBUG] 09:43:43: WU Weather - Original LUA Scripting by Jonny Larsson 2015 [DEBUG] 09:43:43: YAMS WU - Fork by Sébastien Jauquet 11/2015 [DEBUG] 09:43:43: Version: 3.7 [DEBUG] 09:43:44: Données Reçues [DEBUG] 09:43:44: Pas de données disponibles !! [DEBUG] 09:43:59: Données Reçues [DEBUG] 09:43:59: Pas de données disponibles !! [DEBUG] 09:44:14: Données Reçues [DEBUG] 09:44:14: Pas de données disponibles !! [DEBUG] 09:44:30: Données Reçues [DEBUG] 09:44:30: Pas de données disponibles !! [DEBUG] 09:44:50: Données Reçues [DEBUG] 09:44:50: Pas de données disponibles !! [DEBUG] 09:45:05: Données Reçues [DEBUG] 09:45:05: Pas de données disponibles !! [DEBUG] 09:45:21: Données Reçues [DEBUG] 09:45:21: Pas de données disponibles !! [DEBUG] 09:45:36: Données Reçues [DEBUG] 09:45:36: Pas de données disponibles !! [DEBUG] 09:45:52: Données Reçues [DEBUG] 09:45:52: Pas de données disponibles !! [DEBUG] 09:46:07: Données Reçues [DEBUG] 09:46:07: Pas de données disponibles !! [DEBUG] 09:46:23: Données Reçues [DEBUG] 09:46:23: Pas de données disponibles !! [DEBUG] 09:46:38: Données Reçues [DEBUG] 09:46:38: Pas de données disponibles !! [DEBUG] 09:46:54: Données Reçues [DEBUG] 09:46:54: Pas de données disponibles !! [DEBUG] 09:47:09: Données Reçues [DEBUG] 09:47:09: Pas de données disponibles !! [DEBUG] 09:47:24: Données Reçues [DEBUG] 09:47:24: Pas de données disponibles !! [DEBUG] 09:47:40: Données Reçues [DEBUG] 09:47:40: Pas de données disponibles !! [DEBUG] 09:47:55: Données Reçues [DEBUG] 09:47:55: Pas de données disponibles !! [DEBUG] 09:48:11: Données Reçues [DEBUG] 09:48:11: Pas de données disponibles !! [DEBUG] 09:48:26: Données Reçues [DEBUG] 09:48:26: Pas de données disponibles !! [DEBUG] 09:48:41: Données Reçues [DEBUG] 09:48:41: Pas de données disponibles !! [DEBUG] 09:48:57: Données Reçues [DEBUG] 09:48:57: Pas de données disponibles !! [DEBUG] 09:49:12: Données Reçues [DEBUG] 09:49:12: Pas de données disponibles !!
Bono2007 Posté(e) le 21 novembre 2015 Signaler Posté(e) le 21 novembre 2015 Super module, il marche bien chez moi avec PWS location. Il neige bien ^^ @Dyscus Pour trouver, j'ai eu la station PWS en cliquant dans "Search locations" sur Wunderground, on te propose "search nearest station", et il a proposé une station météo proche. Sinon en entrant ta ville, tu peux cliquer sur "change Station" et tu verras une carte avec d'autres stations météo. Exemple : j'ai entré "Boussois" et j'ai comme station météo "Cit du Grand Bois, Récquignies ( IRECQUIG2) J'ai modifié WU.PWS = "IRECQUIG2"
jmg38 Posté(e) le 21 novembre 2015 Signaler Posté(e) le 21 novembre 2015 Bonjour, je viens de le mettre en place = super boulot, malgré qq Pb affichage sur IPhone, Merci
sebcbien Posté(e) le 21 novembre 2015 Auteur Signaler Posté(e) le 21 novembre 2015 oui sur mobile, je dois encore finaliser, l'html ne passe pas et on n'a droit qu'a une seule ligne... Je l'ai déjà fait pour certaines lignes, mais je dois encore compacter les informations longues.. J'en avais parlé ici: http://www.domotique-fibaro.fr/index.php/topic/6446-yams-wu-yet-another-meteo-station-wunderground-version/#entry96890 Dès que j'ai un peu de temps je le ferai. il suffira de remplacer le code du main loop du VD.
sebcbien Posté(e) le 21 novembre 2015 Auteur Signaler Posté(e) le 21 novembre 2015 Pour info: Ajout d'une icône et de quelques explications supplémentaire au post 1
Dyscus Posté(e) le 21 novembre 2015 Signaler Posté(e) le 21 novembre 2015 J'a réglé le soucis de la station météo la plus proche. Je m'attaque maintenant au notification, question débile ce qui me sert pour mes notification quand je créer une scène c'est iPhone_Christophe Je dois bien le tourner comme ceci ? WU.smartphoneID = iPhone_Christophe Parce que ça n'a pas l'air de fonctionner les notifications. Merci
sebcbien Posté(e) le 21 novembre 2015 Auteur Signaler Posté(e) le 21 novembre 2015 Tu dois mettre le no d'id qui correspond àton smartphone. Moi je le trouve dans le toolkit de krikroff Si tu l'a déjàutilisé tu devrais le trouver sans problème. Sent from my Note4
mprinfo Posté(e) le 21 novembre 2015 Signaler Posté(e) le 21 novembre 2015 Tu peux aussi trouver l id du ou des tel via la doc de la hc2 Ex 192.168.1.33/docs Ou http://192.168.1.33:80/api/iosDevices Envoyé de mon SM-G900F en utilisant Tapatalk 1
sebcbien Posté(e) le 22 novembre 2015 Auteur Signaler Posté(e) le 22 novembre 2015 Voici la dernière version: Dans la précédente, il y a une erreur d'interprétation des tables json, ce qui fait que les icônes ne sont pas juste ni les mm pour les jours +1 et +2 .... Je vous recommande donc de mettre à jour. En fait dans le json, les jours avec la description texte ne correspondent pas aux valeurs "chiffrées" (mm,pluie, km/h vent, T°, etc...) Il est tard, jChez moi ça semble bon, mais je vous suggère pour être sur de comparer vos versions texte (web) VS version courte (mobile) et éventuellement à la météo prévue sur le site wunderground. voici le code à copier dans le main loop et c'est tout ce qu’il y a a faire. N'oubliez pas de garder vos paramètres... Je remet l'icône ici au cas où: ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- -- WU WeatherData - Fetch weather data from wunderground.com. Multilanguage support! -- Original Code by Jonny Larsson 2015 http://forum.fibaro.com/index.php?/topic/19810-wu-weatherdata-version-202-2015-10-25/ -- forked by Sébastien Jauquet 11/2015 -- Inspired by GEA(steven), stevenvd, Krikroff and many other users. -- Source - forum.fibaro.com, domotique-fibaro.fr and worldwideweb -- -- Version 3.8 -- -- PWS = Personal Weather Station -- LOCID = Public station -- -- 2014-03-22 - Permissions granted from Krikroff -- 2014-03-23 - Added rain and forecast, Added FR language. -- 2014-03-23 - Language variable changed to get the translation from wunderground.com in forcast -- 2014-03-24 - Added PL language -- 2014-03-24 - Select between PWS or LOCID to download weather data -- 2015-10-23 - New source code. -- 2015-11-13 - V3.0 - Fork Code by Sebastien Jauquet (3 days forecast, rain in mm) -- 2015-11-14 - V3.1 - Compatibilty with GEA, French translation -- 2015-11-14 - V3.2 - Catch rain errors (-999mm null empty etc.) -- 2015-11-14 - V3.3 - Catch json decode error (was stopping main loop) with pcall (can be extended to other jdon datas if needed) -- 2015-11-16 - V3.4 - Generate HTML and non HTML version (for compatibility with mobiles) -- 2015-11-18 - V3.5 - Fixed bug not updating Meteo_Day becaus WU.now was only updated at first launch -- 2015-11-18 - V3.6 - Merged some changes from jompa new version -- 2015-11-18 - Added autmatic creation of Global Variables if not existing -- 2015-11-19 - V3.7 - Modify schedule management and CleanUp code -- 2015-11-22 - V3.8 - Finalise mobile version and bug fixing -- Look for nearest station here: http://www.wunderground.com ------------------------------------------------------------------------------------------- -- MAIN CODE -- ------------------------------------------------------------------------------------------- WU = {} -- WU settings WU.APIkey = "xxxxxxxxxxxxxxx" -- Put your WU api key here WU.PWS = "IGVLEBOR5" -- The PWS location to get data from (Personal Weather Station) WU.LOCID = "SWXX0076" -- The location ID to get data from (City location) WU.station = "PWS" -- Choose your prefered method to retrieve from: PWS or LOCID -- Other settings WU.translation = {true} WU.language = "FR"; -- EN, FR, SW, PL (default is en) WU.smartphoneID = 1347 -- your smartphone ID WU.sendPush = true -- send forecast as push message WU.push_fcst1 = "07:00" -- time when forecast for today will be pushed to smartphone WU.push_fcst2 = "18:15" -- time when forecast for tonight will be pushed to smartphone WU.GEA = true -- subst % with %% when storing in the VG's (because gea bug with % in push messages) WU.CreateVG = true -- will atomaticaly create global variables at first run if = true updateEvery = 30 -- get data every xx minutes WU.startTime = os.time() WU.scheduler = os.time()+60*updateEvery WU.currentDate = os.date("*t"); WU.now = os.date("%H:%M"); DoNotRecheckBefore = os.time() WU.selfId = fibaro:getSelfId() WU.version = "3.8" WU.translation["EN"] = { Push_forecast = "Push forecast", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "Temperature", Humidity = "Humidity", Pressure = "Pressure", Wind = "Wind", Rain = "Rain", Forecast = "Forecast", Station = "Station", Fetched = "Fetched", Data_processed = "Data processed", Update_interval = "Next update will be in (min)", No_data_fetched = "No data fetched", NO_STATIONID_FOUND = "No stationID found", NO_DATA_FOUND = "No data found" } WU.translation["FR"] = { Push_forecast = "Push des prévisions", Exiting_loop_slider = "Sortie de boucle (Slider Changé)", Exiting_loop_push = "Sortie de boucle (Pour Push)", Last_updated = "Mise à jour", Temperature = "Actuellement", Humidity = "Hum", Pressure = "Pression", Wind = "Vent", Rain = "Pluie", Forecast = "", Station = "Station", Fetched = "Données Reçues", Data_processed = "Données mises à jour", Update_interval = "Prochaine Mise à jour prévue dans (min)", No_data_fetched = "Pas de données reçues !!", NO_STATIONID_FOUND = "StationID non trouvée !!", NO_DATA_FOUND = "Pas de données disponibles !!" } WU.translation["SW"] = { Push_forecast = "Push forecast", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "Temperatur", Humidity = "Fuktighet", Pressure = "Barometer", Wind = "Vind", Rain = "Regn", Forecast = "Prognos", Station = "Station", Fetched = "Hà¤mtat", Data_processed = "All data processat", Update_interval = "Nà¤sta uppdatering à¤r om (min)", No_data_fetched = "Inget data hà¤mtat", NO_STATIONID_FOUND = "StationID ej funnet", NO_DATA_FOUND = "Ingen data hos WU" } WU.translation["PL"] = { Push_forecast = "Push prognoza", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "Temperatura", Humidity = "Wilgotnosc", Pressure = "Pressure", Wind = "Wiatr", Rain = "Rain", Forecast = "Forecast", Station = "Station", Fetched = "Fetched", Data_processed = "Data processed", No_data_fetched = "No data fetched", Update_interval = "Next update will be in (min)", NO_STATIONID_FOUND = "No stationID found", NO_DATA_FOUND = "No data found" } WU.translation["NL"] = { Push_forecast = "Push verwachting", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "Temperatuur", Humidity = "Vochtigheid", Pressure = "Druk", Wind = "Wind", Rain = "Regen", Forecast = "Verwachting", Station = "Weerstation", Fetched = "Ontvangen", Data_processed = "Gegevens verwerkt", Update_interval = "Volgende update in (min)", No_data_fetched = "Geen gegevens ontvangen", NO_STATIONID_FOUND = "Geen stationID gevonden", NO_DATA_FOUND = "Geen gegevens gevonden" } WU.translation["DE"] = { Push_forecast = "Push vorhersage", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "Temperatur", Humidity = "Luftfeuchtigkeit", Pressure = "Luftdruck", Wind = "Wind", Rain = "Regen", Forecast = "Vorhersage", Station = "Station", Fetched = "Abgerufen", Data_processed = "Daten verarbeitet", No_data_fetched = "Keine Daten abgerufen", Update_interval = "Das nà¤chste Update in (min)", NO_STATIONID_FOUND = "Keine stationID gefunden", NO_DATA_FOUND = "Keine Daten gefunden" } Debug = function ( color, message ) fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); end WU.createGlobalIfNotExists = function (varName, defaultValue) if (fibaro:getGlobal(varName) == "") then Debug("red", "Global Var: "..varName.." HAS BEEN CREATED") newVar = {} newVar.name = varName HC2 = Net.FHttp("127.0.0.1", 11111) HC2:POST("/api/globalVariables", json.encode(newVar)) end end WU.substPercent = function(doublePercentSymbol) if WU.GEA then doublePercentSymbol = string.gsub(doublePercentSymbol, "%%.", "%%%%") end return doublePercentSymbol end WU.cleanJson = function(jsontocheck,returnIfTrue) if jsontocheck == "-999.00" or jsontocheck == "--" or jsontocheck == json.null then jsontocheck = returnIfTrue end local ok = pcall(function() testConcatenate = "Test Concatenate: " .. jsontocheck -- test for non concatenate value end ) if (not ok) then decode_error = true Debug( "red", "decode raised an error") fibaro:call(WU.smartphoneID , "sendPush", "decode error in WU Meteo") end return jsontocheck end WU.HtmlColor = function(StringToColor,color) if MobileDisplay == false then StringToColor= "<font color=\""..color.."\"> "..StringToColor.."</font>" end return StringToColor end WU.IconOrText = function(icon,txt) if MobileDisplay == false then IconOrText = "<img src="..icon.."\>" else IconOrText = txt end return IconOrText end WU.HtmlOrText = function(_html,txt) if MobileDisplay == false then HtmlOrText = _html else HtmlOrText = txt end return HtmlOrText end WU.getSlider = function() ValeurSliderfunct = fibaro:getValue(WU.selfId , "ui.WebOrMobile.value") return tonumber(ValeurSliderfunct) end WU.setSlider = function(position) fibaro:call(WU.selfId , "setProperty", "ui.WebOrMobile.value", position) return WU.getSlider() end WU.checkMobileOrWeb = function() ValeurSliderSleep = WU.getSlider() -- check slider value at first run if ValeurSliderSleep <= 50 then if ValeurSliderSleep == 1 then MobileDisplay = false else MobileDisplay = false WU.runDirect = 1 sleepAndcheckslider = 20*updateEvery -- exit wait loop Debug("orange", WU.translation[WU.language]["Exiting_loop_slider"]); end WU.setSlider(1) -- désactive le run immediat lors du prochain test end if ValeurSliderSleep >= 50 then if ValeurSliderSleep == 98 then else MobileDisplay = true WU.runDirect = 1 sleepAndcheckslider = 20*updateEvery -- exit wait loop Debug("orange", WU.translation[WU.language]["Exiting_loop_slider"]); end WU.setSlider(98) -- désactive le run immediat lors du prochain test end return WU.getSlider() end WU.fetchWU = function() decode_error = false WU.checkMobileOrWeb() local WGROUND = Net.FHttp("api.wunderground.com",80); local response ,status, err = WGROUND:GET("/api/"..WU.APIkey.."/conditions/forecast/lang:"..WU.language.."/q/"..WU.station..":"..locationID..".json"); if (tonumber(status) == 200 and tonumber(err)==0) then Debug( "cyan", WU.translation[WU.language]["Fetched"]) if (response ~= nil) then WU.now = os.date("%H:%M") jsonTable = json.decode(response); if jsonTable.response.error ~= nil then Debug( "red", WU.translation[WU.language]["NO_DATA_FOUND"]) fibaro:sleep(15*1000) return end stationID = jsonTable.current_observation.station_id; humidity = jsonTable.current_observation.relative_humidity temperature = jsonTable.current_observation.temp_c pression = jsonTable.current_observation.pressure_mb wind = jsonTable.current_observation.wind_kph rain = WU.cleanJson(jsonTable.current_observation.precip_today_metric,"0") weathericon = jsonTable.current_observation.icon_url -- Day meteo fcstday1 = jsonTable.forecast.txt_forecast.forecastday[1].title fcst1 = jsonTable.forecast.txt_forecast.forecastday[1].fcttext_metric fcst1icon = jsonTable.forecast.txt_forecast.forecastday[1].icon_url -- Evening Meteo fcstday2 = jsonTable.forecast.txt_forecast.forecastday[2].title fcst2 = jsonTable.forecast.txt_forecast.forecastday[2].fcttext_metric fcst2icon = jsonTable.forecast.txt_forecast.forecastday[2].icon_url -- Tomorrow Meteo fcstday3 = jsonTable.forecast.txt_forecast.forecastday[3].title fcst3 = jsonTable.forecast.txt_forecast.forecastday[3].fcttext_metric fcst3icon = jsonTable.forecast.txt_forecast.forecastday[3].icon_url -- In 2 days fcstday5 = jsonTable.forecast.txt_forecast.forecastday[5].title fcst5 = jsonTable.forecast.txt_forecast.forecastday[5].fcttext_metric fcst5icon = jsonTable.forecast.txt_forecast.forecastday[5].icon_url -- SimpleForecast Today fcst1SmallTxt = jsonTable.forecast.simpleforecast.forecastday[1].conditions fcst1Tmax = jsonTable.forecast.simpleforecast.forecastday[1].high.celsius fcst1Tmin = jsonTable.forecast.simpleforecast.forecastday[1].low.celsius fcst1avewind =jsonTable.forecast.simpleforecast.forecastday[1].avewind.kph fcst1avewinddir =jsonTable.forecast.simpleforecast.forecastday[1].avewind.dir fcst1mm = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[1].qpf_day.mm,"0") -- SimpleForecast Tomorrow fcst2SmallTxt = jsonTable.forecast.simpleforecast.forecastday[2].conditions fcst2Tmax = jsonTable.forecast.simpleforecast.forecastday[2].high.celsius fcst2Tmin = jsonTable.forecast.simpleforecast.forecastday[2].low.celsius fcst2avewind =jsonTable.forecast.simpleforecast.forecastday[2].avewind.kph fcst2avewinddir =jsonTable.forecast.simpleforecast.forecastday[2].avewind.dir fcst2mm = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[2].qpf_night.mm,"0") -- In 2 days fcst3SmallTxt = jsonTable.forecast.simpleforecast.forecastday[3].conditions fcst3Tmax = jsonTable.forecast.simpleforecast.forecastday[3].high.celsius fcst3Tmin = jsonTable.forecast.simpleforecast.forecastday[3].low.celsius fcst3avewind =jsonTable.forecast.simpleforecast.forecastday[3].avewind.kph fcst3avewinddir =jsonTable.forecast.simpleforecast.forecastday[3].avewind.dir fcst3mm = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[3].qpf_allday.mm,"0") if (stationID ~= nil) and decode_error == false then fibaro:call(WU.selfId , "setProperty", "ui.lblStation.value", locationID); if temperature < 5 then cTemperature = WU.HtmlColor(temperature,"00bfff") elseif temperature > 18 then cTemperature = WU.HtmlColor(temperature,"ff4500") else cTemperature = WU.HtmlColor(temperature,"ffd700") end fibaro:call(WU.selfId , "setProperty", "ui.lblTempHum.value", WU.translation[WU.language]["Temperature"]..": "..cTemperature.." °C - "..WU.translation[WU.language]["Humidity"]..": "..humidity); fibaro:call(WU.selfId , "setProperty", "ui.lblWindRain.value", WU.translation[WU.language]["Wind"]..": "..wind.." km/h - "..WU.translation[WU.language]["Rain"]..": "..rain.." mm"); if (WU.now >= "00:00" and WU.now <= "15:59") then -- donne meteo du jour entre 00:00 (ou 3h) et 15:59. permet de garder la météo du soir jusqu'a 3h du matin, sinon change à minuit fibaro:call(WU.selfId , "setProperty", "ui.lblFcst.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday1,"ff4500")..": "..WU.HtmlColor(fcst1.." ("..fcst1mm.." mm)","b0c4de"), "["..fcst1Tmax.."° "..fcst1Tmin.."°] | "..fcst1mm.."mm | "..fcst1avewind.."Km/h ("..fcst1avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIcon.value",WU.IconOrText(fcst1icon,fcstday1..": "..fcst1SmallTxt)); fibaro:setGlobal("Meteo_Day", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday1..": ".." "..fcst1.." ("..fcst1mm.." mm)") ); elseif (WU.now >= "16:00" and WU.now <= "23:59") then -- donne meteo soirée entre 16:00 et 23:59 fibaro:call(WU.selfId , "setProperty", "ui.lblFcst.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday2,"ff4500")..": "..WU.HtmlColor(fcst2.." ("..fcst1mm.." mm)","b0c4de"), "["..fcst1Tmax.."° "..fcst1Tmin.."°] | "..fcst1mm.."mm | "..fcst1avewind.."Km/h ("..fcst1avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIcon.value",WU.IconOrText(fcst2icon,fcstday2..": "..fcst1SmallTxt)); fibaro:setGlobal("Meteo_Day", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday2..": ".." "..fcst2.." ("..fcst1mm.." mm)") ); end -- Meteo of Tomorrow fibaro:call(WU.selfId , "setProperty", "ui.lblFcstTomorrow.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday3,"ff4500")..": "..WU.HtmlColor(fcst3.." ("..fcst2mm.." mm)","b0c4de"), "["..fcst2Tmax.."° "..fcst2Tmin.."°] | "..fcst2mm.."mm | "..fcst2avewind.."Km/h ("..fcst2avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIconTomorrow.value",WU.IconOrText(fcst3icon,fcstday3..": "..fcst2SmallTxt)); fibaro:setGlobal("Meteo_Tomorrow", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday3..": ".." "..fcst3.." ("..fcst2mm.." mm)") ); -- Meteo in 2 Days fibaro:call(WU.selfId , "setProperty", "ui.lblFcst2Days.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday5,"ff4500")..": "..WU.HtmlColor(fcst5.." ("..fcst3mm.." mm)","b0c4de"), "["..fcst3Tmax.."° "..fcst3Tmin.."°] | "..fcst3mm.."mm | "..fcst3avewind.."Km/h ("..fcst3avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIcon2Days.value",WU.IconOrText(fcst5icon,fcstday5..": "..fcst3SmallTxt)); fibaro:setGlobal("Meteo_In_2_Days", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday5..": ".." "..fcst5.." ("..fcst3mm.." mm)") ); if WU.sendPush then if (os.date("%H:%M") == WU.push_fcst1) then -- fibaro:call(WU.smartphoneID , "sendPush", fcstday1.." - "..fcst1) -- envoie meteo du matin elseif (os.date("%H:%M") == WU.push_fcst2) then fibaro:call(WU.smartphoneID , "sendPush", fcstday2.." - "..fcst2) -- envoie meteo du soir end end if WU.sendPush then fibaro:call(WU.selfId , "setProperty", "ui.lblNotify.value", WU.translation[WU.language]["Push_forecast"].." = true"); else fibaro:call(WU.selfId , "setProperty", "ui.lblNotify.value",WU.translation[WU.language]["Push_forecast"].." = false"); end WU.scheduler = os.time()+updateEvery*60 fibaro:call(WU.selfId, "setProperty", "ui.lblUpdate.value", WU.translation[WU.language]["Last_updated"]..": "..os.date("%c")); Debug( "cyan", WU.translation[WU.language]["Data_processed"]) Debug( "white", WU.translation[WU.language]["Update_interval"].." "..updateEvery) else Debug( "red", WU.translation[WU.language]["NO_STATIONID_FOUND"]) end else fibaro:debug("status:" .. status .. ", errorCode:" .. errorCode); end end sleepAndcheckslider = 0 while sleepAndcheckslider <= 20*updateEvery do fibaro:sleep(3000) WU.checkMobileOrWeb() sleepAndcheckslider = sleepAndcheckslider+1 if (DoNotRecheckBefore <= os.time()) and ((WU.scheduler == os.time) or (os.date("%H:%M") == WU.push_fcst1) or (os.date("%H:%M") == WU.push_fcst2)) then Debug("orange", WU.translation[WU.language]["Exiting_loop_push"]); DoNotRecheckBefore = os.time()+60 sleepAndcheckslider = 20*updateEvery end end end Debug( "orange", "WU Weather - Original LUA Scripting by Jonny Larsson 2015"); Debug( "orange", "YAMS WU - Fork by Sébastien Jauquet 11/2015"); Debug( "orange", "Version: "..WU.version); if WU.station == "LOCID" then locationID = WU.LOCID elseif WU.station == "PWS" then locationID = WU.PWS end if WU.CreateVG then WU.createGlobalIfNotExists("Meteo_Day", "") WU.createGlobalIfNotExists("Meteo_Tomorrow", "") WU.createGlobalIfNotExists("Meteo_In_2_Days", "") end while true do WU.fetchWU() end
domo Posté(e) le 22 novembre 2015 Signaler Posté(e) le 22 novembre 2015 merci pour le partage toujours au top sebcbien
pepite Posté(e) le 22 novembre 2015 Signaler Posté(e) le 22 novembre 2015 Enorme ce VD Sebcbien, le TOP
Dyscus Posté(e) le 22 novembre 2015 Signaler Posté(e) le 22 novembre 2015 Hello, Comment copier le nouveau code sans les numéro de lignes s'il vous plait ? Merci.
Lazer Posté(e) le 22 novembre 2015 Signaler Posté(e) le 22 novembre 2015 Je ne sais pas ce que utilises comme navigateur, mais normalement les numéros de lignes ne sont pas copiés.
Dyscus Posté(e) le 22 novembre 2015 Signaler Posté(e) le 22 novembre 2015 Salut, Je suis sous OSX donc avec safari et le navigateur de google ça ne fonctionne pas. Heureusement Firefox m'a sauvé ++
sebcbien Posté(e) le 22 novembre 2015 Auteur Signaler Posté(e) le 22 novembre 2015 Ça.... avec du matos bon marché... ;-) Sent from my Note4 2
Dyscus Posté(e) le 22 novembre 2015 Signaler Posté(e) le 22 novembre 2015 Décidément je vous sollicite J'aurais souhaité envoyé aussi les notifs sur le samsung de mon épouse pour la préparation des habits de la petite Je pensais faire comme ceci, mais moi je reçois la notif sur mon iPhone , pas elle, 188 c'est bien son ID : WU.smartphoneID = 181,188
sebcbien Posté(e) le 22 novembre 2015 Auteur Signaler Posté(e) le 22 novembre 2015 La météo est mise àdisposition dans des VG. De làtu peux les utiliser àpartir de GEA. Perso je suis dans le même cas que toi et je fais un push quand mon épouse allume les babyphones... Exemples au post 14. Sent from my Note4
Dyscus Posté(e) le 22 novembre 2015 Signaler Posté(e) le 22 novembre 2015 (modifié) La météo est mise à disposition dans des VG. De là tu peux les utiliser à partir de GEA. Perso je suis dans le même cas que toi et je fais un push quand mon épouse allume les babyphones... Exemples au post 14. Sent from my Note4 Ok je vois un peu l'idée générale, je regarderais ça plus tard pour le code, car je maitrise pas du tout. J'ai bien vu les variables dans les scènes en mode bloc par contre. Modifié le 22 novembre 2015 par Lazer Merci de ne pas citer le messages situé immédiatement au dessus
sebcbien Posté(e) le 22 novembre 2015 Auteur Signaler Posté(e) le 22 novembre 2015 Teaser: Une version inspirée des multi-notifications de @lazer (sms push, email) va arriver. Pour le moment ça tourne chez moi, je fais quelques tests et je publierai quand ca me semblera bon. 1
sebcbien Posté(e) le 27 novembre 2015 Auteur Signaler Posté(e) le 27 novembre 2015 Comme promis, voici la version 3.9 avec les notification Email, sms, push, @lazer style. YAMS_WU V3.9.vfib Et voici le code du main loop: ------------------------------------------------------------------------------------------- -- WU WeatherData - Fetch weather data from wunderground.com. Multilanguage support! -- Original Code by Jonny Larsson 2015 http://forum.fibaro.com/index.php?/topic/19810-wu-weatherdata-version-202-2015-10-25/ -- Forked by Sébastien Jauquet 11/2015 http://www.domotique-fibaro.fr/index.php/topic/6446-yams-wu-yet-another-meteo-station-wunderground-version/ -- Inspired by GEA(steven), stevenvd, Lazer, Krikroff and many other users. -- Source - forum.fibaro.com, domotique-fibaro.fr and worldwideweb -- 2014-03-22 - Permissions granted from Krikroff -- 2014-03-23 - Added rain and forecast, Added FR language. -- 2014-03-23 - Language variable changed to get the translation from wunderground.com in forcast -- 2014-03-24 - Added PL language -- 2014-03-24 - Select between PWS or LOCID to download weather data -- 2015-10-23 - New source code. -- 2015-11-16 - Permissions granted from Jonny Larsson -- 2015-11-13 - V3.0 - Fork Code by Sebastien Jauquet (3 days forecast, rain in mm) -- 2015-11-14 - V3.1 - Compatibilty with GEA, French translation -- 2015-11-14 - V3.2 - Catch rain errors (-999mm null empty etc.) -- 2015-11-14 - V3.3 - Catch json decode error (was stopping main loop) with pcall (can be extended to other jdon datas if needed) -- 2015-11-16 - V3.4 - Generate HTML and non HTML version (for compatibility with mobiles) -- 2015-11-18 - V3.5 - Fixed bug not updating Meteo_Day becaus WU.now was only updated at first launch -- 2015-11-18 - V3.6 - Merged some changes from jompa new version -- 2015-11-18 - Added autmatic creation of Global Variables if not existing -- 2015-11-19 - V3.7 - Modify schedule management and CleanUp code -- 2015-11-22 - V3.8 - Finalise mobile version and bug fixing -- 2015-11-23 - V3.9 - Added multiple notification options (Lazer way) -- Look for nearest station here: http://www.wunderground.com ------------------------------------------------------------------------------------------- -- MAIN CODE -- ------------------------------------------------------------------------------------------- WU = {}; -- WU settings WU.APIkey = "XXXXXXXXXxxxxxXX"; -- Put your WU api key here WU.PWS = "IGVLEBOR5"; -- The PWS location to get data from (Personal Weather Station) WU.LOCID = "SWXX0076"; -- The location ID to get data from (City location) WU.station = "PWS"; -- Choose your prefered method to retrieve from: PWS or LOCID -- notifications WU.notifications = true; -- send notifications WU.push_fcst1 = "11:30"; -- time when forecast for today will be pushed to smartphone WU.push_fcst2 = "18:15"; -- time when forecast for tonight will be pushed to smartphone WU.notificationTypes = {"push", "email"}; -- notification types {"push", "email", "sms"} WU.smartphoneID = {1347}; -- Smartphone Id to send push to. {id1, id2, id3} WU.userID = {2}; -- User Id to send email to. {id1, id2, id3} WU.sms = { ["VD_ID"] = 0, -- Virtual Device ID ["VD_Button"] = "1", -- Virtual Device Button ["VG_Name"] = "SMS"}; -- Global Variable Name WU.debug_messages = false; -- Diplay debug for notifications -- Other settings WU.translation = {true}; WU.language = "FR"; -- EN, FR, SW, PL (default is en) WU.GEA = true; -- subst % with %% when storing in the VG's (because gea bug with % in push messages) WU.CreateVG = true; -- will atomaticaly create global variables at first run if = true WU.updateEvery = 30; -- get data every xx minutes -- Do not change WU.startTime = os.time(); WU.scheduler = os.time()+60*WU.updateEvery; WU.currentDate = os.date("*t"); WU.now = os.date("%H:%M"); WU.DoNotRecheckBefore = os.time(); WU.selfId = fibaro:getSelfId(); WU.version = "3.9"; WU.translation["EN"] = { Push_forecast = "Push forecast", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "Temperature", Humidity = "Humidity", Pressure = "Pressure", Wind = "Wind", Rain = "Rain", Forecast = "Forecast", EmailSubject = "Meteo of this", Station = "Station", Fetched = "Fetched", Data_processed = "Data processed", Update_interval = "Next update will be in (min)", No_data_fetched = "No data fetched", NO_STATIONID_FOUND = "No stationID found", NO_DATA_FOUND = "No data found" }; WU.translation["FR"] = { Push_forecast = "Push des prévisions", Exiting_loop_slider = "Sortie de boucle (Slider Changé)", Exiting_loop_push = "Sortie de boucle (Pour Push)", Last_updated = "Mise à jour", Temperature = "Actuellement", Humidity = "Hum", Pressure = "Pression", Wind = "Vent", Rain = "Pluie", Forecast = "", EmailSubject = "Météo de ce", Station = "Station", Fetched = "Données reçues", Data_processed = "Données mises à jour", Update_interval = "Prochaine Mise à jour prévue dans (min)", No_data_fetched = "Pas de données reçues !!", NO_STATIONID_FOUND = "StationID non trouvée !!", NO_DATA_FOUND = "Pas de données disponibles !!" }; WU.translation["SW"] = { Push_forecast = "Push forecast", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "Temperatur", Humidity = "Fuktighet", Pressure = "Barometer", Wind = "Vind", Rain = "Regn", Forecast = "Prognos", EmailSubject = "Meteo of this", Station = "Station", Fetched = "Hà¤mtat", Data_processed = "All data processat", Update_interval = "Nà¤sta uppdatering à¤r om (min)", No_data_fetched = "Inget data hà¤mtat", NO_STATIONID_FOUND = "StationID ej funnet", NO_DATA_FOUND = "Ingen data hos WU" }; WU.translation["PL"] = { Push_forecast = "Push prognoza", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "Temperatura", Humidity = "Wilgotnosc", Pressure = "Pressure", Wind = "Wiatr", Rain = "Rain", Forecast = "Forecast", EmailSubject = "Meteo of this", Station = "Station", Fetched = "Fetched", Data_processed = "Data processed", No_data_fetched = "No data fetched", Update_interval = "Next update will be in (min)", NO_STATIONID_FOUND = "No stationID found", NO_DATA_FOUND = "No data found" }; WU.translation["NL"] = { Push_forecast = "Push verwachting", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "Temperatuur", Humidity = "Vochtigheid", Pressure = "Druk", Wind = "Wind", Rain = "Regen", Forecast = "Verwachting", EmailSubject = "Meteo of this", Station = "Weerstation", Fetched = "Ontvangen", Data_processed = "Gegevens verwerkt", Update_interval = "Volgende update in (min)", No_data_fetched = "Geen gegevens ontvangen", NO_STATIONID_FOUND = "Geen stationID gevonden", NO_DATA_FOUND = "Geen gegevens gevonden" }; WU.translation["DE"] = { Push_forecast = "Push vorhersage", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "Temperatur", Humidity = "Luftfeuchtigkeit", Pressure = "Luftdruck", Wind = "Wind", Rain = "Regen", Forecast = "Vorhersage", EmailSubject = "Meteo of this", Station = "Station", Fetched = "Abgerufen", Data_processed = "Daten verarbeitet", No_data_fetched = "Keine Daten abgerufen", Update_interval = "Das nà¤chste Update in (min)", NO_STATIONID_FOUND = "Keine stationID gefunden", NO_DATA_FOUND = "Keine Daten gefunden" }; Debug = function (color, message) if color and color ~= "" then fibaro:debug('<span style="color:'..color..';">'..message..'</span>'); else fibaro:debug(message); end end WU.notification = function(message, subject, param) local message = message or "<vide>"; if WU.debug_messages then Debug("yellow", "Notification : "..message); end if param then for _, notif in ipairs(param) do if WU.debug_messages then Debug("grey", notif); end -- Envoi Push if notif == "push" and WU.smartphoneID then for _, id in ipairs(WU.smartphoneID) do if WU.debug_messages then Debug("grey", "Send Push smartphone ID : "..id); end fibaro:call(id, "sendPush", message); end -- Envoi Email elseif notif == "email" and WU.userID then for _, id in ipairs(WU.userID) do if WU.debug_messages then Debug("grey", "Send Email user ID : "..id); end fibaro:call(id, "sendEmail", subject, message); end -- Envoi SMS elseif notif == "sms" and WU.sms then if WU.debug_messages then Debug("grey", "Send SMS : VD_ID="..(WU.sms["VD_ID"] or 0).." VD_Button="..(WU.sms["VD_Button"] or "0").." VG_Name="..(WU.sms["VG_Name"] or "")); end fibaro:setGlobal(WU.sms["VG_Name"], message); if WU.sms["VD_ID"] and tonumber(WU.sms["VD_ID"])>0 and WU.sms["VD_Button"] and tonumber(WU.sms["VD_Button"])>0 then fibaro:call(WU.sms["VD_ID"], "pressButton", WU.sms["VD_Button"]); end end end else Debug("orange", "Warning : no notification options given"); end end WU.createGlobalIfNotExists = function(varName, defaultValue) if (fibaro:getGlobal(varName) == "") then Debug("red", "Global Var: "..varName.." HAS BEEN CREATED"); newVar = {}; newVar.name = varName; HC2 = Net.FHttp("127.0.0.1", 11111); HC2:POST("/api/globalVariables", json.encode(newVar)); end end WU.substPercent = function(doublePercentSymbol) if WU.GEA then doublePercentSymbol = string.gsub(doublePercentSymbol, "%%.", "%%%%"); end return doublePercentSymbol; end WU.cleanJson = function(jsontocheck,returnIfTrue) if jsontocheck == "-999.00" or jsontocheck == "--" or jsontocheck == json.null then jsontocheck = returnIfTrue; end local ok = pcall(function() testConcatenate = "Test Concatenate: " .. jsontocheck; -- test for non concatenate value end ) if (not ok) then decode_error = true; Debug( "red", "decode raised an error"); if WU.notifications then WU.notification("decode error in WU Meteo","Got a Decode Error in WU Meteo.", WU.notificationTypes); end end return jsontocheck; end WU.HtmlColor = function(StringToColor,color) if MobileDisplay == false then StringToColor= "<font color=\""..color.."\"> "..StringToColor.."</font>"; end return StringToColor; end WU.IconOrText = function(icon,txt) if MobileDisplay == false then IconOrText = "<img src="..icon.."\>"; else IconOrText = txt; end return IconOrText; end WU.HtmlOrText = function(_html,txt) if MobileDisplay == false then HtmlOrText = _html; else HtmlOrText = txt; end return HtmlOrText; end WU.getSlider = function() ValeurSliderfunct = fibaro:getValue(WU.selfId , "ui.WebOrMobile.value"); return tonumber(ValeurSliderfunct); end WU.setSlider = function(position) fibaro:call(WU.selfId , "setProperty", "ui.WebOrMobile.value", position); return WU.getSlider(); end WU.checkMobileOrWeb = function() ValeurSliderSleep = WU.getSlider(); -- check slider value at first run if ValeurSliderSleep <= 50 then if ValeurSliderSleep == 1 then MobileDisplay = false; else MobileDisplay = false; WU.runDirect = 1; sleepAndcheckslider = 20*WU.updateEvery; -- exit wait loop Debug("orange", WU.translation[WU.language]["Exiting_loop_slider"]); end WU.setSlider(1); -- désactive le run immediat lors du prochain test end if ValeurSliderSleep >= 50 then if ValeurSliderSleep == 98 then else MobileDisplay = true; WU.runDirect = 1; sleepAndcheckslider = 20*WU.updateEvery; -- exit wait loop Debug("orange", WU.translation[WU.language]["Exiting_loop_slider"]); end WU.setSlider(98); -- désactive le run immediat lors du prochain test end return WU.getSlider(); end WU.fetchWU = function() decode_error = false; WU.checkMobileOrWeb(); local WGROUND = Net.FHttp("api.wunderground.com",80); local response ,status, err = WGROUND:GET("/api/"..WU.APIkey.."/conditions/forecast/lang:"..WU.language.."/q/"..WU.station..":"..locationID..".json"); if (tonumber(status) == 200 and tonumber(err)==0) then Debug( "cyan", WU.translation[WU.language]["Fetched"]); if (response ~= nil) then WU.now = os.date("%H:%M"); jsonTable = json.decode(response); if jsonTable.response.error ~= nil then Debug( "red", WU.translation[WU.language]["NO_DATA_FOUND"]); fibaro:sleep(15*1000); Debug( "yellow", WU.translation[WU.language]["NO_DATA_FOUND"]); fibaro:sleep(15*1000); return end stationID = jsonTable.current_observation.station_id; humidity = jsonTable.current_observation.relative_humidity; temperature = jsonTable.current_observation.temp_c; pression = jsonTable.current_observation.pressure_mb; wind = jsonTable.current_observation.wind_kph; rain = WU.cleanJson(jsonTable.current_observation.precip_today_metric,"0"); weathericon = jsonTable.current_observation.icon_url; -- Day meteo fcstday1 = jsonTable.forecast.txt_forecast.forecastday[1].title; fcst1 = jsonTable.forecast.txt_forecast.forecastday[1].fcttext_metric; fcst1icon = jsonTable.forecast.txt_forecast.forecastday[1].icon_url; -- Evening Meteo fcstday2 = jsonTable.forecast.txt_forecast.forecastday[2].title; fcst2 = jsonTable.forecast.txt_forecast.forecastday[2].fcttext_metric; fcst2icon = jsonTable.forecast.txt_forecast.forecastday[2].icon_url; -- Tomorrow Meteo fcstday3 = jsonTable.forecast.txt_forecast.forecastday[3].title; fcst3 = jsonTable.forecast.txt_forecast.forecastday[3].fcttext_metric; fcst3icon = jsonTable.forecast.txt_forecast.forecastday[3].icon_url; -- In 2 days fcstday5 = jsonTable.forecast.txt_forecast.forecastday[5].title; fcst5 = jsonTable.forecast.txt_forecast.forecastday[5].fcttext_metric; fcst5icon = jsonTable.forecast.txt_forecast.forecastday[5].icon_url; -- SimpleForecast Today fcst1SmallTxt = jsonTable.forecast.simpleforecast.forecastday[1].conditions; fcst1Tmax = jsonTable.forecast.simpleforecast.forecastday[1].high.celsius; fcst1Tmin = jsonTable.forecast.simpleforecast.forecastday[1].low.celsius; fcst1avewind =jsonTable.forecast.simpleforecast.forecastday[1].avewind.kph; fcst1avewinddir =jsonTable.forecast.simpleforecast.forecastday[1].avewind.dir; fcst1mm = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[1].qpf_day.mm,"0"); -- SimpleForecast Tomorrow fcst2SmallTxt = jsonTable.forecast.simpleforecast.forecastday[2].conditions; fcst2Tmax = jsonTable.forecast.simpleforecast.forecastday[2].high.celsius; fcst2Tmin = jsonTable.forecast.simpleforecast.forecastday[2].low.celsius; fcst2avewind =jsonTable.forecast.simpleforecast.forecastday[2].avewind.kph; fcst2avewinddir =jsonTable.forecast.simpleforecast.forecastday[2].avewind.dir; fcst2mm = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[2].qpf_night.mm,"0"); -- In 2 days fcst3SmallTxt = jsonTable.forecast.simpleforecast.forecastday[3].conditions; fcst3Tmax = jsonTable.forecast.simpleforecast.forecastday[3].high.celsius; fcst3Tmin = jsonTable.forecast.simpleforecast.forecastday[3].low.celsius; fcst3avewind =jsonTable.forecast.simpleforecast.forecastday[3].avewind.kph; fcst3avewinddir =jsonTable.forecast.simpleforecast.forecastday[3].avewind.dir; fcst3mm = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[3].qpf_allday.mm,"0"); if (stationID ~= nil) and decode_error == false then fibaro:call(WU.selfId , "setProperty", "ui.lblStation.value", locationID); if temperature < 5 then cTemperature = WU.HtmlColor(temperature,"00bfff"); elseif temperature > 18 then cTemperature = WU.HtmlColor(temperature,"ff4500"); else cTemperature = WU.HtmlColor(temperature,"ffd700"); end fibaro:call(WU.selfId , "setProperty", "ui.lblTempHum.value", WU.translation[WU.language]["Temperature"]..": "..cTemperature.." °C - "..WU.translation[WU.language]["Humidity"]..": "..humidity); fibaro:call(WU.selfId , "setProperty", "ui.lblWindRain.value", WU.translation[WU.language]["Wind"]..": "..wind.." km/h - "..WU.translation[WU.language]["Rain"]..": "..rain.." mm"); if (WU.now >= "03:00" and WU.now <= "15:59") then -- donne meteo du jour entre 00:00 (ou 3h) et 15:59. permet de garder la météo du soir jusqu'a 3h du matin, sinon change à minuit fibaro:call(WU.selfId , "setProperty", "ui.lblFcst.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday1,"ff4500")..": "..WU.HtmlColor(fcst1.." ("..fcst1mm.." mm)","b0c4de"), "["..fcst1Tmax.."° "..fcst1Tmin.."°] | "..fcst1mm.."mm | "..fcst1avewind.."Km/h ("..fcst1avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIcon.value",WU.IconOrText(fcst1icon,fcstday1..": "..fcst1SmallTxt)); fibaro:setGlobal("Meteo_Day", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday1..": ".." "..fcst1.." ("..fcst1mm.." mm)") ); elseif (WU.now >= "16:00" and WU.now <= "23:59") then -- donne meteo soirée entre 16:00 et 23:59 fibaro:call(WU.selfId , "setProperty", "ui.lblFcst.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday2,"ff4500")..": "..WU.HtmlColor(fcst2.." ("..fcst1mm.." mm)","b0c4de"), "["..fcst1Tmax.."° "..fcst1Tmin.."°] | "..fcst1mm.."mm | "..fcst1avewind.."Km/h ("..fcst1avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIcon.value",WU.IconOrText(fcst2icon,fcstday2..": "..fcst1SmallTxt)); fibaro:setGlobal("Meteo_Day", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday2..": ".." "..fcst2.." ("..fcst1mm.." mm)") ); end -- Meteo of Tomorrow fibaro:call(WU.selfId , "setProperty", "ui.lblFcstTomorrow.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday3,"ff4500")..": "..WU.HtmlColor(fcst3.." ("..fcst2mm.." mm)","b0c4de"), "["..fcst2Tmax.."° "..fcst2Tmin.."°] | "..fcst2mm.."mm | "..fcst2avewind.."Km/h ("..fcst2avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIconTomorrow.value",WU.IconOrText(fcst3icon,fcstday3..": "..fcst2SmallTxt)); fibaro:setGlobal("Meteo_Tomorrow", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday3..": ".." "..fcst3.." ("..fcst2mm.." mm)") ); -- Meteo in 2 Days fibaro:call(WU.selfId , "setProperty", "ui.lblFcst2Days.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday5,"ff4500")..": "..WU.HtmlColor(fcst5.." ("..fcst3mm.." mm)","b0c4de"), "["..fcst3Tmax.."° "..fcst3Tmin.."°] | "..fcst3mm.."mm | "..fcst3avewind.."Km/h ("..fcst3avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIcon2Days.value",WU.IconOrText(fcst5icon,fcstday5..": "..fcst3SmallTxt)); fibaro:setGlobal("Meteo_In_2_Days", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday5..": ".." "..fcst5.." ("..fcst3mm.." mm)") ); if WU.notifications then if (os.date("%H:%M") == WU.push_fcst1) then WU.notification(fcstday1.." - "..fcst1.." ("..fcst1mm.." mm)" , WU.translation[WU.language]["EmailSubject"].." "..fcstday1 , WU.notificationTypes); -- Send Morning meteo elseif (os.date("%H:%M") == WU.push_fcst2) then WU.notification( fcstday2.." - "..fcst2.." ("..fcst2mm.." mm)" , WU.translation[WU.language]["EmailSubject"].." "..fcstday2 , WU.notificationTypes); -- Send evening meteo end end if WU.notifications then fibaro:call(WU.selfId , "setProperty", "ui.lblNotify.value", WU.translation[WU.language]["Push_forecast"].." = true"); else fibaro:call(WU.selfId , "setProperty", "ui.lblNotify.value",WU.translation[WU.language]["Push_forecast"].." = false"); end WU.scheduler = os.time()+WU.updateEvery*60; fibaro:call(WU.selfId, "setProperty", "ui.lblUpdate.value", WU.translation[WU.language]["Last_updated"]..": "..os.date("%c")); Debug( "cyan", WU.translation[WU.language]["Data_processed"]); Debug( "white", WU.translation[WU.language]["Update_interval"].." "..WU.updateEvery); else Debug( "red", WU.translation[WU.language]["NO_STATIONID_FOUND"]); end else fibaro:debug("status:" .. status .. ", errorCode:" .. errorCode); end end sleepAndcheckslider = 0; while sleepAndcheckslider <= 20*WU.updateEvery do fibaro:sleep(3000); WU.checkMobileOrWeb(); sleepAndcheckslider = sleepAndcheckslider+1; if (WU.DoNotRecheckBefore <= os.time()) and ((WU.scheduler == os.time) or (os.date("%H:%M") == WU.push_fcst1) or (os.date("%H:%M") == WU.push_fcst2)) then Debug("orange", WU.translation[WU.language]["Exiting_loop_push"]); WU.DoNotRecheckBefore = os.time()+60; sleepAndcheckslider = 20*WU.updateEvery; end end end Debug( "orange", "10/2015 - WU Weather - Original LUA Scripting by Jonny Larsson 2015"); Debug( "orange", "11/2015 - YAMS WU - Fork by Sébastien Jauquet"); Debug( "orange", "Version: "..WU.version); if WU.station == "LOCID" then locationID = WU.LOCID; elseif WU.station == "PWS" then locationID = WU.PWS; end if WU.CreateVG then WU.createGlobalIfNotExists("Meteo_Day", ""); WU.createGlobalIfNotExists("Meteo_Tomorrow", ""); WU.createGlobalIfNotExists("Meteo_In_2_Days", ""); end while true do WU.fetchWU(); end 2
Yohan Posté(e) le 29 novembre 2015 Signaler Posté(e) le 29 novembre 2015 Installé ça fonctionne au top
sebcbien Posté(e) le 30 novembre 2015 Auteur Signaler Posté(e) le 30 novembre 2015 Et voici la "V4.0" ... non pas de bugs comme chez fibaro (enfin j'espère ) Ajouts: - plus de précision pour la pluie: (Journée/soirée) - Ajout de la T° ressentie: T°réelle / ressentie 10/8°C - Optimisation de l'affichage pour mobile. Si vous avez déjà le virtual device V3.9, il suffit de remplacer la code du main loop avec celui ci-dessous Code main loop à remplacer: ------------------------------------------------------------------------------------------- -- WU WeatherData - Fetch weather data from wunderground.com. Multilanguage support! -- Original Code by Jonny Larsson 2015 http://forum.fibaro.com/index.php?/topic/19810-wu-weatherdata-version-202-2015-10-25/ -- Forked by Sébastien Jauquet 11/2015 http://www.domotique-fibaro.fr/index.php/topic/6446-yams-wu-yet-another-meteo-station-wunderground-version/ -- Inspired by GEA(steven), stevenvd, Lazer, Krikroff and many other users. -- Source - forum.fibaro.com, domotique-fibaro.fr and worldwideweb -- 2014-03-22 - Permissions granted from Krikroff -- 2014-03-23 - Added rain and forecast, Added FR language. -- 2014-03-23 - Language variable changed to get the translation from wunderground.com in forcast -- 2014-03-24 - Added PL language -- 2014-03-24 - Select between PWS or LOCID to download weather data -- 2015-10-23 - New source code. -- 2015-11-16 - Permissions granted from Jonny Larsson -- 2015-11-13 - V3.0 - Fork Code by Sebastien Jauquet (3 days forecast, rain in mm) -- 2015-11-14 - V3.1 - Compatibilty with GEA, French translation -- 2015-11-14 - V3.2 - Catch rain errors (-999mm null empty etc.) -- 2015-11-14 - V3.3 - Catch json decode error (was stopping main loop) with pcall (can be extended to other jdon datas if needed) -- 2015-11-16 - V3.4 - Generate HTML and non HTML version (for compatibility with mobiles) -- 2015-11-18 - V3.5 - Fixed bug not updating Meteo_Day becaus WU.now was only updated at first launch -- 2015-11-18 - V3.6 - Merged some changes from jompa new version -- 2015-11-18 - Added autmatic creation of Global Variables if not existing -- 2015-11-19 - V3.7 - Modify schedule management and CleanUp code -- 2015-11-22 - V3.8 - Finalise mobile version and bug fixing -- 2015-11-23 - V3.9 - Added multiple notification options (Lazer way) -- 2015-11-30 - V4.0 - More precision for rain mm (moring/evening) + added feels like T° + optimized display -- Look for nearest station here: http://www.wunderground.com ------------------------------------------------------------------------------------------- -- MAIN CODE -- ------------------------------------------------------------------------------------------- WU = {}; -- WU settings WU.APIkey = "XXXXXXXXXxxxxxXX"; -- Put your WU api key here WU.PWS = "IGVLEBOR5"; -- The PWS location to get data from (Personal Weather Station) WU.LOCID = "SWXX0076"; -- The location ID to get data from (City location) WU.station = "PWS"; -- Choose your prefered method to retrieve from: PWS or LOCID -- notifications WU.notifications = true; -- send notifications WU.push_fcst1 = "11:30"; -- time when forecast for today will be pushed to smartphone WU.push_fcst2 = "18:15"; -- time when forecast for tonight will be pushed to smartphone WU.notificationTypes = {"push", "email"};--notification types {"push", "email", "sms"} WU.smartphoneID = {1347}; -- Smartphone Id to send push to. {id1, id2, id3} WU.userID = {2}; -- User Id to send email to. {id1, id2, id3} WU.sms = { ["VD_ID"] = 0, -- Virtual Device ID ["VD_Button"] = "1", -- Virtual Device Button ["VG_Name"] = "SMS"}; -- Global Variable Name WU.debug_messages = false; -- Diplay debug for notifications -- Other settings WU.translation = {true}; WU.language = "FR"; -- EN, FR, SW, PL (default is en) WU.GEA = true; -- subst % with %% when storing in the VG's (because gea bug with % in push messages) WU.CreateVG = true; -- will atomaticaly create global variables at first run if = true WU.updateEvery = 30; -- get data every xx minutes -- Do not change WU.startTime = os.time(); WU.scheduler = os.time()+60*WU.updateEvery; WU.currentDate = os.date("*t"); WU.now = os.date("%H:%M"); WU.DoNotRecheckBefore = os.time(); WU.selfId = fibaro:getSelfId(); WU.version = "4.0"; WU.translation["EN"] = { Push_forecast = "Push forecast", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "T°/Feels Like", Humidity = "Humidity", Pressure = "Pressure", Wind = "Wind", Rain = "Rain", Forecast = "Forecast", EmailSubject = "Meteo of this", Station = "Station", Fetched = "Fetched", Data_processed = "Data processed", Update_interval = "Next update will be in (min)", No_data_fetched = "No data fetched", NO_STATIONID_FOUND = "No stationID found", NO_DATA_FOUND = "No data found" }; WU.translation["FR"] = { Push_forecast = "Push des prévisions", Exiting_loop_slider = "Sortie de boucle (Slider Changé)", Exiting_loop_push = "Sortie de boucle (Pour Push)", Last_updated = "Mise à jour", Temperature = "T°/Ressentie", Humidity = "Humidité", Pressure = "Pression", Wind = "Vent", Rain = "Pluie", Forecast = "", EmailSubject = "Météo de ce", Station = "Station", Fetched = "Données reçues", Data_processed = "Données mises à jour", Update_interval = "Prochaine Mise à jour prévue dans (min)", No_data_fetched = "Pas de données reçues !!", NO_STATIONID_FOUND = "StationID non trouvée !!", NO_DATA_FOUND = "Pas de données disponibles !!" }; WU.translation["SW"] = { Push_forecast = "Push forecast", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "T°/Feels Like", Humidity = "Fuktighet", Pressure = "Barometer", Wind = "Vind", Rain = "Regn", Forecast = "Prognos", EmailSubject = "Meteo of this", Station = "Station", Fetched = "Hà¤mtat", Data_processed = "All data processat", Update_interval = "Nà¤sta uppdatering à¤r om (min)", No_data_fetched = "Inget data hà¤mtat", NO_STATIONID_FOUND = "StationID ej funnet", NO_DATA_FOUND = "Ingen data hos WU" }; WU.translation["PL"] = { Push_forecast = "Push prognoza", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "T°/Feels Like", Humidity = "Wilgotnosc", Pressure = "Pressure", Wind = "Wiatr", Rain = "Rain", Forecast = "Forecast", EmailSubject = "Meteo of this", Station = "Station", Fetched = "Fetched", Data_processed = "Data processed", No_data_fetched = "No data fetched", Update_interval = "Next update will be in (min)", NO_STATIONID_FOUND = "No stationID found", NO_DATA_FOUND = "No data found" }; WU.translation["NL"] = { Push_forecast = "Push verwachting", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "T°/Feels Like", Humidity = "Vochtigheid", Pressure = "Druk", Wind = "Wind", Rain = "Regen", Forecast = "Verwachting", EmailSubject = "Meteo of this", Station = "Weerstation", Fetched = "Ontvangen", Data_processed = "Gegevens verwerkt", Update_interval = "Volgende update in (min)", No_data_fetched = "Geen gegevens ontvangen", NO_STATIONID_FOUND = "Geen stationID gevonden", NO_DATA_FOUND = "Geen gegevens gevonden" }; WU.translation["DE"] = { Push_forecast = "Push vorhersage", Exiting_loop_slider = "Exiting loop earlier (Slider Changed)", Exiting_loop_push = "Exiting loop earlier (For push)", Last_updated = "Last updated", Temperature = "T°/Feels Like", Humidity = "Luftfeuchtigkeit", Pressure = "Luftdruck", Wind = "Wind", Rain = "Regen", Forecast = "Vorhersage", EmailSubject = "Meteo of this", Station = "Station", Fetched = "Abgerufen", Data_processed = "Daten verarbeitet", No_data_fetched = "Keine Daten abgerufen", Update_interval = "Das nà¤chste Update in (min)", NO_STATIONID_FOUND = "Keine stationID gefunden", NO_DATA_FOUND = "Keine Daten gefunden" }; Debug = function (color, message) if color and color ~= "" then fibaro:debug('<span style="color:'..color..';">'..message..'</span>'); else fibaro:debug(message); end end WU.notification = function(message, subject, param) local message = message or "<vide>"; if WU.debug_messages then Debug("yellow", "Notification : "..message); end if param then for _, notif in ipairs(param) do if WU.debug_messages then Debug("grey", notif); end -- Envoi Push if notif == "push" and WU.smartphoneID then for _, id in ipairs(WU.smartphoneID) do if WU.debug_messages then Debug("grey", "Send Push smartphone ID : "..id); end fibaro:call(id, "sendPush", message); end -- Envoi Email elseif notif == "email" and WU.userID then for _, id in ipairs(WU.userID) do if WU.debug_messages then Debug("grey", "Send Email user ID : "..id); end fibaro:call(id, "sendEmail", subject, message); end -- Envoi SMS elseif notif == "sms" and WU.sms then if WU.debug_messages then Debug("grey", "Send SMS : VD_ID="..(WU.sms["VD_ID"] or 0).." VD_Button="..(WU.sms["VD_Button"] or "0").." VG_Name="..(WU.sms["VG_Name"] or "")); end fibaro:setGlobal(WU.sms["VG_Name"], message); if WU.sms["VD_ID"] and tonumber(WU.sms["VD_ID"])>0 and WU.sms["VD_Button"] and tonumber(WU.sms["VD_Button"])>0 then fibaro:call(WU.sms["VD_ID"], "pressButton", WU.sms["VD_Button"]); end end end else Debug("orange", "Warning : no notification options given"); end end WU.createGlobalIfNotExists = function(varName, defaultValue) if (fibaro:getGlobal(varName) == "") then Debug("red", "Global Var: "..varName.." HAS BEEN CREATED"); newVar = {}; newVar.name = varName; HC2 = Net.FHttp("127.0.0.1", 11111); HC2:POST("/api/globalVariables", json.encode(newVar)); end end WU.substPercent = function(doublePercentSymbol) if WU.GEA then doublePercentSymbol = string.gsub(doublePercentSymbol, "%%.", "%%%%"); end return doublePercentSymbol; end WU.cleanJson = function(jsontocheck,returnIfTrue) if jsontocheck == "-999.00" or jsontocheck == "--" or jsontocheck == json.null then jsontocheck = returnIfTrue; end local ok = pcall(function() testConcatenate = "Test Concatenate: " .. jsontocheck; -- test for non concatenate value end ) if (not ok) then decode_error = true; Debug( "red", "decode raised an error"); if WU.notifications then WU.notification("decode error in WU Meteo","Got a Decode Error in WU Meteo.", WU.notificationTypes); end end return jsontocheck; end WU.HtmlColor = function(StringToColor,color) if MobileDisplay == false then StringToColor= "<font color=\""..color.."\"> "..StringToColor.."</font>"; end return StringToColor; end WU.IconOrText = function(icon,txt) if MobileDisplay == false then IconOrText = "<img src="..icon.."\>"; else IconOrText = txt; end return IconOrText; end WU.HtmlOrText = function(_html,txt) if MobileDisplay == false then HtmlOrText = _html; else HtmlOrText = txt; end return HtmlOrText; end WU.getSlider = function() ValeurSliderfunct = fibaro:getValue(WU.selfId , "ui.WebOrMobile.value"); return tonumber(ValeurSliderfunct); end WU.setSlider = function(position) fibaro:call(WU.selfId , "setProperty", "ui.WebOrMobile.value", position); return WU.getSlider(); end WU.checkMobileOrWeb = function() ValeurSliderSleep = WU.getSlider(); -- check slider value at first run if ValeurSliderSleep <= 50 then if ValeurSliderSleep == 1 then MobileDisplay = false; else MobileDisplay = false; WU.runDirect = 1; sleepAndcheckslider = 20*WU.updateEvery; -- exit wait loop Debug("orange", WU.translation[WU.language]["Exiting_loop_slider"]); end WU.setSlider(1); -- désactive le run immediat lors du prochain test end if ValeurSliderSleep >= 50 then if ValeurSliderSleep == 98 then else MobileDisplay = true; WU.runDirect = 1; sleepAndcheckslider = 20*WU.updateEvery; -- exit wait loop Debug("orange", WU.translation[WU.language]["Exiting_loop_slider"]); end WU.setSlider(98); -- désactive le run immediat lors du prochain test end return WU.getSlider(); end WU.fetchWU = function() decode_error = false; WU.checkMobileOrWeb(); local WGROUND = Net.FHttp("api.wunderground.com",80); local response ,status, err = WGROUND:GET("/api/"..WU.APIkey.."/conditions/forecast/lang:"..WU.language.."/q/"..WU.station..":"..locationID..".json"); if (tonumber(status) == 200 and tonumber(err)==0) then Debug( "cyan", WU.translation[WU.language]["Fetched"]); if (response ~= nil) then WU.now = os.date("%H:%M"); jsonTable = json.decode(response); if jsonTable.response.error ~= nil then Debug( "red", WU.translation[WU.language]["NO_DATA_FOUND"]); fibaro:sleep(15*1000); Debug( "yellow", WU.translation[WU.language]["NO_DATA_FOUND"]); fibaro:sleep(15*1000); return end -- current observation stationID = jsonTable.current_observation.station_id; humidity = jsonTable.current_observation.relative_humidity; temperature = jsonTable.current_observation.temp_c; pression = jsonTable.current_observation.pressure_mb; wind = jsonTable.current_observation.wind_kph; rain = WU.cleanJson(jsonTable.current_observation.precip_today_metric,"0"); weathericon = jsonTable.current_observation.icon_url; feelslike_c = jsonTable.current_observation.feelslike_c; temperatureWithFeels = temperature.."/"..feelslike_c -- Today meteo fcstday1 = jsonTable.forecast.txt_forecast.forecastday[1].title; fcst1 = jsonTable.forecast.txt_forecast.forecastday[1].fcttext_metric; fcst1icon = jsonTable.forecast.txt_forecast.forecastday[1].icon_url; -- Today Evening Meteo fcstday2 = jsonTable.forecast.txt_forecast.forecastday[2].title; fcst2 = jsonTable.forecast.txt_forecast.forecastday[2].fcttext_metric; fcst2icon = jsonTable.forecast.txt_forecast.forecastday[2].icon_url; -- Tomorrow Morning Meteo fcstday3 = jsonTable.forecast.txt_forecast.forecastday[3].title; fcst3 = jsonTable.forecast.txt_forecast.forecastday[3].fcttext_metric; fcst3icon = jsonTable.forecast.txt_forecast.forecastday[3].icon_url; -- In 2 days Morning Meteo fcstday5 = jsonTable.forecast.txt_forecast.forecastday[5].title; fcst5 = jsonTable.forecast.txt_forecast.forecastday[5].fcttext_metric; fcst5icon = jsonTable.forecast.txt_forecast.forecastday[5].icon_url; -- SimpleForecast Today Meteo (Complete day) fcst1SmallTxt = jsonTable.forecast.simpleforecast.forecastday[1].conditions; fcst1Tmax = jsonTable.forecast.simpleforecast.forecastday[1].high.celsius; fcst1Tmin = jsonTable.forecast.simpleforecast.forecastday[1].low.celsius; fcst1avewind =jsonTable.forecast.simpleforecast.forecastday[1].avewind.kph; fcst1avewinddir =jsonTable.forecast.simpleforecast.forecastday[1].avewind.dir; fcst1mmday = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[1].qpf_day.mm,"0"); fcst1mmnight = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[1].qpf_night.mm,"0"); fcst1mm = fcst1mmday.."/"..fcst1mmnight -- SimpleForecast Tomorrow Meteo (Complete day) fcst2SmallTxt = jsonTable.forecast.simpleforecast.forecastday[2].conditions; fcst2Tmax = jsonTable.forecast.simpleforecast.forecastday[2].high.celsius; fcst2Tmin = jsonTable.forecast.simpleforecast.forecastday[2].low.celsius; fcst2avewind =jsonTable.forecast.simpleforecast.forecastday[2].avewind.kph; fcst2avewinddir =jsonTable.forecast.simpleforecast.forecastday[2].avewind.dir; fcst2mmday = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[2].qpf_day.mm,"0"); fcst2mmnight = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[2].qpf_night.mm,"0"); fcst2mm = fcst2mmday.."/"..fcst2mmnight -- In 2 days Meteo (Complete day) fcst3SmallTxt = jsonTable.forecast.simpleforecast.forecastday[3].conditions; fcst3Tmax = jsonTable.forecast.simpleforecast.forecastday[3].high.celsius; fcst3Tmin = jsonTable.forecast.simpleforecast.forecastday[3].low.celsius; fcst3avewind =jsonTable.forecast.simpleforecast.forecastday[3].avewind.kph; fcst3avewinddir =jsonTable.forecast.simpleforecast.forecastday[3].avewind.dir; fcst3mmday = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[3].qpf_day.mm,"0"); fcst3mmnight = WU.cleanJson(jsonTable.forecast.simpleforecast.forecastday[3].qpf_night.mm,"0"); fcst3mm = fcst3mmday.."/"..fcst3mmnight if (stationID ~= nil) and decode_error == false then fibaro:call(WU.selfId , "setProperty", "ui.lblStation.value", locationID); if temperature < 5 then cTemperature = WU.HtmlColor(temperatureWithFeels,"00bfff"); elseif temperature > 18 then cTemperature = WU.HtmlColor(temperatureWithFeels,"ff4500"); else cTemperature = WU.HtmlColor(temperatureWithFeels,"ffd700"); end fibaro:call(WU.selfId , "setProperty", "ui.lblTempHum.value", WU.translation[WU.language]["Temperature"]..": "..cTemperature.."°C | "..humidity.." "..WU.translation[WU.language]["Humidity"]); fibaro:call(WU.selfId , "setProperty", "ui.lblWindRain.value", WU.translation[WU.language]["Wind"]..": "..wind.." km/h - "..WU.translation[WU.language]["Rain"]..": "..rain.." mm"); if (WU.now >= "03:00" and WU.now <= "15:59") then -- donne meteo du jour entre 00:00 (ou 3h) et 15:59. permet de garder la météo du soir jusqu'a 3h du matin, sinon change à minuit fibaro:call(WU.selfId , "setProperty", "ui.lblFcst.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday1,"ff4500")..": "..WU.HtmlColor(fcst1.." ("..fcst1mm.." mm)","b0c4de"), fcst1Tmax.."°/"..fcst1Tmin.."° | "..fcst1mm.."mm | "..fcst1avewind.."Km/h ("..fcst1avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIcon.value",WU.IconOrText(fcst1icon,fcstday1..": "..fcst1SmallTxt)); fibaro:setGlobal("Meteo_Day", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday1..": ".." "..fcst1.." ("..fcst1mm.." mm)") ); elseif (WU.now >= "16:00" and WU.now <= "23:59") then -- donne meteo soirée entre 16:00 et 23:59 fibaro:call(WU.selfId , "setProperty", "ui.lblFcst.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday2,"ff4500")..": "..WU.HtmlColor(fcst2.." ("..fcst1mm.." mm)","b0c4de"), fcst1Tmax.."°/"..fcst1Tmin.."° | "..fcst1mm.."mm | "..fcst1avewind.."Km/h ("..fcst1avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIcon.value",WU.IconOrText(fcst2icon,fcstday2..": "..fcst1SmallTxt)); fibaro:setGlobal("Meteo_Day", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday2..": ".." "..fcst2.." ("..fcst1mm.." mm)") ); end -- Meteo of Tomorrow fibaro:call(WU.selfId , "setProperty", "ui.lblFcstTomorrow.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday3,"ff4500")..": "..WU.HtmlColor(fcst3.." ("..fcst2mm.." mm)","b0c4de"), fcst2Tmax.."°/"..fcst2Tmin.."° | "..fcst2mm.."mm | "..fcst2avewind.."Km/h ("..fcst2avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIconTomorrow.value",WU.IconOrText(fcst3icon,fcstday3..": "..fcst2SmallTxt)); fibaro:setGlobal("Meteo_Tomorrow", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday3..": ".." "..fcst3.." ("..fcst2mm.." mm)") ); -- Meteo in 2 Days fibaro:call(WU.selfId , "setProperty", "ui.lblFcst2Days.value", WU.HtmlOrText( WU.HtmlColor(WU.translation[WU.language]["Forecast"],"c0c0c0").." "..WU.HtmlColor(fcstday5,"ff4500")..": "..WU.HtmlColor(fcst5.." ("..fcst3mm.." mm)","b0c4de"), fcst3Tmax.."°/"..fcst3Tmin.."° | "..fcst3mm.."mm | "..fcst3avewind.."Km/h ("..fcst3avewinddir..")")); fibaro:call(WU.selfId , "setProperty", "ui.lblIcon2Days.value",WU.IconOrText(fcst5icon,fcstday5..": "..fcst3SmallTxt)); fibaro:setGlobal("Meteo_In_2_Days", WU.substPercent(WU.translation[WU.language]["Forecast"].." "..fcstday5..": ".." "..fcst5.." ("..fcst3mm.." mm)") ); if WU.notifications then if (os.date("%H:%M") == WU.push_fcst1) then WU.notification(fcstday1.." - "..fcst1.." ("..fcst1mm.." mm)" , WU.translation[WU.language]["EmailSubject"].." "..fcstday1 , WU.notificationTypes); -- Send Morning meteo elseif (os.date("%H:%M") == WU.push_fcst2) then WU.notification( fcstday2.." - "..fcst2.." ("..fcst2mm.." mm)" , WU.translation[WU.language]["EmailSubject"].." "..fcstday2 , WU.notificationTypes); -- Send evening meteo end end if WU.notifications then fibaro:call(WU.selfId , "setProperty", "ui.lblNotify.value", WU.translation[WU.language]["Push_forecast"].." = true"); else fibaro:call(WU.selfId , "setProperty", "ui.lblNotify.value",WU.translation[WU.language]["Push_forecast"].." = false"); end WU.scheduler = os.time()+WU.updateEvery*60; fibaro:call(WU.selfId, "setProperty", "ui.lblUpdate.value", WU.translation[WU.language]["Last_updated"]..": "..os.date("%c")); Debug( "cyan", WU.translation[WU.language]["Data_processed"]); Debug( "white", WU.translation[WU.language]["Update_interval"].." "..WU.updateEvery); else Debug( "red", WU.translation[WU.language]["NO_STATIONID_FOUND"]); end else fibaro:debug("status:" .. status .. ", errorCode:" .. errorCode); end end sleepAndcheckslider = 0; while sleepAndcheckslider <= 20*WU.updateEvery do fibaro:sleep(3000); WU.checkMobileOrWeb(); sleepAndcheckslider = sleepAndcheckslider+1; if (WU.DoNotRecheckBefore <= os.time()) and ((WU.scheduler == os.time) or (os.date("%H:%M") == WU.push_fcst1) or (os.date("%H:%M") == WU.push_fcst2)) then Debug("orange", WU.translation[WU.language]["Exiting_loop_push"]); WU.DoNotRecheckBefore = os.time()+60; sleepAndcheckslider = 20*WU.updateEvery; end end end Debug( "orange", "10/2015 - WU Weather - Original LUA Scripting by Jonny Larsson 2015"); Debug( "orange", "11/2015 - YAMS WU - Fork by Sébastien Jauquet"); Debug( "orange", "Version: "..WU.version); if WU.station == "LOCID" then locationID = WU.LOCID; elseif WU.station == "PWS" then locationID = WU.PWS; end if WU.CreateVG then WU.createGlobalIfNotExists("Meteo_Day", ""); WU.createGlobalIfNotExists("Meteo_Tomorrow", ""); WU.createGlobalIfNotExists("Meteo_In_2_Days", ""); end while true do WU.fetchWU(); end 2
kead77 Posté(e) le 7 janvier 2016 Signaler Posté(e) le 7 janvier 2016 Bonjour Je joins la traduction de la langue italienne. Merci pour votre travail. WU.translation["IT"] = { Push_forecast = "Premere per previsione", Exiting_loop_slider = "Exiting loop earlier (Slider cambiato)", Exiting_loop_push = "Exiting loop earlier (Per Premere)", Last_updated = "Ultimo aggiornamento", Temperature = "T°/Percepita", Humidity = "Umidità ", Pressure = "Pressione", Wind = "Vento", Rain = "Pioggia", Forecast = "Previsione", EmailSubject = "Meteo di oggi", Station = "Stazione", Fetched = "Caricamento dati", Data_processed = "Dati caricati", Update_interval = "Prossimo aggiornamento tra (min)", No_data_fetched = "Nessun dato ricevuto !!", NO_STATIONID_FOUND = "StationID non trovata !!", NO_DATA_FOUND = "Nessun dato disponibile !!" }; 1
Messages recommandés