21.11.2018, 13:39
You need two scripts:
1. Event script mapped to a tag (for both setpoint and current temperature). For each object update, check if delta is within limits or not. If delta is ok, put current timestamp in storage:
2. Scheduled script which will check time difference between now and last_update key (in seconds):
1. Event script mapped to a tag (for both setpoint and current temperature). For each object update, check if delta is within limits or not. If delta is ok, put current timestamp in storage:
Code:
temp = grp.getvalue('1/1/1')
setp = grp.getvalue('1/1/2')
delta = math.abs(temp - setp)
if delta <= 1 then
storage.set('last_update', os.time())
storage.set('notified', false)
end
2. Scheduled script which will check time difference between now and last_update key (in seconds):
Code:
prev = storage.get('last_update', 0)
delta = prev - os.time()
if delta >= (24 * 60 * 60) then
notified = storage.get('notified')
if not notified then
-- send e-mail here
storage.set('notified', true)
end
end