13.12.2017, 09:22
(This post was last modified: 13.12.2017, 09:23 by Thinklight.)
I am connected over m-bus and get value "xxx m3" and if water somewhere running out meter not stops for example one hour I need get alert.
here is the scheduled script that runs every 5min:
-- current meter value
curr = grp.getvalue('1/1/1')
-- list of previous values
list = storage.get('water_meter_values', {})
-- add current value to list
table.insert(list, curr)
-- remove old values from the list (5 min * 12 = 1 hour)
while #list > 12 do
table.remove(list, 1)
end
-- delta between current value and value from an hour ago
delta = curr - list[ 1 ]
if delta > 123 then
-- run alert, send e-mail etc
end
-- save new value list
storage.set('water_meter_values', list)
here is the scheduled script that runs every 5min:
-- current meter value
curr = grp.getvalue('1/1/1')
-- list of previous values
list = storage.get('water_meter_values', {})
-- add current value to list
table.insert(list, curr)
-- remove old values from the list (5 min * 12 = 1 hour)
while #list > 12 do
table.remove(list, 1)
end
-- delta between current value and value from an hour ago
delta = curr - list[ 1 ]
if delta > 123 then
-- run alert, send e-mail etc
end
-- save new value list
storage.set('water_meter_values', list)