-
Compteur de contenus
4 189 -
Inscription
-
Dernière visite
-
Jours gagnés
85
Tout ce qui a été posté par sebcbien
-
comme dit plus haut: local id = { PARTITION_REZ = 1242, PARTITION_1ER = 1243, PARTITION_FIBARO = 1244, PARTITION_REZ_MVT = 1245, PARTITION_1ER_MVT = 1246 } fibaro:call(id["PARTITION_REZ"], "clearAlarm")
-
Oui en lua, un clearalarm sur la partition. De la même manière que arm et disarm Sent From my Vic20
-
Oui bien sur. Il suffit que le contenu de la variable soit identique aux valeurs attendues par gea. Sent From my Vic20
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
Topic unique Fibaro - Module Dimmer Fgd-211
sebcbien a répondu à un(e) sujet de Moicphil dans Modules Fibaro
Je pense qu'on peut surtout pleurer... :-/ Sent From my Vic20 -
Malheureusement gea ne sais pas faire ça... Ni l'application mobile d'ailleurs. Par contre gea sait faire du très bon café ;-) Sent From my Vic20
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
Topic unique Telecommande Neeo
sebcbien a répondu à un(e) sujet de Moicphil dans Périphériques et matériels autres
un truc me turlupine, le zwave... ce truc sera master controller, donc il faudra choisir entre la hc2 ou ça ? Quelqu'un a plus d'infos ? C'est pas destinés aux petites installations ? Ceci dit, rien que l'irblaster intégré vaut déjàle détour. -
Un copain m'a demandé d'ajouter la possibilité d'avoir des lampes sélectionnées qui resteraient allumées en permanence durant toute la simulation... C'est une bonne suggestion permettant de coller encore mieux àla réalité. Voici un debug pour se faire une idée: [DEBUG] 23:42:39: Presence Simulator | v2.6.0 [DEBUG] 23:42:39: -------------------------------- [DEBUG] 23:42:39: Not starting Simulation (Simu_presence = 0) [DEBUG] 23:42:39: Presence Simulator is Terminated [DEBUG] 23:42:52: Presence Simulator | v2.6.0 [DEBUG] 23:42:52: -------------------------------- [DEBUG] 23:42:52: It s sunset time -> Simulation ON [DEBUG] 23:42:52: Turning On always on lights: [DEBUG] 23:42:52: Device: Bureau On [DEBUG] 23:42:52: Now randomizing other lights... [DEBUG] 23:42:53: light ID:Cellier status:99 [DEBUG] 23:42:53: entering loop of 6.25 minutes [DEBUG] 23:43:16: exiting loop of 6.25 minutes [DEBUG] 23:43:16: TurnOff All lights! [DEBUG] 23:43:16: Device: Salle De Bain Off [DEBUG] 23:43:16: Device: Hall Off [DEBUG] 23:43:16: Device: Cellier Off [DEBUG] 23:43:16: Device: Chambre Amis Off [DEBUG] 23:43:16: Device: Bureau Off [DEBUG] 23:43:16: Manual Light Settings: Turned On light: Hall [DEBUG] 23:43:16: Simulation is deactivated [DEBUG] 23:43:16: Presence Simulator is Terminated [DEBUG] 23:43:16: Simu = 0, Exit from scene Et voici le code: --[[ %% autostart %% properties %% globals Simu_presence --]] --------------------------------- -- YAPS Presence Simulator V2.6.1 -- SebcBien -- Février 2015 --------------------------------- --V2.6.1 -- Added naming of devices in the debug during simulation --V2.6.0 -- Added the possibility to select always on light during simulation --V2.5.0 -- fixed simulation starting if restarted between endtime & midnight --v2.4.1 -- fixed big bug simulator restarting after end time --V2.3.1 -- small notification and debug changes --V2.3 -- Rewriting the engine -- now relaunch automatically the next day, even if Simu_presence has not changed --V2.2 -- Added Manual Stop variable -- added list of mobiles if (fibaro:countScenes() > 1) then --fibaro:debug("More than one scene active, exiting!"); 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, PHONE_NEXUS_5 = 53, PHONE_NEXUS_4 = 104 } local stop_hour = "01"; -- Hour when you want simulation to stop local stop_minute = "10"; -- 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 -- 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 rndmaxtime = 15; -- random time of light change in minutes --> here each device is on maximum 30min local ID_devices_lights_always_on = {id["LAMPE_BUREAU"]} -- IDs of lights who will always stay on during simulation local ID_devices_lights = {id["LAMPE_SDB"],id["LAMPE_HALL"],id["LAMPE_CELLIER"],id["LAMPE_CH_AMIS"]} -- IDs of lights to use in simulation --local ID_devices_lights = {id["LAMPE_BUREAU"],id["LAMPE_CELLIER"]} -- Reduced set for test purposes local activatePush = true; -- activate push when simulation starts and stops --local ID_Smartphones = {id["PHONE_NEXUS_5"],id["PHONE_NEXUS_4"]}; local ID_Smartphones = {id["PHONE_NEXUS_5"]}; -- list of device receiving Push local ID_On_After_Simu = 0; -- If next line is commented, no light will turn on after simulation ends local ID_On_After_Simu = id["LAMPE_HALL"]; -- Only One ID of a light to turn on after simulation ends. Comment this line to turn off this feature --------------------- USER SETTINGS END ---------------------------- ----------------------ADVANCED SETTINGS----------------------------- local showStandardDebugInfo = true; -- Debug shown in white local showExtraDebugInfo = false; -- Debug shown in orange local numbers_lights = #ID_devices_lights; -- numbers of light devices listed above local manualOveride = fibaro:getGlobal("overideSimuSunset"); -- if = 1 then the simulation is forced -------------------------------------------------------------------- -------------------- DO NOT CHANGE CODE BELOW ---------------------- -------------------------------------------------------------------- local version = "2.6.1"; local simu = fibaro:getGlobal("Simu_presence"); --value of the global value: simulation is on or off local start_simu = fibaro:getValue(1, "sunsetHour"); --Start simulation when sunset local endtime; local wait_for_tomorrow = 1; local NotifLoop = 30; SimulatorPresenceEngine = {}; -- FONCTIONS Debug = function ( color, message ) fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); end ExtraDebug = function (debugMessage) if ( showExtraDebugInfo ) then Debug( "orange", debugMessage); end end StandardDebug = function (debugMessage) if ( showStandardDebugInfo ) then Debug( "white", debugMessage); end end round = function (num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end -- Push message to mobile pushMessage = function (sendPush) if (activatePush) then for i=1, #ID_Smartphones do fibaro:call(tonumber(ID_Smartphones[i]), 'sendPush', sendPush); ExtraDebug("Push message ("..sendPush..") sent to mobile: "..tonumber(ID_Smartphones[i])); end end end -- Calculate endtime function SimulatorPresenceEngine:EndTimeCalc() local start = os.date("%H:%M") local time = os.time() local date = os.date("*t", time) local year = date.year local month = date.month local day = date.day endtime = os.time{year=year, month=month, day=day, hour=stop_hour, min=stop_minute, sec=sec} -- to calculate when it's daytime local currentHour = os.date("*t") local sunrise = tonumber(string.sub (fibaro:getValue(1,'sunriseHour'), 1 , 2) ) * 60 + tonumber(string.sub(fibaro:getValue(1,'sunriseHour'), 4) ) local sunset = tonumber(string.sub (fibaro:getValue(1,'sunsetHour'), 1 , 2) ) * 60 + tonumber(string.sub(fibaro:getValue(1,'sunsetHour'), 4) ) local now = currentHour.hour * 60 + currentHour.min; --ExtraDebug ("debug info: Sunrise : " .. sunrise .. " Sunset : "..sunset .. " Now : " ..now); --ExtraDebug ("debug info: Current OS Time" ..os.time()) --ExtraDebug ("debug info: Original planed EndTime " ..endtime) --ExtraDebug ("debug info: os.date: "..os.date("%H:%M").. " sunrisehour: "..fibaro:getValue(1, "sunriseHour")) if ((wait_for_tomorrow == 0) and (endtime < os.time())) then -- if endtime is gone and it's the first launch of simulator endtime = endtime + 24*60*60 -- add 24h at endtime after the night is gone start_simu = fibaro:getValue(1, "sunsetHour"); -- recalculate for next day ExtraDebug ("Added 24H to Endtime (first start ending after midnignt)"); ExtraDebug ("Recalculated Simulation StartHour (Sunset): " .. start_simu); wait_for_tomorrow = 1 end if (wait_for_tomorrow == 1 and (endtime < os.time()) and ((now >= sunrise) and (now <= sunset))) then -- if it looping days and endtime is gone and we are daytime endtime = endtime + 24*60*60 -- add 24h at endtime after the night is gone start_simu = fibaro:getValue(1, "sunsetHour"); -- recalculate for next day ExtraDebug ("Added One Day to Endtime: " .. endtime); ExtraDebug ("Recalculated Simulation StartHour (Sunset): " .. start_simu); end --ExtraDebug ("debug info: Recalculated planed EndTime " ..endtime) end -- Simulate Presence Main function SimulatorPresenceEngine:Launch() pushMessage("Lights simulation started, will stop at: "..stop_hour..":"..stop_minute) ExtraDebug("Lights simulation started, will stop at: "..stop_hour..":"..stop_minute ); SimulatorPresenceEngine:TurnOn(ID_devices_lights_always_on); while ((os.time() <= endtime) and (simu == "1")) or ((manualOveride == "1")) do -- original code: while ((os.time() <= endtime) and (simu == "1")) or ((os.time() <= endtime) and (simu == "1") and (manualOveride == "1")) do if time == endtime then StandardDebug("time and endtime same value -> end") end local random_light = tonumber(ID_devices_lights[math.random(numbers_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(rndmaxtime*60000) --random sleep StandardDebug("entering loop of " .. round(sleeptime/60000,2) .. " minutes"); -- This modification allows to exit the scene if the Simu_presence global var changes to 0 during the random sleep local counterexitsimu = 200 while (counterexitsimu > 0) do counterexitsimu = counterexitsimu - 1; test_presence_state = fibaro:getGlobal("Simu_presence"); simu = tonumber(test_presence_state); --verify the global value, if the virtual device is deactivated, the scene stops. --fibaro:debug("simu var state : " .. simu); if simu == 0 then counterexitsimu = 0 end fibaro:sleep(sleeptime/200); end StandardDebug("exiting loop of " .. round(sleeptime/60000,2) .. " minutes"); local sleeptimemin = math.abs(sleeptime/60000) --StandardDebug('sleeptime:'..sleeptimemin); simu = fibaro:getGlobal("Simu_presence"); --verify the global value, if the virtual device is deactivated, the scene stops. manualOveride = fibaro:getGlobalValue("overideSimuSunset"); end end function SimulatorPresenceEngine:EndSimulation() SimulatorPresenceEngine:TurnOff(ID_devices_lights,ID_devices_lights_always_on); Debug("red","Simulation is deactivated"); if (simu == "1") then Debug("grey", "Presence Simulator will Restart tomorrow around ".. fibaro:getValue(1, "sunsetHour")); pushMessage("Presence Simulator will Restart tomorrow around ".. fibaro:getValue(1, "sunsetHour")); wait_for_tomorrow = 1 -- will make EndTimeCalc add 24h to endtime during daytime end end function SimulatorPresenceEngine:ExitSimulation() Debug("red","Presence Simulator is Terminated"); pushMessage("Presence Simulator is Terminated"); end -- Switch off devices in the list function SimulatorPresenceEngine:TurnOff(group,group2) Debug("red","TurnOff All 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, "turnOff"); name = fibaro:getName(id2); if (name == nil or name == string.char(0)) then name = "Unknown" end StandardDebug("Device: " .. name .. " Off "); end local ID_devices_group = group2; 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 if ID_On_After_Simu ~= 0 then fibaro:call(ID_On_After_Simu, "turnOn"); name = fibaro:getName(ID_On_After_Simu); if (name == nil or name == string.char(0)) then name = "Unknown" end Debug("red","Manual Light Settings: Turned On light: " .. name); end end -- Switch on devices in the list function SimulatorPresenceEngine: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 .. " On "); end Debug("red","Now randomizing other lights..."); end Debug("green", "Presence Simulator | v" .. version ); Debug( "green", "--------------------------------"); if tonumber(stop_hour) <= 12 then wait_for_tomorrow = 0 end -- if stop hour is between 00 and 12h then will consider that stop hour is before midnight ------------------------ Main Loop ---------------------------------- if (simu == "0") then Debug("red","Not starting Simulation (Simu_presence = 0)"); SimulatorPresenceEngine:ExitSimulation(); fibaro:abort(); end pushMessage("Scheduled Simulation starting time: " .. start_simu); ExtraDebug("Today's sunset is at "..fibaro:getValue(1, "sunsetHour").." - End of Simulation at "..stop_hour..":"..stop_minute); while (simu=="1" or simu=="0" ) do SimulatorPresenceEngine:EndTimeCalc(); -- local start_simu = "00:01" -- uncomment this line when testing to force a start hour (for the first loop) if (os.date("%H:%M") >= start_simu) then -- define if nighttime (sunset) sunset = 1 else sunset = 0 end if (simu == "1") then if sunset == 1 and (os.time() <= endtime) then Debug("grey", "It's sunset time -> Simulation ON"); SimulatorPresenceEngine:Launch(); SimulatorPresenceEngine:EndSimulation(); end if manualOveride == "1" then Debug("grey", "Manual Override Activated -> Simulation ON"); SimulatorPresenceEngine:Launch(); SimulatorPresenceEngine:EndSimulation(); end --fibaro:debug("sunset: "..sunset .. "endtime: " .. endtime .. "ostime: " .. os.time()); if manualOveride == "0" and sunset == 0 and NotifLoop == 30 then Debug("grey", "Waiting for next Sunset -> Simulation OFF."); end end if sunset == 1 and (os.time() >= endtime) and (os.time() <= (endtime + 60)) then Debug("grey","Simulation ended for this night."); end if (simu == "0") then -- Condition to end simulation SimulatorPresenceEngine:ExitSimulation(); Debug("red","Simu = 0, Exit from scene"); fibaro:abort(); end if NotifLoop <= 30 then if NotifLoop == 30 then NotifLoop = 0 end if NotifLoop == 0 then ExtraDebug("Looping to check for changes every 2min") end NotifLoop = NotifLoop + 1 end fibaro:sleep(2*60*1000); simu = fibaro:getGlobal("Simu_presence"); manualOveride = fibaro:getGlobal("overideSimuSunset"); end
-
si ça peut te rassurer, j'ai aussi relevé ce problème précédemment: http://www.domotique-fibaro.fr/index.php/topic/1211-support-gea/?view=findpost&p=46007 Mais bon, le Workaround est simple: doubler le maxtime
- 12 330 réponses
-
- 1
-
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
Tu as vu que raspberry vient de sortir un nouveau ? http://www.gizmodo.fr/2015/02/02/raspberry-pi-2.html Tellement puissant que Microsoft a annoncé une verion de windows 10 gratos (pour les développeurs) :-) http://dev.windows.com/en-us/featured/raspberrypi2support Moi j'attends openelec
-
ah bah oui, ça va peut être vous intéresser de savoir comment lire les autres infos dans la VMC ? -------------------------------------------------- -- RaspVMC Fibaro Virtual Module -- Sebastien Jauquet -- Juin 2014 -------------------------------------------------- local thismodule=fibaro:getSelfId() local ipraspberry = fibaro:get(thismodule, 'IPAddress') local speedwrite = "" local extraitpourcent = "" local vitesse = "" local RendementVMC = "" -- IP of the VMC Rasp VMC = Net.FHttp(ipraspberry,80) response ,status, errorCode = VMC:GET("/cgi-bin/VMCbinjson.cgi") -- enregistrement du retour de l API dans une table fibaro:debug("Status = " .. status) if (tonumber(status) == 200) then response = json.decode(response) else fibaro:log("ErrorCode = " .. errorCode) fibaro:setGlobal("VENT_V3_TEMP", "0") end local vitesse = response.config.ventilateurs.vitesse - 1 fibaro:debug(vitesse) function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end local extraitpourcent = response.data.ventilateurs.extraitpourcent local vitesse = response.config.ventilateurs.vitesse local Tairneuf = response.data.temperature.Tairneuf local Textrait = response.data.temperature.Textrait local Trepris = response.data.temperature.Trepris local Tsoufflage = response.data.temperature.Tsoufflage local Tconfort = response.data.temperature.Tconfort local Mode = response.data.bypass.mode local soufflagepourcent = response.data.ventilateurs.soufflagepourcent local extraitpourcent = response.data.ventilateurs.extraitpourcent local extraitrpm = round(response.data.ventilateurs.extraitrpm) local soufflagerpm = round(response.data.ventilateurs.soufflagerpm) local filtres = response.data.usage.filtres local wallplug1 = fibaro:getValue(25, "valueSensor") local RendementVMC = 1000*((Tsoufflage-Tairneuf)/(Trepris-Tairneuf)) RendementVMC = round(RendementVMC)/10 fibaro:call(thismodule, "setProperty", "ui.Label1.value", vitesse - 1 .. " (" .. extraitpourcent .. "%)") fibaro:call(thismodule, "setProperty", "ui.Label2.value", RendementVMC .. "%") fibaro:call(thismodule, "setProperty", "ui.Label3.value", Tairneuf .. "° -> " .. Textrait .. "°") fibaro:call(thismodule, "setProperty", "ui.Label4.value", Trepris .. "° -> " .. Tsoufflage .. "°") fibaro:call(thismodule, "setProperty", "ui.Label5.value", Tconfort .. "°") fibaro:call(thismodule, "setProperty", "ui.Label6.value", Mode ) fibaro:call(thismodule, "setProperty", "ui.Label7.value", soufflagepourcent .. "% / " .. soufflagerpm .. "rpm") fibaro:call(thismodule, "setProperty", "ui.Label8.value", extraitpourcent .. "% / " .. extraitrpm .. "rpm") fibaro:call(thismodule, "setProperty", "ui.Label9.value", filtres .. " Heures") fibaro:call(thismodule, "setProperty", "ui.Label10.value",wallplug1 .." watt") --fibaro:call(thismodule, "setProperty", "ui.Label1.value", vitesse - 1 .. " (" .. extraitpourcent .. "%)") --fibaro:call(thismodule, "setProperty", "ui.Label2.value", RendementVMC .. "%") --fibaro:call(thismodule, "setProperty", "ui.Label3.value", Tairneuf .. "° " .. Trepris .. "° " .. Tsoufflage .. "°")
-
Bon, le temps, toujours pas, mais voici le virtual device: Vitesse_VMC.vfib En gros, il y a un script sous chaque bouton de vitesse qui push les paramètres vers une url. exemple pour définir la vitesse2: -------------------------------------------------- -- VMC Speed -- Control of VMC StorkAir / ComfoAir / Zehnder -- sebcbien -- Juin 2014 -------------------------------------------------- local thismodule=fibaro:getSelfId() local ipraspberry = fibaro:get(thismodule, 'IPAddress') local speedwrite = "2" local extraitpourcent = "" local vitesse = "" local RendementVMC = "" local Notifier = 93 -- VD notifier fibaro:setGlobal("VMC_Speed", "Normale") function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end VMC = Net.FHttp(ipraspberry,80) payloademon = "/cgi-bin/VMCsetspeed.cgi?speed=" .. speedwrite response, status, errorCode = VMC:GET(payloademon) response ,status, errorCode = VMC:GET("/cgi-bin/VMCbinjson.cgi") -- enregistrement du retour de l API dans une table if (tonumber(status) == 200) then response = json.decode(response) -- Wait for Notifier to be free --while (fibaro:getGlobalValue("Notifier_Use") == "In_Use") do fibaro:sleep(1000); end fibaro:setGlobal("Notifier_Use", "In_Use"); -- Call Notifier --fibaro:setGlobal("Notify_Msg", "Vitesse VMC: " .. speedwrite); --fibaro:call(Notifier, "pressButton", "5"); else fibaro:log("ErrorCode = " .. errorCode) end -- read VMC state fibaro:call(thismodule, "pressButton", "10"); J'utilise un notificateur "maison" à vous de le remplacer par l'action que vous désirez. Le main loop permet de surveiller et de modifier l'icône et quelques paramètres Fibaro. Je n'interroge pas le raspberry qui gère la VMC trop souvent car le protocole RS-232 utilisé pour gérer la VMC n'a pas été conçu pour un polling très fréquent et donc plante parfois si trop sollicité. Des questions ?, n'hésitez pas ;-)
-
Met plezier !
-
Donc tu confirme que ça tourne bien sur plusieurs jours d'affilée ? J'espère que je n'aurai pas tout cassé avec la dernière mise à jour
-
J'ai trouvé une demie heure et je viens de terminer le débug ;-) j'ai même accédé à la demande de l'arrondi de l'affichage des minutes ;-) Note: maintenant par défaut j'ai mis le extradebug à false. en cas de problème donc, pour avoir un debug plus bavard, remettre cette variable à true. here it is: --[[ %% autostart %% properties %% globals Simu_presence --]] -------------------------------- -- YAPS Presence Simulator V2.5.0 -- SebcBien -- Février 2015 -------------------------------- --V2.5.0 -- fixed simulation starting if restarted between endtime & midnight --v2.4.1 -- fixed big bug simulator restarting after end time --V2.3.1 -- small notification and debug changes --V2.3 -- Rewriting the engine -- now relaunch automatically the next day, even if Simu_presence has not changed --V2.2 -- Added Manual Stop variable -- added list of mobiles if (fibaro:countScenes() > 1) then fibaro:debug("More than one scene active, exiting!"); 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, PHONE_NEXUS_5 = 53, PHONE_NEXUS_4 = 104 } local stop_hour = "01"; -- Hour when you want simulation to stop local stop_minute = "10"; -- 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 -- 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 rndmaxtime = 15; -- random time of light change in minutes --> here each device is on maximum 30min local ID_devices_lights = {id["LAMPE_SDB"],id["LAMPE_BUREAU"],id["LAMPE_HALL"],id["LAMPE_CELLIER"],id["LAMPE_CH_AMIS"]} -- IDs of lights to use in simulation --local ID_devices_lights = {id["LAMPE_BUREAU"],id["LAMPE_CELLIER"]} -- IDs of lights to use in simulation local activatePush = true; -- activate push when simulation starts and stops --local ID_Smartphone = 53; -- ID of your smartphone --local ID_Smartphones = {id["PHONE_NEXUS_5"],id["PHONE_NEXUS_4"]}; local ID_Smartphones = {id["PHONE_NEXUS_5"]}; local ID_On_After_Simu = id["LAMPE_HALL"]; -- Only One ID of a lamp to turn on after simulation ends (set 0 to disable) local Manual_Stop = 1; -- 0 will not turn on the lamp "ID_On_After_Simu" at the end of the script. Replace this variable by a global value if you want to automate --------------------- USER SETTINGS END ---------------------------- ----------------------ADVANCED SETTINGS----------------------------- local showStandardDebugInfo = true; -- Debug shown in white local showExtraDebugInfo = false; -- Debug shown in orange local numbers_lights = #ID_devices_lights; -- numbers of light devices listed above local manualOveride = fibaro:getGlobal("overideSimuSunset"); -- if = 1 then the simulation is forced -------------------------------------------------------------------- ----------------------------------- ----- Do not change code below ---- ----------------------------------- local version = "2.5.0"; local simu = fibaro:getGlobal("Simu_presence"); --value of the global value: simulation is on or off local start_simu = fibaro:getValue(1, "sunsetHour"); --Start simulation when sunset local endtime; local wait_for_tomorrow = 1; local NotifLoop = 30; SimulatorPresenceEngine = {}; -- debug function Debug = function ( color, message ) fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); end ExtraDebug = function (debugMessage) if ( showExtraDebugInfo ) then Debug( "orange", debugMessage); end end StandardDebug = function (debugMessage) if ( showStandardDebugInfo ) then Debug( "white", debugMessage); end end round = function (num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end -- function push message to mobile pushMessage = function (sendPush) if (activatePush) then for i=1, #ID_Smartphones do fibaro:call(tonumber(ID_Smartphones[i]), 'sendPush', sendPush); ExtraDebug("Push message ("..sendPush..") sent to mobile: "..tonumber(ID_Smartphones[i])); end end end -- function to calculate endtime function SimulatorPresenceEngine:EndTimeCalc() local start = os.date("%H:%M") local time = os.time() local date = os.date("*t", time) local year = date.year local month = date.month local day = date.day endtime = os.time{year=year, month=month, day=day, hour=stop_hour, min=stop_minute, sec=sec} -- to calculate when it's daytime local currentHour = os.date("*t") local sunrise = tonumber(string.sub (fibaro:getValue(1,'sunriseHour'), 1 , 2) ) * 60 + tonumber(string.sub(fibaro:getValue(1,'sunriseHour'), 4) ) local sunset = tonumber(string.sub (fibaro:getValue(1,'sunsetHour'), 1 , 2) ) * 60 + tonumber(string.sub(fibaro:getValue(1,'sunsetHour'), 4) ) local now = currentHour.hour * 60 + currentHour.min; --ExtraDebug ("debug info: Sunrise : " .. sunrise .. " Sunset : "..sunset .. " Now : " ..now); --ExtraDebug ("debug info: Current OS Time" ..os.time()) --ExtraDebug ("debug info: Original planed EndTime " ..endtime) --ExtraDebug ("debug info: os.date: "..os.date("%H:%M").. " sunrisehour: "..fibaro:getValue(1, "sunriseHour")) if ((wait_for_tomorrow == 0) and (endtime < os.time())) then -- if endtime is gone and it's the first launch of simulator endtime = endtime + 24*60*60 -- add 24h at endtime after the night is gone start_simu = fibaro:getValue(1, "sunsetHour"); -- recalculate for next day ExtraDebug ("Added 24H to Endtime (first start ending after midnignt)"); ExtraDebug ("Recalculated Simulation StartHour (Sunset): " .. start_simu); wait_for_tomorrow = 1 end if (wait_for_tomorrow == 1 and (endtime < os.time()) and ((now >= sunrise) and (now <= sunset))) then -- if it looping days and endtime is gone and we are daytime endtime = endtime + 24*60*60 -- add 24h at endtime after the night is gone start_simu = fibaro:getValue(1, "sunsetHour"); -- recalculate for next day ExtraDebug ("Added One Day to Endtime: " .. endtime); ExtraDebug ("Recalculated Simulation StartHour (Sunset): " .. start_simu); end --ExtraDebug ("debug info: Recalculated planed EndTime " ..endtime) end -- function to simulate a presence function SimulatorPresenceEngine:Launch() pushMessage("Lights simulation started, will stop at: "..stop_hour..":"..stop_minute) ExtraDebug("Lights simulation started, will stop at: "..stop_hour..":"..stop_minute ); while ((os.time() <= endtime) and (simu == "1")) or ((manualOveride == "1")) do -- original code: while ((os.time() <= endtime) and (simu == "1")) or ((os.time() <= endtime) and (simu == "1") and (manualOveride == "1")) do if time == endtime then StandardDebug("time and endtime same value -> end") end local random_light = tonumber(ID_devices_lights[math.random(numbers_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:'..random_light..' status:'..lightstatus); local sleeptime = math.random(rndmaxtime*60000) --random sleep StandardDebug("entering loop of " .. round(sleeptime/60000,2) .. " minutes"); -- This modification allows to exit the scene if the Simu_presence global var changes to 0 during the random sleep local counterexitsimu = 200 while (counterexitsimu > 0) do counterexitsimu = counterexitsimu - 1; test_presence_state = fibaro:getGlobal("Simu_presence"); simu = tonumber(test_presence_state); --verify the global value, if the virtual device is deactivated, the scene stops. --fibaro:debug("simu var state : " .. simu); if simu == 0 then counterexitsimu = 0 end fibaro:sleep(sleeptime/200); end StandardDebug("exiting loop of " .. round(sleeptime/60000,2) .. " minutes"); local sleeptimemin = math.abs(sleeptime/60000) --StandardDebug('sleeptime:'..sleeptimemin); simu = fibaro:getGlobal("Simu_presence"); --verify the global value, if the virtual device is deactivated, the scene stops. manualOveride = fibaro:getGlobalValue("overideSimuSunset"); end end function SimulatorPresenceEngine:EndSimulation() SimulatorPresenceEngine:TurnOff(ID_devices_lights); Debug("red","Simulation is deactivated"); if (simu == "1") then Debug("grey", "Presence Simulator will Restart tomorrow around ".. fibaro:getValue(1, "sunsetHour")); pushMessage("Presence Simulator will Restart tomorrow around ".. fibaro:getValue(1, "sunsetHour")); wait_for_tomorrow = 1 -- will make EndTimeCalc add 24h to endtime during daytime end end function SimulatorPresenceEngine:ExitSimulation() --SimulatorPresenceEngine:TurnOff(ID_devices_lights); Debug("red","Presence Simulator is Terminated"); pushMessage("Presence Simulator is Terminated"); end -- function to switch off devices in the list function SimulatorPresenceEngine:TurnOff(group) Debug("red","TurnOff All 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, "turnOff"); name = fibaro:getName(id2); if (name == nil or name == string.char(0)) then name = "Unknown" end StandardDebug("Device:" .. name .. " Off "); end if (ID_On_After_Simu ~= 0 and Manual_Stop == 1) then fibaro:call(ID_On_After_Simu, "turnOn"); end end -- tester startup type et si autostart ou simu = 0 ne pas push et exit Debug("green", "Presence Simulator | v" .. version ); Debug( "green", "--------------------------------"); -- if stop hour is between 00 and 12h then will consider that stop hour is before midnight if tonumber(stop_hour) <= 12 then wait_for_tomorrow = 0 end -- Main Loop --------------------------------------- if (simu == "0") then Debug("red","Not starting Simulation (Simu_presence = 0)"); SimulatorPresenceEngine:ExitSimulation(); fibaro:abort(); end pushMessage("Scheduled Simulation starting time: " .. start_simu); ExtraDebug("Today's sunset is at "..fibaro:getValue(1, "sunsetHour").." - End of Simulation at "..stop_hour..":"..stop_minute); while (simu=="1" or simu=="0" ) do SimulatorPresenceEngine:EndTimeCalc(); -- local start_simu = "00:01" -- uncomment this line when testing to force a start hour. ex: 1 min after saving the scene. -- define if nighttime (sunset) if (os.date("%H:%M") >= start_simu) then sunset = 1 else sunset = 0 end if (simu == "1") then if sunset == 1 and (os.time() <= endtime) then Debug("grey", "It's sunset time -> Simulation ON"); SimulatorPresenceEngine:Launch(); --launch the simulation. SimulatorPresenceEngine:EndSimulation(); end if manualOveride == "1" then Debug("grey", "Manual Override Activated -> Simulation ON"); SimulatorPresenceEngine:Launch(); --launch the simulation. SimulatorPresenceEngine:EndSimulation(); end --fibaro:debug("sunset: "..sunset .. "endtime: " .. endtime .. "ostime: " .. os.time()); if manualOveride == "0" and sunset == 0 and NotifLoop == 30 then Debug("grey", "Waiting for next Sunset -> Simulation OFF."); end end if sunset == 1 and (os.time() >= endtime) and (os.time() <= (endtime + 60)) then Debug("grey","Simulation ended for this night."); end -- Condition to end simulation if (simu == "0") then SimulatorPresenceEngine:ExitSimulation(); Debug("red","Simu = 0, Exit from scene"); fibaro:abort(); end if NotifLoop <= 30 then if NotifLoop == 30 then NotifLoop = 0 end if NotifLoop == 0 then ExtraDebug("Looping to check for changes every 2min") end NotifLoop = NotifLoop + 1 end fibaro:sleep(2*60*1000); simu = fibaro:getGlobal("Simu_presence"); manualOveride = fibaro:getGlobal("overideSimuSunset"); end
-
Présentation Du P'tit Nouveau
sebcbien a répondu à un(e) sujet de FANDOMOTIQUE dans Nouveau ? Présentez-vous
Bienvenue ! Sent From my Vic20 -
J'ai pas tout capté avec la tondeuse, sans doute un reste d'un autre fil ... Git Updated https://github.com/sjauquet/GEA
- 12 330 réponses
-
- support
- script lua
-
(et 1 en plus)
Étiqueté avec :
-
Moi je rajouterais gea dans la chaîne ;-) Sent From my Vic20
-
@krikroff En parlant de ça, aurais-tu un bout de code qui permet de passer ces triggers (qui lancent une Xe fois la scène) d'être passés à la première ? Moi jusqu'ici je ne peut que détecter avec countscene et faire un exit si >1
-
Oui elle est puissante c clair, mais une boucle toutes les minutes, dans cette optique est sans doute plus propre si on n'est pas très fort en programmation. Imaginons que il y a un problème d'antenne, ou que la puce zwave est plantée et que les 100 devices zwave apparaissent morts en même temps et que pour chaque noeud mort on a demandé un push, un email et ... (non pas de prise de photo sur la cam 1 )... il y a intérêt à avoir prévu le coup ! Quand je vois que ma box plantait avec le module alarme de fibaro quand il y avait une intrusion (cligotement des lampes, et push de photos)... si je ne l'arrêtait pas dans les 30 secondes bah seul un reset hardware pouvait la récupérer...
-
il y a quand même une chose qu'il faut faire attention avec les triggers. Si on en met beaucoup (pour vérifier les nœuds morts par exemple) et que en un coup on en a 6 (une multiprise greenwave par exemple) on va avoir 6 scènes concurrentes qui vont se lancer pile en même temps, àquelques mili secondes d’intervalles. Il peut donc y avoir une surcharge massive en un temps court. On peut tester pour que la scène ne puisse pas se lancer en parallèle mais on risque de passer àcôté d'events. Inconvénient aussi, par exemple dans une boucle pour vérifier les nœuds morts, il faut déclarer tous les id en entête, donc revenir sur le script àchaque ajout/suppression de device... économique en resources, mais pas très plug&play àmon avis
-
Peux-tu faire ce test: Aller sur la scène et faire un save après 23h05 mais avant minuit Si la simulation démarre, je pense que j'ai une piste... Désolé mais pour le moment, j'ai une to-do de ouf ;-)
-
Perso je préfère aussi travailler avec des scènes dès que c'est possible, et garder les VD pour la commande et le retour d'état. donc: VD -> bouton -> set Variable globale Scène surveille VG et prend action quand il faut VD a une boucle dans le main loop qui surveille la VG et modifie l'icône, le texte et en fonction. Avantages: - Beaucoup plus portable et partageable, facilité de migration vers la V4 et ré-installant tout et ceux qui copieront e code n'auront qu'une VG àcréer - Actionnable àpartir d'aures scènes sans devoir récupérer l'id du bouton et du VD, juste une VG a récupérer (et qui aura toujours le même nom...) - Status analysable par d'autres Scènes et VD.
-
Désolé, mais ce WE, entre les enfants, aniversaires, balades et la migration de mon PC vers une nouvelle machine, je n'ai plus trop suivi... jojo, tu as eu réponse à toutes tes questions ? Dès que je peux j'installe ce beau VD :-)
-
Je ne sais pas regarder ça maintenant, pour que je puisse regarder, sois sûr que j'aie toutes les infos (heures démarrage et arrêt. Heures programmées et heure ou tu as interrompu etc. Merci Sent From my Vic20
-
A propos, J'ai mis le repo git de YAPS dans ma signature (uniquement code de la scène) Sent From my Vic20