Hallo liebes Forum,
wie kann ich in einem LUA Skript (Alarmanlage scharf stellen) prüfen, ob alle Fenster geschlossen sind. Sofern ein Fenster nicht geschlossen ist, möchte ich eine Mail auf mein Handy erhalten mit der Information "Fenster xy ist noch offen, Kontakt nicht Schaft gestellt!“
Ich benutze folgendes Skript zum Aktivieren der Alarmfunktion, in diesem möchte ich die Prüfung der offenen Fenster (Skript 2) integrieren.
ggf. kann das Skript noch optimiert werden.
–[[
%% properties
%% globals
–]]
local FK1WZID = 22
local FK2WZID = 26
local FK3WZID = 30
local FK4WZliID = 34
local FK5WZreID = 38
local FK1KUEliID = 46
local FK2KUEreID = 50
local FK1DIELEID = 13
local FK1BZID = 84
local FK1HWRID = 88
local Alarm1ID = 139
local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getValue(FK1WZID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(FK1WZID, “setArmed”, “1”);
end
if (
( tonumber(fibaro:getValue(FK2WZID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(FK2WZID, “setArmed”, “1”);
end
if (
( tonumber(fibaro:getValue(FK3WZID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(FK3WZID, “setArmed”, “1”);
end
if (
( tonumber(fibaro:getValue(FK4WZliID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(FK4WZliID, “setArmed”, “1”);
end
if (
( tonumber(fibaro:getValue(FK5WZreID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(FK5WZreID, “setArmed”, “1”);
end
if (
( tonumber(fibaro:getValue(FK1KUEliID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(FK1KUEliID, “setArmed”, “1”);
end
if (
( tonumber(fibaro:getValue(FK2KUEreID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(FK2KUEreID, “setArmed”, “1”);
end
if (
( tonumber(fibaro:getValue(FK1DIELEID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(FK1DIELEID, “setArmed”, “1”);
end
if (
( tonumber(fibaro:getValue(FK1BZID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(FK1BZID, “setArmed”, “1”);
end
if (
( tonumber(fibaro:getValue(FK1HWRID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(FK1HWRID, “setArmed”, “1”);
end
if (
( tonumber(fibaro:getValue(Alarm1ID, “armed”)) ~= 1 )
or
startSource[“type”] == “other”
)
then
fibaro:call(Alarm1ID, “setArmed”, “1”);
end
fibaro:call(70, “sendPush”, “Alarm aktiviert”); --ID Daniel Handy
fibaro:call(81, “sendPush”, “Alarm aktiviert”); --ID Mareen Handy
Jetzt wollte ich folgendes Skript integrieren und bei der Aktivierung der Alarmanlage prüfen, ob alle Fenster und Türen geschlossen sind. Ich hatte mit dem folgenden Skript bereits experimentiert, erhalte aber immer eine Fehlermeldung
–[[
%% properties
3 WeatherConditionConverted
%% globals
–]]
local phoneID = {70, 81} – Handy-IDs
local maxID = 1000
Debug = function ( color, message )
fibaro:debug(string.format(’< %s style=“color:%s;”>%s’, “span”, color, message, “span”))
end
local startSource = fibaro:getSourceTrigger();
if (fibaro:getValue(3, “WeatherConditionConverted”) == “rain” or startSource[‘type’] == ‘other’) then
if (startSource[‘type’] == ‘other’) then
Debug(‘white’, “SZENE MANUELL GESTARTET”)
else
Debug(‘green’, “SZENE DURCH REGEN-VORHERSAGE GESTARTET”)
end
Debug(‘red’, “ACHTUNG! Es könnte regnen”)
Debug(‘white’, “Prüfe offene Fenster”)
for id = 1, maxID do
local deviceType = fibaro:getType(id)
if (deviceType == 'com.fibaro.windowSensor' or deviceType == 'com.fibaro.doorSensor') then
if (tonumber(fibaro:getValue(id, 'value')) == 1) then
local name = fibaro:getName(id)
local room = fibaro:getRoomNameByDeviceID(id)
Debug('red', "ACHTUNG! Regen vorhergesagt. " ..name.. " im Raum " ..room.. " ist offen!")
for k=1, maxID do
if phoneID[k] ~= nil then
fibaro:call(phoneID[k], 'sendPush', 'ACHTUNG: Regen vorhergesagt! ' ..name.. ' im Raum ' ..room.. ' ist offen!')
end
end
end
end
end
end
Vielen Dank für eure Hilfe.
Daniel