I want to achieve that the doorbell will start to ring after the door sensor is opened for more then 20 second. It must to continue ringing every 20 seconds if the door is not closed.
If the door is closed before the 20 second it must not ring.
The script below works but it rings even if you open and close the door within 20 second.
Code: Select all
commandArray = {}
for deviceName,deviceValue in pairs(otherdevices) do
if (deviceName=='Door') then
if deviceValue == "Alarm" then
commandArray['Doorbell'] = "On AFTER 20"
print("Doors are open!!!")
elseif deviceValue == "Normal" then
print("Doors are closed!!!")
end
end
end