Advertisement
Drogenfahnder

Untitled

Feb 25th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. --[[
  2. %% autostart
  3. %% properties
  4. 33 value
  5. %% globals
  6. --]]
  7.  
  8. local startSource = fibaro:getSourceTrigger();
  9. function tempFunc()
  10.  
  11. if (tonumber(fibaro:getGlobalValue("TagNacht")) == tonumber("1") ) then
  12. local startSunLux = 25000; -- über 10.000 Lux für zu
  13. local startSunDelay = 300; -- 5 Min bis zu
  14. local endSunLux = 8000; -- unter 8000 Lux für auf
  15. local endSunDelay = 1200; -- 20 Min bis auf
  16. local gSunFirstMax = (fibaro:getGlobal("SunFirstMax"));
  17. local gSunFirstMin = (fibaro:getGlobal("SunFirstMin"));
  18. gSunFirstMaxTime = tonumber(gSunFirstMaxTime)
  19. gSunFirstMaxTime = fibaro:getGlobalModificationTime("SunFirstMax");
  20. gSunFirstMinTime = fibaro:getGlobalModificationTime("SunFirstMin");
  21. gSunFirstMinTime = tonumber(gSunFirstMinTime);
  22. local currentLux = tonumber(fibaro:getValue(33, "value"));
  23. --currentLux = 17000; -- nur für Debug !!
  24. fibaro:debug("— Current Lux: " .. currentLux .. " RolloDown: " .. fibaro:getGlobalValue("RolloSunDown") .. " parallele Szenen: " .. fibaro:countScenes() .. " —");
  25.  
  26. if ( currentLux >= startSunLux and fibaro:getGlobalValue("RolloSunDown") ~= 1) then
  27. if (gSunFirstMaxTime == 0 or gSunFirstMaxTime == nil or gSunFirstMax == 0) then
  28. fibaro:setGlobal("SunFirstMax",currentLux);
  29. fibaro:debug("New Max Timestamp (Down)");
  30. setTimeout(tempFunc, startSunDelay*1000) -- sicherheitshalber diese Szene / Funktion schonmal für zukünftigen Zeitpunkt aufrufen, falls es da dann keinen Trigger gibt
  31. elseif (os.time() - gSunFirstMaxTime >= startSunDelay ) then
  32.  
  33. fibaro:call(11, "setValue", "45");
  34. fibaro:call(15, "setValue", "45");
  35. --fibaro:call(113, „setValue“, „45“);
  36. --fibaro:call(114, „setValue“, „45“);
  37.  
  38. fibaro:debug("*** Aktion: ZU nach " .. os.time() - gSunFirstMaxTime);
  39. fibaro:setGlobal("RolloSunDown",1);
  40. else
  41. fibaro:debug("Restzeit bis zu " .. os.time() - gSunFirstMaxTime - startSunDelay);
  42. end
  43. else
  44. fibaro:setGlobal("SunFirstMax",0);
  45. fibaro:debug("RolloDown Restzeit reset");
  46. end
  47.  
  48. if ( currentLux <= endSunLux and fibaro:getGlobalValue("RolloSunDown") == 1)
  49. then
  50. if (gSunFirstMinTime ~= 0
  51. or gSunFirstMinTime == nil
  52. or gSunFirstMin == '0')
  53. then
  54. fibaro:setGlobal("SunFirstMin", currentLux);
  55. fibaro:debug("New Min Timestamp (Up)");
  56. setTimeout(tempFunc, endSunDelay*1000)
  57. --sicherheitshalber diese Szene / Funktion schonmal für zukünftigen Zeitpunkt aufrufen, falls es da dann keinen Trigger gibt
  58. elseif (os.time() - gSunFirstMinTime >= endSunDelay) then
  59.  
  60. fibaro:call(11, "open");
  61. fibaro:call(15, "open");
  62. --fibaro:call(118, "open");
  63. --fibaro:call(120, "open");
  64.  
  65. fibaro:debug("*** Aktion: AUF nach " .. os.time() - gSunFirstMinTime);
  66. fibaro:setGlobal("RolloSunDown",0);
  67. else
  68. fibaro:debug("Restzeit bis auf " .. os.time() - gSunFirstMinTime - endSunDelay);
  69. end
  70. else
  71. fibaro:setGlobal("SunFirstMin",0);
  72. fibaro:debug("RolloUp Restzeit reset");
  73. end
  74. else
  75. fibaro:debug("Nachtabschaltung");
  76. end
  77. end
  78.  
  79. if ( startSource["type"] == "other" ) then
  80. -- manueller Start der Szene
  81. if (fibaro:getGlobalValue("RolloSunDown") == 1) then
  82. fibaro:debug("Manuelles sofortiges Öffnen..");
  83. fibaro:call(11, "open");
  84. fibaro:call(15, "open");
  85. --fibaro:call(118, „open“);
  86. --fibaro:call(120, „open“);
  87. fibaro:setGlobal("RolloSunDown",0);
  88. else
  89. fibaro:debug("Manueller sofortiger Sonnenschutz..");
  90. fibaro:call(11, "setValue", "45");
  91. fibaro:call(15, "setValue", "45");
  92. --fibaro:call(116, „setValue“, „45“);
  93. --fibaro:call(114, „setValue“, „45“);
  94.  
  95. fibaro:setGlobal("RolloSunDown",1);
  96. end
  97. else
  98. -- automatischer Lauf
  99. fibaro:debug("Scene läuft.. ");
  100. tempFunc();
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement