21.03.2019, 13:27
(15.03.2019, 08:05)admin Wrote: Create an event script mapped to temperature object:
Code:temp = event.getvalue()
curr = temp > 22
prev = storage.get('temp_over')
if curr ~= prev then
if curr then
storage.set('temp_time', os.time())
storage.set('temp_notified', false)
end
storage.set('temp_over', curr)
end
Then create a scheduled script that runs every minute to check whether e-mail needs to be sent. Change delta time if needed (60 * 60 = 1 hour in seconds).
Code:curr = storage.get('temp_over')
notified = storage.get('temp_notified')
if curr and not notified then
now = os.time()
time = storage.get('temp_time', now)
delta = now - time
if delta > 60 * 60 then
-- send email
storage.set('temp_notified', true)
end
end
Thank you very much!! Script works perfectly on my LM. Is there any handbook or manual to learn advanced scripts in LUA???