Hallo liebe Gemeinde!
Ich wundere mich. Seit gestern geht folgendes Script nicht mehr:
--[[
%% properties
892 value
1226 value
%% globals
--]]
local sensors = {892, 1226}
local delay = 0
local debug = false
function actionsMotion()
fibaro:debug('Führe Aktionen bei Bewegungserkennung aus')
if (fibaro:getGlobal('TimeOfDay') == 'Evening' or fibaro:getGlobal('TimeOfDay') == 'Morning') then
fibaro:debug('Licht kann eingeschaltet werden.')
fibaro:call(1078, "turnOn");
fibaro:call(1078, "setColor", "255", "255", "255", "0")
fibaro:call(1078, "setBrightness", "35");
setTimeout(function()
fibaro:call(1078, "turnOff");
end, 45000)
else
fibaro:debug('Es ist Tag. Schalte das Licht nicht ein.')
end
end
function actionsNoMotion()
fibaro:debug('Führe Aktionen nach Ende Bewegung aus')
end
local instances = tonumber(fibaro:countScenes());
function getSensorStatus()
for i,n in ipairs(sensors) do
if (tonumber(fibaro:getValue(n, "value")) > 0) then
return 1;
end
end
return 0;
end
function getLastBreach()
local breach = 0;
for i,n in ipairs(sensors) do
local nBreach = tonumber(fibaro:getValue(n, "lastBreached"));
if(nBreach > breach) then
breach = nBreach;
end
end
return breach;
end
function checkMotion()
lastBreached = getLastBreach();
time = os.time();
if (debug) then fibaro:debug("Zuletzt ausgelöst: Vor "..(time-lastBreached).." Sekunden"); end
if (getSensorStatus() == 1) then
return true;
end
if ((time-lastBreached)>=delay) then
return false;
end
return true;
end
local lastBreached = getLastBreach()
if (fibaro:getSourceTriggerType() == 'property' and getSensorStatus() == 1) then
if (instances > 1) then fibaro:abort(); end
fibaro:debug('Bewegung im Raum erkannt - Starte Timer')
actionsMotion()
while (checkMotion()) do
fibaro:sleep(5000);
end
if (debug) then fibaro:debug("Keine Bewegung mehr erkannt."); end
actionsNoMotion()
end
Hier, der Debug:
[DEBUG] 17:53:56: line 46: attempt to compare number with nil
[DEBUG] 17:54:22: line 46: attempt to compare number with nil
[DEBUG] 17:56:09: line 46: attempt to compare number with nil
[DEBUG] 17:57:05: line 46: attempt to compare number with nil
[DEBUG] 17:57:49: line 46: attempt to compare number with nil
[DEBUG] 17:59:37: line 46: attempt to compare number with nil
[DEBUG] 18:00:48: line 46: attempt to compare number with nil
Es ging, ohne das ich irgendetwas am kompletten System geändert hätte, nicht mehr. Nach näherem Hinsehen gerade, fiel mir auf, dass ein Bewegungsmelder plötzlich weg ist. Das ist auch nicht das erste Mal, dass Module von alleine aus der HC2 verschwinden.
Kommt der Fehler oben, daher das der Motionsensor sich verabschiedet hat?
Weiß jemand Rat?
Viele Grüße
Christian