This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Help example on simple light controll, lux
#8
(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
Reply


Messages In This Thread
RE: Help example on simple light controll, lux - by Joep - 14.03.2024, 09:47

Forum Jump: