03.10.2016, 15:36
Hi Savaskorkmaz,
I don't know if there is a function for this in the system, but i solved it once with a little resident script.
Put your actions on the position where the logging is now (replace them with your action).
BR,
Erwin van der Zwart
I don't know if there is a function for this in the system, but i solved it once with a little resident script.
Put your actions on the position where the logging is now (replace them with your action).
Code:
-- Check all modbus meters for connection
query = 'SELECT * FROM modbus_devices'
meter_state = db:getall(query)
previous_state = storage.get('meterstate')
if previous_state == nil then
for _, device in ipairs(meter_state) do
if device.active == 0 then
log(device.name .. " = down")
else
log(device.name .. " = active")
end
end
storage.set('meterstate', meter_state)
else
for _, device in ipairs(meter_state) do
if device.active ~= previous_state[_].active then
log(device.name .. ' is changed to ' .. device.active)
end
end
storage.set('meterstate', meter_state)
end
BR,
Erwin van der Zwart