-
Compteur de contenus
4 189 -
Inscription
-
Dernière visite
-
Jours gagnés
85
Tout ce qui a été posté par sebcbien
-
Voici ce que ça donne sur une petite semaine: Ce qui m'étonne le plus c'est la constance de la diminution de la mémoire... Que la box soit utilisée ou non, la nuit, le jour, backup etc, la diminution semble constante... J'ai rajouté les lignes vert fluo pour bien illustrer cette tendance.
-
Moi je suis resté en 4.058, mais je dois les mettre en fin de liste pour que ça marche... Tu as du changer entre la 58 et la 59 ?Sent from my Note4
-
Merci krikroff, pas sur d'avoir saisi toutes les nuances de ta réponse, mais le principal c'est que ce soit équivalent :-) Je pense que je vais utiliser àl'avenir le [.] .... C'est plus joli ;-) Sent from my Note4
-
exemple: -- On dimme la lampe automatiquement après 90mn et on l'éteint après 20mn si pas d'action manuelle local malampegar = GEA.add({"Value+", id["LAMPE_GARAGE"],21}, 90*60, "",{{"Value", 20},{"Repeat"}}) local malampegardim = GEA.add({"Value-", id["LAMPE_GARAGE"],21}, 5*60, "",{{"Value", id["LAMPE_GARAGE"], 99},{"Function", function() fibaro:sleep(300) end},{"turnOff"},{"If", {{"Value+", id["LAMPE_GARAGE"], 1}}}},{"Repeat"}) -- Une action manuelle relance tout GEA.add( id["LAMPE_GARAGE"], -1, "", {{"Inverse"}, {"RestartTask", malampegar}, {"RestartTask", malampegardim}}) -----------------------------------------------
- 12 330 réponses
-
- 1
-
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
non, tout les gea.add qui vont suivre (ceux avec un delais 30, 60 240 etc, pas les -1)
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
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
-
Regarde dans le showroom gea, j'ai posté un exemple avec la lampe de mon garage, je la fais clignotter une fois puis je l'éteins un peu après.Faire très attention avec les sleep et gea, car toutes les commandes suivantes vont être retardées. Ne jamais non plus dépasser les 30s en tout sinon ça va aller moins bien... Sent from my Note4
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
C'est possible mais ce ne sera pas plus rapide que 1 alternance par 30 secondes... Sent from my Note4
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
@lazer on peut pas compter sur lui, c bien connu ;-) Sent from my Note4
-
Oui. Pour la pomme je sais pas Sent from my Note4
-
C'est un refresh avec nettoyage du cache et si tu est derrière un proxy, ça force aussi le refresh du proxy Sent from my Note4
-
Idem Sent from my Note4
-
@pitp2 Ceci dit, il est facile dans le code d'avoir d'autres notifications. Soit décommenter des notifications, soit rajouter. -> ,"push" <- après "email" dans les accolades en fin de ligne notification et vice versa. SMS est aussi possible Sent from my Note4
-
Oui j'y suis allé mollo avec les notifications... Ding ding ding àchaque fois que la hc2 fais un truc. Par contre savoir que la simu àdémarré comme prévu quand je suis pas là, ça ça peut être utile... Et encore on ne devrais pas avoir àsurveiller... Mais ça c'est quand les poules auront des dents... Heuuu non, quand la hc2 sera stable... Sent from my Note4
-
@Syris met le code à jour avec le dernier de YAPS sur github (résoud le problème admin pour le mail) et fais attention à ne pas commenter les lignes comme ci-dessus ;-)
-
-- If next line is commented, no light will turn on after Simulation ends veut dire que l'on peut commenter la ligne suivante... pas la ligne même... ;-) Bref, au moins ça a permis de rajouter un nouveau notifieur, Je met github à jour.
-
Je viens de voir que tu as commenté des variable... --local Lights_On_at_end_Simulation = 0; -- If next line is commented, no light will turn on after Simulation ends --local Lights_On_at_end_Simulation = id["LAMPE_COULOIR"]; -- ID of a light (Only One) to turn on after Simulation ends (at specified Stop_hour & Stop_minute). Comment this line to turn off this feature --local Lights_On_if_Simulation_deactivated = 0; -- If next line is commented, no light will turn on after Simulation is stopped (by putting Simu_presence to 0) --local Lights_On_if_Simulation_deactivated = id["LAMPE_HALL"]; -- ID of a light (Only One) to turn on after Simulation is stopped (Simulation_). Comment this line to turn off this feature doit au moins etre comme ceci: local Lights_On_at_end_Simulation = 0; -- If next line is commented, no light will turn on after Simulation ends --local Lights_On_at_end_Simulation = id["LAMPE_COULOIR"]; -- ID of a light (Only One) to turn on after Simulation ends (at specified Stop_hour & Stop_minute). Comment this line to turn off this feature local Lights_On_if_Simulation_deactivated = 0; -- If next line is commented, no light will turn on after Simulation is stopped (by putting Simu_presence to 0) --local Lights_On_if_Simulation_deactivated = id["LAMPE_HALL"]; -- ID of a light (Only One) to turn on after Simulation is stopped (Simulation_). Comment this line to turn off this feature
-
Hmmm.... J'ai rajouté un check de plus pour gérer les listes vides. J'ai mis àjour le code ci-dessus
-
c'est quoi ce device "lumiere" juste avant le plantage ? [DEBUG] 15:54:04: Sun 29/11 Device: Lumiere Off [DEBUG] 15:54:04: line 252: attempt to concatenate local 'deviceID' (a nil value)
-
Bonjour, J'utilise depuis peu un développement du style: mais je me demande s'il n'y a pas mieux/plus efficace.. function Engine:test2(debugmessage) voici un petit test: Engine = {}; Engine.var1 = "petit test 2"; Engine.list1 = {"bonjour", "demain"}; Engine.test = function(debugmessage) fibaro:debug(debugmessage) end function Engine:test2(debugmessage) fibaro:debug(debugmessage) end Engine:test(Engine.var1) Engine.test(Engine.var1) Engine:test(Engine.list1) Engine.test(Engine.list1) fibaro:debug("----------------------------") Engine:test2(Engine.var1) Engine.test2(Engine.var1) Engine:test2(Engine.list1) Engine.test2(Engine.list1) ce qui donne: [DEBUG] 16:54:38: table: 0x94c1e68 [DEBUG] 16:54:38: petit test 2 [DEBUG] 16:54:38: table: 0x94c1e68 [DEBUG] 16:54:38: table: 0x94c29d8 [DEBUG] 16:54:38: ---------------------------- [DEBUG] 16:54:38: petit test 2 [DEBUG] 16:54:38: nil [DEBUG] 16:54:38: table: 0x94c29d8 [DEBUG] 16:54:38: nil Quelle est la méthode la plus efficace ? Je vois que @steven utilise dans gea cette méthode-ci: Engine.test = function(debugmessage)
-
voici le nouveau code V3.6.1 avec une nouvelle méthode de notification (multiples email, sms, push) Ca devrait résoudre votre bug de "nil value" Je n'ai pas encore fait beaucoup de tests, mais ça semble fonctionner correctement. Confirmez si ça fonctionne bien chez vous et je le mettrai sur github --[[ %% autostart %% properties %% globals Simu_presence --]] --------------------------------------- local version = "3.6.1"; -- YAPS Presence Simulation by SebcBien -- August 2015 --------------------------------------- --V3.6.1 -- added new notifications engine (sms, freesms, push, email) -- fixed bug "attempt to concatenate local 'deviceID' (a nil value)" --V3.5.2 - start push sent by email --V3.5.1 -- Fixed launch between midnight and endtime (if endtime is after midnight) -- clean up code midnight-endtime --V3.3.2 -- renamed all variables for more readability --V3.3.0 -- Fixed Override bug (no sleep time between lights) --V3.2.3 -- added sunset shifting possibility (add or remove minutes to startime -- added time stamp to push messages -- formated messages -- optimisation -- cleanup --V3.1.0 -- "complete" rewriting with unix times -- modified end time notification impacted by random and smooth TurnOff (End_simulation_time impact) -- exit is now exactly at End_simulation_time -- added smooth cut off of lights at ending time (function not triggered with deactivation) --V2.6.6 -- clean up debug messages -- added free sms notifications -- second fix to looping days bug --V2.6.0 to V2.6.5 -- Fixed bug when Random_max_TurnOff_duration = 0 -- Probably fixed End_simulation_time bug calculation when looping for days du to days are shorter now than the previous day -- Fixed bug not turning on Lights_On_at_end_Simulation when exiting Simulation -- added random end time + small stability changes and cleaning -- Added array of lights to turn on after Simulation, ONLY if Simu_presence = 1 (normal ending, not ended by setting Simu_presence to 0) -- Added the possibility to not have an always on lamp -- Added naming of devices in the debug during Simulation -- Added the possibility to select always on light during Simulation --V2.2.0 to 2.5.0 -- fixed Simulation starting if restarted between End_simulation_time & midnight -- fixed big bug Simulation restarting after end time -- small notification and debug changes -- Rewriting the engine -- now relaunch automatically the next day, even if Simu_presence has not changed -- Added Manual Stop variable -- added list of mobiles if (fibaro:countScenes() > 1) then fibaro:debug("Scene already active! Aborting this new instance !!"); fibaro:abort(); end --------------------- USER SETTINGS -------------------------------- local id = { LAMPE_SDB = 16, LAMPE_CH_AMIS = 24, LAMPE_SALON = 45, LAMPE_BUREAU = 49, LAMPE_HALL = 52, LAMPE_CELLIER = 56, LAMPE_CH_EMILIEN = 58, LAMPE_COULOIR = 1316, PHONE_SEB = 1347, ADMIN = 2, PHONE_GG = 1327 } local Stop_hour = "01"; -- Hour when you want Simulation to stop local Stop_minute = "30"; -- Minute of the hour you want Simulation to stop -- note 1: the script will not exit while waiting the random time of the last light turned on. So end time can be longer than specified end time. (even more with var Random_max_TurnOff_duration) -- note 2: if the global variable changes during the same wait time as above, it will exit immediately (when back home while Simulation runs) local Sunset_offset = -15 -- number of minutes before or after sunset to activate Simulation local Random_max_duration = 30; -- random time of light change in minutes --> here each device is on maximum 30min local Random_max_TurnOff_duration = 25; -- random time to add at the stop hour+stop minute so the Simulation can be more variable (0 to deactivate) local Lights_always_on = {id["LAMPE_BUREAU"],id["LAMPE_COULOIR"]} -- IDs of lights who will always stay on during Simulation - leave empty array if none -> {} local Random_lights = {id["LAMPE_SDB"],id["LAMPE_HALL"],id["LAMPE_CELLIER"],id["LAMPE_CH_AMIS"]} -- IDs of lights to use in Simulation --local Random_lights = {id["LAMPE_HALL"],id["LAMPE_CELLIER"],id["LAMPE_CH_AMIS"]} -- Reduced set for test purposes local Lights_On_at_end_Simulation = 0; -- If next line is commented, no light will turn on after Simulation ends local Lights_On_at_end_Simulation = id["LAMPE_COULOIR"]; -- ID of a light (Only One) to turn on after Simulation ends (at specified Stop_hour & Stop_minute). Comment this line to turn off this feature local Lights_On_if_Simulation_deactivated = 0; -- If next line is commented, no light will turn on after Simulation is stopped (by putting Simu_presence to 0) local Lights_On_if_Simulation_deactivated = id["LAMPE_HALL"]; -- ID of a light (Only One) to turn on after Simulation is stopped (Simulation_). Comment this line to turn off this feature YAPS_Engine = {}; YAPS_Engine.notifications = true; -- send notifications YAPS_Engine.notificationTypes = {"push", "email"}; --notification types {"push", "email", "sms"} but they are overriden in the code YAPS_Engine.Activate_FreeSms = false; -- activate push with Activate_FreeSms (Activate_Push must be true also) YAPS_Engine.smartphoneID = {id["PHONE_SEB"]}; -- Smartphone Id to send push to. {id1, id2, id3} YAPS_Engine.userID = {id["ADMIN"]}; -- User Id to send email to. {id1, id2, id3} YAPS_Engine.sms = { ["VD_ID"] = 0, -- Virtual Device ID ["VD_Button"] = "1", -- Virtual Device Button ["VG_Name"] = "SMS"}; -- Global Variable Name --------------------- USER SETTINGS END ---------------------------- ----------------------ADVANCED SETTINGS----------------------------- local Show_standard_debug = true; -- Debug displayed in white local Show_extra_debug = false; -- Debug displayed in orange -------------------------------------------------------------------- -------------------- DO NOT CHANGE CODE BELOW ---------------------- -------------------------------------------------------------------- local Number_of_lights = #Random_lights; -- numbers of light devices listed above local Simulation = fibaro:getGlobal("Simu_presence"); --value of the global value: Simulation is on or off local Manual_overide = fibaro:getGlobal("overideSimuSunset"); -- if = 1 then the Simulation is forced local Start_simulation_time = fibaro:getValue(1, "sunsetHour"); --Start Simulation when sunset local End_simulation_time,Sunrise_unix_hour,Sunset_unix_hour,Converted_var,Midnight,End_simulation_time_with_random_max_TurnOff,Sleep_between_TurnOff; local Is_first_launch = true; local NotifLoop = 0; function Debug(color, message) fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, os.date("%a %d/%m", os.time()).." "..message, "span")); end function ExtraDebug(debugMessage) if ( Show_extra_debug ) then Debug( "orange", debugMessage); end end function StandardDebug(debugMessage) if ( Show_standard_debug ) then Debug( "white", debugMessage); end end function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end function YAPS_Engine:notification(message, subject, param) local message = os.date("%H:%M", os.time()).." "..message or "<vide>"; if YAPS_Engine.debug_messages then ExtraDebug("yellow", "Notification : "..message); end if Activate_FreeSms then fibaro:setGlobal("Activate_FreeSms", message) ExtraDebug("Message ("..message..") sent to Activate_FreeSms"); end if param then for _, notif in ipairs(param) do if YAPS_Engine.debug_messages then ExtraDebug("grey", notif); end -- Envoi Push if notif == "push" and YAPS_Engine.smartphoneID then for _, id in ipairs(YAPS_Engine.smartphoneID) do if YAPS_Engine.debug_messages then ExtraDebug("grey", "Send Push smartphone ID : "..id); end fibaro:call(id, "sendPush", message); end -- Envoi Email elseif notif == "email" and YAPS_Engine.userID then for _, id in ipairs(YAPS_Engine.userID) do if YAPS_Engine.debug_messages then ExtraDebug("grey", "Send Email user ID : "..id); end fibaro:call(id, "sendEmail", subject, message); end -- Envoi SMS elseif notif == "sms" and YAPS_Engine.sms then if YAPS_Engine.debug_messages then ExtraDebug("grey", "Send SMS : VD_ID="..(YAPS_Engine.sms["VD_ID"] or 0).." VD_Button="..(YAPS_Engine.sms["VD_Button"] or "0").." VG_Name="..(YAPS_Engine.sms["VG_Name"] or "")); end fibaro:setGlobal(YAPS_Engine.sms["VG_Name"], message); if YAPS_Engine.sms["VD_ID"] and tonumber(YAPS_Engine.sms["VD_ID"])>0 and YAPS_Engine.sms["VD_Button"] and tonumber(YAPS_Engine.sms["VD_Button"])>0 then fibaro:call(YAPS_Engine.sms["VD_ID"], "pressButton", YAPS_Engine.sms["VD_Button"]); end end end else Debug("orange", "Warning : no notification options given"); end end function YAPS_Engine:UnixTimeCalc(Converted_var, hour, min) local time = os.time(); local date = os.date("*t", time); local year = date.year; local month = date.month; local day = date.day; unix_hour = os.time{year=year, month=month, day=day, hour=hour, min=min, sec=sec}; ExtraDebug("converted "..Converted_var..": "..hour..":"..min.." to Unix Time: "..unix_hour..")") return unix_hour end function YAPS_Engine:ReverseUnixTimeCalc(Converted_var,hour) reverse_unix = os.date("%H:%M", hour) ExtraDebug("Reverse converted Unix Time of "..Converted_var.." : "..hour.." To: "..reverse_unix) return reverse_unix end function YAPS_Engine:EndTimeCalc() local hour,min ExtraDebug ("Current Unix Time: "..os.time()) End_simulation_time = YAPS_Engine:UnixTimeCalc("Original planed End_simulation_time", Stop_hour, Stop_minute); -- generate End_simulation_time (changes at midnight) will not change during Simulation, only when ended Midnight = YAPS_Engine:UnixTimeCalc("Midnight", 00, 00); Sunset_unix_hour = fibaro:getValue(1,'sunsetHour'); hour = string.sub(Sunset_unix_hour, 1 , 2); min = string.sub(Sunset_unix_hour,4); Sunset_unix_hour = (YAPS_Engine:UnixTimeCalc("Sunset", hour, min))+Sunset_offset*60; -- if stop hour is between 00 and 12h then add 24 hours to End_simulation_time if tonumber(Stop_hour) <= 12 and (os.time() >= End_simulation_time) then End_simulation_time = End_simulation_time + 24*60*60 ExtraDebug ("stop hour <= 12, Added 24H to End_simulation_time (End_simulation_time is ending after midnignt)"); ExtraDebug ("New End_simulation_time: "..End_simulation_time); end if Random_max_TurnOff_duration ~= 0 and Number_of_lights > 1 then -- if Simulation = 1 then slow turn off, else turn off all immediately Sleep_between_TurnOff = round((math.random(Random_max_TurnOff_duration)/(Number_of_lights-1)),1); Sleep_between_TurnOff = math.random(Random_max_TurnOff_duration)/(Number_of_lights-1); ExtraDebug("Calculated sleeping between each turn off: "..Sleep_between_TurnOff.." min"); else Sleep_between_TurnOff = 0; ExtraDebug("No sleeping between turn off"); end End_simulation_time_with_random_max_TurnOff = End_simulation_time + ((Sleep_between_TurnOff*(Number_of_lights-1))*60) ExtraDebug("End_simulation_time_with_random_max_TurnOff: "..End_simulation_time_with_random_max_TurnOff); if ((os.time() < End_simulation_time) and (Sunset_unix_hour - End_simulation_time > 0) and (Is_first_launch == true)) then -- if calculation is done between midnight and End_simulation_time and sunset is wrongly calculated after endtime (at first start only) Sunset_unix_hour = Sunset_unix_hour - (24*60*60) + 70; -- remove 24h58m50s of sunsettime ExtraDebug ("launch after Midnight and before End_simulation_time, removed 24H to Sunset_unix_hour (Only at the first start)"); ExtraDebug ("New SunsetTime: "..Sunset_unix_hour); end Is_first_launch = false end -- Presence Simulation actions Main loop function YAPS_Engine:Launch() YAPS_Engine:notification("Presence Simulation started. Will stop at: "..YAPS_Engine:ReverseUnixTimeCalc("End_simulation_time", End_simulation_time).." + rand("..Random_max_TurnOff_duration.."min) : "..YAPS_Engine:ReverseUnixTimeCalc("End_simulation_time_with_random_max_TurnOff", End_simulation_time_with_random_max_TurnOff), "Presence Simulator", {"push"}); -- push only StandardDebug("Presence Simulation started. Will stop at: "..YAPS_Engine:ReverseUnixTimeCalc("End_simulation_time", End_simulation_time).." + rand("..Random_max_TurnOff_duration.."min) : "..YAPS_Engine:ReverseUnixTimeCalc("End_simulation_time_with_random_max_TurnOff", End_simulation_time_with_random_max_TurnOff)); if Lights_always_on[1] ~= nil then YAPS_Engine:TurnOn(Lights_always_on); end while ((os.time() <= End_simulation_time) and (Simulation == "1")) or ((Manual_overide == "1")) do local random_light = tonumber(Random_lights[math.random(Number_of_lights)]) --choose a random light in the list local lightstatus = fibaro:getValue(random_light, 'value') --get the value of the random light in the list -- turn on the light if off or turn off if on if tonumber(lightstatus) == 0 then fibaro:call(random_light, 'turnOn') else fibaro:call(random_light, 'turnOff') end fibaro:sleep(1000); -- necessary to get back the new status, because HC2 is too fast :-) lightstatus = fibaro:getValue(random_light, 'value') --get the value of the random light after his update StandardDebug('light ID:'.. fibaro:getName(random_light) ..' status:'..lightstatus); local sleeptime = math.random(Random_max_duration*60000) --random sleep StandardDebug("Entering loop of " .. round(sleeptime/60000,2) .. " minutes"); -- Allows to exit the scene if the Simu_presence global var changes to 0 during the random sleep local counterexitSimulation = 200 while (counterexitSimulation > 0) and ((os.time() <= End_simulation_time) or Manual_overide == "1") do counterexitSimulation = counterexitSimulation - 1; test_presence_state = fibaro:getGlobal("Simu_presence"); Simulation = tonumber(test_presence_state); --verify the global value, if the virtual device is deactivated, the loop stops. --fibaro:debug("Simulation var state : " .. Simulation.." override var state : " .. Manual_overide); if Simulation == 0 then Manual_overide = fibaro:getGlobalValue("overideSimuSunset"); if Simulation == 0 or Manual_overide == "0" then counterexitSimulation = 0 end end fibaro:sleep(sleeptime/200); end ExtraDebug("Exiting loop of "..round(sleeptime/60000,2).." minutes"); local sleeptimemin = math.abs(sleeptime/60000) Simulation = fibaro:getGlobal("Simu_presence"); --verify the global value, if the virtual device is deactivated, the scene stops. Manual_overide = fibaro:getGlobalValue("overideSimuSunset"); end end function YAPS_Engine:EndSimulation() if Lights_always_on[1] ~= nil then YAPS_Engine:TurnOff(Random_lights,Lights_always_on); end Debug("red","Presence Simulation deactivated"); if (Simulation == "1") then Debug("yellow","Presence Simulation will restart tomorrow."); Debug("yellow","Sunset is around "..fibaro:getValue(1, "sunsetHour").." + Sunset Shift of "..Sunset_offset.."min = Start Time around "..YAPS_Engine:ReverseUnixTimeCalc("Sunset unix time", Sunset_unix_hour)); YAPS_Engine:notification("Presence Simulation will restart tomorrow. Sunset is around "..fibaro:getValue(1, "sunsetHour").." + Sunset Shift of "..Sunset_offset.."min = Start Time around "..YAPS_Engine:ReverseUnixTimeCalc("Sunset unix time", Sunset_unix_hour), "Presence Simulator", {"push"}); -- push only end NotifLoop = 0; -- will force main loop notifications at end of Simulation end function YAPS_Engine:ExitSimulation() --YAPS_Engine:notification("Presence Simulation is terminated", "Presence Simulator", {"push"}); -- push only Debug("red","Simu_presence = 0, Aborting Simulation scene"); fibaro:abort(); end function YAPS_Engine:TurnOff(group,group2) Debug("red","TurnOff All Simulation lights!"); local name, id2; local ID_devices_group = group; if ID_devices_group ~= 0 then for i=1, #ID_devices_group do Simulation = fibaro:getGlobal("Simu_presence"); --verify the global value, if Simulation presence is deactivated if Simulation == "0" then Sleep_between_TurnOff = 0; end; -- if Simulation ended before End_simulation_time, then no turn off delay if i > 1 then -- wait Number of lights -1 (do not need to wait for the first TurnOff) StandardDebug("Sleeping "..Sleep_between_TurnOff.." minute(s) before next TurnOff"); fibaro:sleep(Sleep_between_TurnOff*60000); end id2 = tonumber(ID_devices_group[i]); fibaro:call(id2, "turnOff"); name = fibaro:getName(id2); if (name == nil or name == string.char(0)) then name = "Unknown" end StandardDebug("Device: "..name.." Off "); end end Debug("red","TurnOff All Always_On lights!"); local ID_devices_group = group2; if ID_devices_group ~= 0 then for i=1, #ID_devices_group do id2 = tonumber(ID_devices_group[i]); fibaro:call(id2, "turnOff"); name = fibaro:getName(id2); if (name == nil or name == string.char(0)) then name = "Unknown" end StandardDebug("Device: "..name.." Off "); end end if Lights_On_at_end_Simulation ~= 0 and Simulation == "1" then fibaro:call(Lights_On_at_end_Simulation, "turnOn"); name = fibaro:getName(Lights_On_at_end_Simulation); if (name == nil or name == string.char(0)) then name = "Unknown" end Debug("red","Turned On light Lights_On_at_end_Simulation:"); Debug("white", name); end if Lights_On_if_Simulation_deactivated ~= 0 and Simulation == "0" then fibaro:call(Lights_On_if_Simulation_deactivated, "turnOn"); name = fibaro:getName(Lights_On_if_Simulation_deactivated); if (name == nil or name == string.char(0)) then name = "Unknown" end Debug("red","Turned On light Lights_On_if_Simulation_deactivated:"); Debug("white", name); end end function YAPS_Engine:TurnOn(group) Debug("red","Turning On Always_On lights:"); local name, id2; local ID_devices_group = group; for i=1, #ID_devices_group do id2 = tonumber(ID_devices_group[i]); fibaro:call(id2, "turnOn"); name = fibaro:getName(id2); if (name == nil or name == string.char(0)) then name = "Unknown" end StandardDebug("Device: "..name.." Turned On "); end Debug("red","Now randomizing other lights..."); end Debug("green", "Presence Simulation | v" .. version .. " Starting up"); Debug("green", "--------------------------------------------------------------------------"); ------------------------ Main Loop ---------------------------------- -- first start notifications YAPS_Engine:EndTimeCalc(); YAPS_Engine:notification("Scheduled presence Simulation at "..YAPS_Engine:ReverseUnixTimeCalc("Sunset unix time", Sunset_unix_hour).." (Sunset: "..fibaro:getValue(1, "sunsetHour")..")", "Presence Simulator", {"email"}); -- mail only Debug("green","Sunset is at "..fibaro:getValue(1, "sunsetHour").." + Sunset Shift of "..Sunset_offset.."min = Start Time at "..YAPS_Engine:ReverseUnixTimeCalc("Sunset unix time", Sunset_unix_hour)); Debug("green","End of Simulation: "..YAPS_Engine:ReverseUnixTimeCalc("End Simulation", End_simulation_time).." + random of "..Random_max_TurnOff_duration.."min"); Debug("green", "Checking for actions every minute."); Is_first_launch = true while true do -- Infinite loop of actions checking, hours calculations, notifications YAPS_Engine:EndTimeCalc(); -- local Sunset_unix_hour = Midnight -- un-comment this line when testing to force a start hour (or use Sunset_offset) if os.time() >= Sunset_unix_hour then -- define if nighttime (sunset = 1) sunset = 1 else sunset = 0 end if (Simulation == "1") then if sunset == 1 and (os.time() <= End_simulation_time) then Debug("yellow", "It's sunset time -> Simulation ON"); YAPS_Engine:Launch(); YAPS_Engine:EndSimulation(); end if Manual_overide == "1" then Debug("yellow", "Manual Override Activated -> Simulation ON"); YAPS_Engine:Launch(); YAPS_Engine:EndSimulation(); end if Manual_overide == "0" and sunset == 0 and NotifLoop == 0 then Debug("yellow", "Sunset is at "..fibaro:getValue(1, "sunsetHour").." + Sunset Shift of "..Sunset_offset.."min = Start Time at "..YAPS_Engine:ReverseUnixTimeCalc("Sunset unix time", Sunset_unix_hour)); Debug("yellow", "End of Simulation: "..YAPS_Engine:ReverseUnixTimeCalc("End Simulation", End_simulation_time).." + random of "..Random_max_TurnOff_duration.."min = "..YAPS_Engine:ReverseUnixTimeCalc("End Simulation", End_simulation_time_with_random_max_TurnOff)); end end if (Simulation == "0") then -- Condition to end Simulation YAPS_Engine:ExitSimulation(); end if NotifLoop <= 120 then --a waiting xx times the fibaro sleep below (2 hours) before resetting counter (and notifying) if NotifLoop == 120 then NotifLoop = 0 end if NotifLoop == 0 then ExtraDebug("Now, checking for actions every minute. Next notify: in 2 hours"); end end fibaro:sleep(1*60*1000); -- wait 1 minutes before testing again the global vars below Simulation = fibaro:getGlobal("Simu_presence"); Manual_overide = fibaro:getGlobal("overideSimuSunset"); NotifLoop = NotifLoop + 1; end
-
J'ai tout retourné, je pense que la ligne 252 n'a rien a voir, mais essaye de rajouter l'id de l'admin (2) dans ta liste d'id (c la fonction mail qui en a besoin) local id = { ADMIN = 2, }
-
et aussi la fonction complète dans laquelle se trouve ta ligne 252
-
je voulais dire les variable dans l'entête du script: --------------------- USER SETTINGS -------------------------------- local id = { LAMPE_SDB = 16, LAMPE_CH_AMIS = 24, LAMPE_SALON = 45, LAMPE_BUREAU = 49, LAMPE_HALL = 52, LAMPE_CELLIER = 56, LAMPE_CH_EMILIEN = 58, LAMPE_COULOIR = 1316, PHONE_SEB = 1347, ADMIN = 2, PHONE_GG = 1327 } local Stop_hour = "01"; -- Hour when you want Simulation to stop local Stop_minute = "30"; -- Minute of the hour you want Simulation to stop -- note 1: the script will not exit while waiting the random time of the last light turned on. So end time can be longer than specified end time. (even more with var Random_max_TurnOff_duration) -- note 2: if the global variable changes during the same wait time as above, it will exit immediately (when back home while Simulation runs) local Sunset_offset = -15 -- number of minutes before or after sunset to activate Simulation local Random_max_duration = 30; -- random time of light change in minutes --> here each device is on maximum 30min local Random_max_TurnOff_duration = 25; -- random time to add at the stop hour+stop minute so the Simulation can be more variable (0 to deactivate) local Lights_always_on = {id["LAMPE_BUREAU"],id["LAMPE_COULOIR"]} -- IDs of lights who will always stay on during Simulation - leave empty array if none -> {} local Random_lights = {id["LAMPE_SDB"],id["LAMPE_HALL"],id["LAMPE_CELLIER"],id["LAMPE_CH_AMIS"]} -- IDs of lights to use in Simulation --local Random_lights = {id["LAMPE_HALL"],id["LAMPE_CELLIER"],id["LAMPE_CH_AMIS"]} -- Reduced set for test purposes local Activate_Push = true; -- activate push when Simulation starts and stops local Activate_FreeSms = false; -- activate push with Activate_FreeSms (Activate_Push must be true also) --local Smartphones_push = {id["PHONE_SEB"],id["PHONE_GG"]}; local Smartphones_push = {id["PHONE_SEB"]}; -- list of device receiving Push local Lights_On_at_end_Simulation = 0; -- If next line is commented, no light will turn on after Simulation ends local Lights_On_at_end_Simulation = id["LAMPE_COULOIR"]; -- ID of a light (Only One) to turn on after Simulation ends (at specified Stop_hour & Stop_minute). Comment this line to turn off this feature local Lights_On_if_Simulation_deactivated = 0; -- If next line is commented, no light will turn on after Simulation is stopped (by putting Simu_presence to 0) local Lights_On_if_Simulation_deactivated = id["LAMPE_HALL"]; -- ID of a light (Only One) to turn on after Simulation is stopped (Simulation_). Comment this line to turn off this feature --------------------- USER SETTINGS END ---------------------------- ----------------------ADVANCED SETTINGS----------------------------- local Show_standard_debug = true; -- Debug displayed in white local Show_extra_debug = false; -- Debug displayed in orange -------------------------------------------------------------------- -------------------- DO NOT CHANGE CODE BELOW ----------------------
-
Le code àbesoin du vd car les noms et nombre de boutons àchangé... Sent from my Note4