The issue seems to be that the script is not checking the new state of the switch after sleeping.
Code: Select all
commandArray = {}
if (devicechanged['Main Entrance Door Sensor'] == 'Open' and otherdevices['Ben is Home'] == 'Off') then
os.execute("sleep " .. tonumber(9))
if (otherdevices['Ben is Home'] == 'Off') then
commandArray['SendNotification']='Security#The main entrance door was just opened'
end
end
return commandArray
Has anyone found a way to do this or should I be abandoning Lua for this particular task and using PHP or BASH?