25.10.2021, 18:12
Hello together,
im tying to build a simple "alarm system" with email notification.
But i have a little problem with the loop for the email notification.
If there is an alarm, i don´t get a one-time email notification, i get endles email notifications.
Can somebody show me where the mistake in my thinking is?
The objects / variabels (alarm_on; door_1_closed; door_1_locked; door_2_cloded; door_3_closed have the same "Tag" to start a event based script.
-- ==========================================================================
--
-- alarm system
-- © 2021 123einerlei
--
-- simple email alarm notification
--
-- ==========================================================================
--variable declaration-------------------------------------------------------
alarm_on = grp.getvalue('1/1/1') -- arm the alarm system
garage_armed = grp.getvalue('2/2/2') -- alarm system armed
alarm = grp.getvalue('3/3/3') -- alarm
door_1_closed = grp.getvalue('4/4/4') -- side entrance door closed
door_1_locked = grp.getvalue('5/5/5') -- side entrance door locked
door_2_closed = grp.getvalue('6/6/6') -- door street closed
door_3_closed = grp.getvalue('7/7/7') -- door garden closed
--arm the alarmsystem--------------------------------------------------------
if
alarm_on == true then
--logic----------------------------------------------------------------------
if
door_1_closed == true and door_1_locked == true and door_2_closed == true and door_3_closed == true
then
grp.write('3/3/3', true) -- no alarm
i = 1
else
grp.write('3/3/3', false) -- alarm
alert('message')
--loop for one-time email notification---------------------------------------
repeat
Email("user@provider.com", "subject", "message")
i, = i+1
until (i > 1)
end
--status alarmsystem---------------------------------------------------------
grp.write('2/2/2', true) -- status alarmsystem armed
else
grp.write('2/2/2', false) -- status alarm system disarmed
end
im tying to build a simple "alarm system" with email notification.
But i have a little problem with the loop for the email notification.
If there is an alarm, i don´t get a one-time email notification, i get endles email notifications.
Can somebody show me where the mistake in my thinking is?
The objects / variabels (alarm_on; door_1_closed; door_1_locked; door_2_cloded; door_3_closed have the same "Tag" to start a event based script.
-- ==========================================================================
--
-- alarm system
-- © 2021 123einerlei
--
-- simple email alarm notification
--
-- ==========================================================================
--variable declaration-------------------------------------------------------
alarm_on = grp.getvalue('1/1/1') -- arm the alarm system
garage_armed = grp.getvalue('2/2/2') -- alarm system armed
alarm = grp.getvalue('3/3/3') -- alarm
door_1_closed = grp.getvalue('4/4/4') -- side entrance door closed
door_1_locked = grp.getvalue('5/5/5') -- side entrance door locked
door_2_closed = grp.getvalue('6/6/6') -- door street closed
door_3_closed = grp.getvalue('7/7/7') -- door garden closed
--arm the alarmsystem--------------------------------------------------------
if
alarm_on == true then
--logic----------------------------------------------------------------------
if
door_1_closed == true and door_1_locked == true and door_2_closed == true and door_3_closed == true
then
grp.write('3/3/3', true) -- no alarm
i = 1
else
grp.write('3/3/3', false) -- alarm
alert('message')
--loop for one-time email notification---------------------------------------
repeat
Email("user@provider.com", "subject", "message")
i, = i+1
until (i > 1)
end
--status alarmsystem---------------------------------------------------------
grp.write('2/2/2', true) -- status alarmsystem armed
else
grp.write('2/2/2', false) -- status alarm system disarmed
end