alert if water somewhere running - Printable Version +- Logic Machine 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: alert if water somewhere running (/showthread.php?tid=1133) |
alert if water somewhere running - Thinklight - 13.12.2017 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) |