Anbei eine Rollladen-Steuerung, welche die Rollläden anhand des Sonnenaufgangs/-untergangs steuert. Es gibt in dem Skript eine random()-Zeit, welche das Skript wartet, bis es den Befehl absendet. Zusätzlich ist eine Prüfung eingebaut, ob die Temperatur unter 0° ist. So werden Schäden bei festgefrorenen Rollladenmotoren verhindert. Ihr müsst nur die ID’s der Geräte anpassen ![]()
Es wird eine Variable rollershutter_runs benötigt.
--[[
%% autostart
%% properties
%% globals
--]]
local sourceTrigger = fibaro:getSourceTrigger();
local version = '2.0';
fibaro:debug('Rollladen-Steuerung erstmalig gestartet (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('Rollladen-Steuerung gestartet (Ver.' .. version .. ')');
fibaro:setGlobal("rollershutter_runs", "1");
fibaro:debug(Sonnenaufgang. Öffne Rollladen');
fibaro:debug('Warte ' .. min .. ' min');
fibaro:sleep(random*100000);
fibaro:call(48, "open");
fibaro:debug('Rollladen geöffnet');
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('Rollladen-Steuerung gestartet (Ver.' .. version .. ')');
fibaro:setGlobal("rollershutter_runs", "1");
fibaro:debug('Sonnenuntergang... Schließe Rollladen');
fibaro:debug('Waiting ' .. min .. ' min');
fibaro:sleep(random*100000);
fibaro:call(48, "close");
fibaro:debug('Rollladen geschlossen');
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('Rollladen-Steuerung gestartet (Ver.' .. version .. ')');
fibaro:setGlobal("rollershutter_runs", "1");
fibaro:debug('Sonnenaufgang... Temperatur < 0... Rollladen bleibt geschlossen.');
fibaro:call(98, "sendPush", "Temperatur unter 0. Rollladen wurde nicht geöffnet. Bitte manuell öffnen", "rollershutter");
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('Rollladen-Steuerung gestartet (Ver.' .. version .. ')');
fibaro:setGlobal("rollershutter_runs", "1");
fibaro:debug('Sonnenuntergang... Temperatur < 0... Rollladen bleibt offen.');
fibaro:call(98, "sendPush", "Temperatur unter 0. Rollladen wurde nicht geöffnet. Bitte manuell öffnen", "rollershutter");
fibaro:setGlobal("rollershutter_runs", "0");
end
setTimeout(rollershutter, 60*1000);
end
if (sourceTrigger["type"] == "autostart") then
rollershutter();
end


