14.03.2024, 09:47
(14.03.2024, 09:26)admin Wrote: You can use grp.find() and updatetime field to check when the last telegram was sent to this specific object. Then use os.time() to calculate the delta.
Alternative solution is to use a scheduled script that runs every X minutes.
Hi admin that will not work for me as the updatetime of the object is changing all the time.
Code:
lux = grp.getvalue('1/0/3')
azimut = grp.getvalue('5/5/2')
alarm = grp.getvalue('4/0/1')
hysterese = 10
if alarm == false then
if lux > 700 then
if azimut > 95 and azimut < 150 then
grp.write('2/3/1', 100)
grp.write('2/3/2', 0)
grp.write('2/3/6', 0)
elseif azimut > 180 and azimut < 230 then
grp.write('2/3/1', 0)
grp.write('2/3/2', 100)
grp.write('2/3/6', 0)
elseif azimut > 230 and azimut < 280 then
grp.write('2/3/1', 0)
grp.write('2/3/2', 0)
grp.write('2/3/6', 100)
else
grp.write('2/3/1', 0)
grp.write('2/3/2', 0)
grp.write('2/3/6', 0)
end
elseif lux < 500 then
object = grp.find('1/0/3')
time = object.updatetime -- time will change every time the object is updated
grp.write('2/3/1', 0)
grp.write('2/3/2', 0)
grp.write('2/3/6', 0)
end
end