Hi Daniel!
Ja, das ist ok. Es wäre sonst blöd, wenn Du im Sommer draußen bist und von Deinem eigenen Haus ausgesperrt wirst.
Allerdings sind die beiden Rolläden, zu denen ich die Schleife hinzugefügt habe, jetzt gar nicht heruntergefahren. Zum Testen, habe ich einen Kontakt geschlossen und einen offen gelassen um die Szene zu testen.
Hier mal die Szene und Debug:
--[[
%% autostart
%% properties
%% globals
--]]
local sourceTrigger = fibaro:getSourceTrigger();
local version = '2.0';
fibaro:debug('Rollershutter-Controller started for the first time (Ver.' .. version .. ')');
function rollershutter()
local version = '2.0';
local sunriseHour = fibaro:getValue(1,'sunriseHour');
local sunsetHour = fibaro:getValue(1,'sunsetHour');
local currentDate = os.date('*t');
local temp = tonumber(fibaro:getValue(3, 'Temperature'));
local rollershutter_runs = tonumber(fibaro:getGlobalValue('rollershutter_runs'));
local random = math.random(35);
local min = math.floor((random*100)/60);
if ((((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format('%02d', currentDate.hour) .. ':' .. string.format('%02d', currentDate.min) == sunriseHour)) and rollershutter_runs == 0 and tonumber(temp)>=0)
then
fibaro:debug('Rollershutter-Controller started (Ver.' .. version .. ')');
fibaro:setGlobal('rollershutter_runs', '1');
fibaro:debug('Sunrise... Opening rollershutters');
fibaro:debug('Waiting ' .. min .. ' min');
fibaro:sleep(random*100000);
fibaro:call(569, 'open');
fibaro:call(571, 'open');
fibaro:call(579, 'open');
fibaro:call(573, 'open');
fibaro:call(575, 'open');
fibaro:call(581, 'open');
fibaro:call(590, 'open');
fibaro:debug('Rollershutters opened');
fibaro:setGlobal('rollershutter_runs', '0');
elseif ((((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format('%02d', currentDate.hour) .. ':' .. string.format('%02d', currentDate.min) == sunsetHour)) and rollershutter_runs == 0 and tonumber(temp)>=0)
then
fibaro:debug('Rollershutter-Controller started (Ver.' .. version .. ')');
fibaro:setGlobal('rollershutter_runs', '1');
fibaro:debug('Sunset... Closing rollershutters');
fibaro:debug('Waiting ' .. min .. ' min');
fibaro:sleep(random*100000);
fibaro:call(590, 'close');
fibaro:call(571, 'close');
fibaro:call(579, 'close');
while (fibaro:getValue(675, 'value') > 0) do
fibaro:sleep(10*1000)
end
fibaro:call(573, 'close');
fibaro:call(575, 'close');
fibaro:call(581, 'close');
while
(fibaro:getValue(672, 'value') > 0) do
fibaro:sleep(10*1000)
end
fibaro:call(569, 'close');
fibaro:debug('Rollershutters closed');
fibaro:setGlobal('rollershutter_runs', '0');
elseif ((((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format('%02d', currentDate.hour) .. ':' .. string.format('%02d', currentDate.min) == sunriseHour)) and rollershutter_runs == 0 and tonumber(temp)<=0)
then
fibaro:debug('Rollershutter-Controller started (Ver.' .. version .. ')');
fibaro:setGlobal('rollershutter_runs', '1');
fibaro:debug('Sunrise... Temperatur < 0... Rollershutters stay closed.');
fibaro:setGlobal('rollershutter_runs', '0');
elseif ((((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format('%02d', currentDate.hour) .. ':' .. string.format('%02d', currentDate.min) == sunsetHour)) and rollershutter_runs == 0 and tonumber(temp)<=0)
then
fibaro:debug('Rollershutter-Controller started (Ver.' .. version .. ')');
fibaro:setGlobal('rollershutter_runs', '1');
fibaro:debug('Sunset... Temperatur < 0... Rollershutters stay opened.');
fibaro:setGlobal('rollershutter_runs', '0');
end
setTimeout(rollershutter, 60*1000);
end
if (sourceTrigger['type'] == 'autostart') then
rollershutter();
end
[DEBUG] 14:49:00: Rollershutter-Controller started for the first time (Ver.2.0)
[DEBUG] 15:57:01: Rollershutter-Controller started (Ver.2.0)
[DEBUG] 15:57:01: Sunset… Closing rollershutters
[DEBUG] 15:57:01: Waiting 31 min
[ERROR] 16:28:41: LUA error: /opt/fibaro/scenes/517.lua:48: attempt to compare number with string
Habe ich wieder irgendwo ein Komma vergessen?
Viele Grüße
Christian