![]() |
|
Send email alert when group has been on for 5 minutes - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Send email alert when group has been on for 5 minutes (/showthread.php?tid=5955) |
Send email alert when group has been on for 5 minutes - jamesng - 04.04.2025 I have a sensor on a garage door which monitors whether the door is open (value of 255) or closed (value of 0) I'd like to script an email alert which gets triggered if the door has been left open for more than 5 minutes. Many thanks in advance Kind Regards James RE: Send email alert when group has been on for 5 minutes - admin - 04.04.2025 Use Event script with "Execution mode" set to "Last instance": Code: value = event.getvalue()
if value == 255 then
os.sleep(5 * 60)
-- send alert
endRE: Send email alert when group has been on for 5 minutes - jamesng - 04.04.2025 Where does one set the Execution Mode to Last Instance (I'm on a CBUS SHAC so perhaps don't have this option)? Would the following work on the SHAC - event script name is "'Garage Door Open Too Long Notification" - script gets killed if the sensor returns to value 0 Code: if (event.getvalue() == 255) then
log('The garage door has been opened.')
os.sleep(5*60)
log('The garage door has been left open for 5 minutes.')
end
if (event.getvalue() == 0) then
log('The garage door is closed.')
item = script.get('Garage Door Open Too Long Notification')
script.kill(item.id)
endRE: Send email alert when group has been on for 5 minutes - jamesng - 04.04.2025 ... hmm the script.kill above doesn't seem to work as intended. The first instance of the script keeps running, when the script gets called again on door close. Any ideas how to modify the above to stop the first instance of the script which is sleeping for 5*60 seconds?? RE: Send email alert when group has been on for 5 minutes - Daniel - 04.04.2025 see this: https://forum.logicmachine.net/showthread.php?tid=2884&pid=18564#pid18564 RE: Send email alert when group has been on for 5 minutes - jamesng - 04.04.2025 Thanks Daniel - that approach works. |