22.07.2024, 05:38
(22.07.2024, 05:36)admin Wrote: Online status can be done via a scheduled script.
If a device is battery powered then the maximum allowed delta should be increased from 1 hour (60 * 60) to 4 hours.
Code:ieeeaddr = 'cc86ecfffe728382'
updatetime = db:getone([[
SELECT updatetime
FROM zb_devices
WHERE ieeeaddr=?
]], ieeeaddr)
diff = os.time() - updatetime
delta = 60 * 60 * 1.1 -- max time delta in seconds +10%
online = diff < delta
grp.checkwrite('0/0/1', online)
Ok, thanks!