Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- %% autostart
- %% properties
- 33 value
- %% globals
- --]]
- local startSource = fibaro:getSourceTrigger();
- function tempFunc()
- if (tonumber(fibaro:getGlobalValue("TagNacht")) == tonumber("1") ) then
- local startSunLux = 25000; -- über 10.000 Lux für zu
- local startSunDelay = 300; -- 5 Min bis zu
- local endSunLux = 8000; -- unter 8000 Lux für auf
- local endSunDelay = 1200; -- 20 Min bis auf
- local gSunFirstMax = (fibaro:getGlobal("SunFirstMax"));
- local gSunFirstMin = (fibaro:getGlobal("SunFirstMin"));
- gSunFirstMaxTime = tonumber(gSunFirstMaxTime)
- gSunFirstMaxTime = fibaro:getGlobalModificationTime("SunFirstMax");
- gSunFirstMinTime = fibaro:getGlobalModificationTime("SunFirstMin");
- gSunFirstMinTime = tonumber(gSunFirstMinTime);
- local currentLux = tonumber(fibaro:getValue(33, "value"));
- --currentLux = 17000; -- nur für Debug !!
- fibaro:debug("— Current Lux: " .. currentLux .. " RolloDown: " .. fibaro:getGlobalValue("RolloSunDown") .. " parallele Szenen: " .. fibaro:countScenes() .. " —");
- if ( currentLux >= startSunLux and fibaro:getGlobalValue("RolloSunDown") ~= 1) then
- if (gSunFirstMaxTime == 0 or gSunFirstMaxTime == nil or gSunFirstMax == 0) then
- fibaro:setGlobal("SunFirstMax",currentLux);
- fibaro:debug("New Max Timestamp (Down)");
- setTimeout(tempFunc, startSunDelay*1000) -- sicherheitshalber diese Szene / Funktion schonmal für zukünftigen Zeitpunkt aufrufen, falls es da dann keinen Trigger gibt
- elseif (os.time() - gSunFirstMaxTime >= startSunDelay ) then
- fibaro:call(11, "setValue", "45");
- fibaro:call(15, "setValue", "45");
- --fibaro:call(113, „setValue“, „45“);
- --fibaro:call(114, „setValue“, „45“);
- fibaro:debug("*** Aktion: ZU nach " .. os.time() - gSunFirstMaxTime);
- fibaro:setGlobal("RolloSunDown",1);
- else
- fibaro:debug("Restzeit bis zu " .. os.time() - gSunFirstMaxTime - startSunDelay);
- end
- else
- fibaro:setGlobal("SunFirstMax",0);
- fibaro:debug("RolloDown Restzeit reset");
- end
- if ( currentLux <= endSunLux and fibaro:getGlobalValue("RolloSunDown") == 1)
- then
- if (gSunFirstMinTime ~= 0
- or gSunFirstMinTime == nil
- or gSunFirstMin == '0')
- then
- fibaro:setGlobal("SunFirstMin", currentLux);
- fibaro:debug("New Min Timestamp (Up)");
- setTimeout(tempFunc, endSunDelay*1000)
- --sicherheitshalber diese Szene / Funktion schonmal für zukünftigen Zeitpunkt aufrufen, falls es da dann keinen Trigger gibt
- elseif (os.time() - gSunFirstMinTime >= endSunDelay) then
- fibaro:call(11, "open");
- fibaro:call(15, "open");
- --fibaro:call(118, "open");
- --fibaro:call(120, "open");
- fibaro:debug("*** Aktion: AUF nach " .. os.time() - gSunFirstMinTime);
- fibaro:setGlobal("RolloSunDown",0);
- else
- fibaro:debug("Restzeit bis auf " .. os.time() - gSunFirstMinTime - endSunDelay);
- end
- else
- fibaro:setGlobal("SunFirstMin",0);
- fibaro:debug("RolloUp Restzeit reset");
- end
- else
- fibaro:debug("Nachtabschaltung");
- end
- end
- if ( startSource["type"] == "other" ) then
- -- manueller Start der Szene
- if (fibaro:getGlobalValue("RolloSunDown") == 1) then
- fibaro:debug("Manuelles sofortiges Öffnen..");
- fibaro:call(11, "open");
- fibaro:call(15, "open");
- --fibaro:call(118, „open“);
- --fibaro:call(120, „open“);
- fibaro:setGlobal("RolloSunDown",0);
- else
- fibaro:debug("Manueller sofortiger Sonnenschutz..");
- fibaro:call(11, "setValue", "45");
- fibaro:call(15, "setValue", "45");
- --fibaro:call(116, „setValue“, „45“);
- --fibaro:call(114, „setValue“, „45“);
- fibaro:setGlobal("RolloSunDown",1);
- end
- else
- -- automatischer Lauf
- fibaro:debug("Scene läuft.. ");
- tempFunc();
- end
Add Comment
Please, Sign In to add comment