Logic Machine Forum
ON Delay - 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: ON Delay (/showthread.php?tid=3538)



ON Delay - khalil - 01.09.2021

hello 
what is the best way to do an ON delay?
I have a resident script that monitors two values to check water leakage by comparing the tank level with a stored value (tank level when user activates level leakage detection) when the difference between the values becomes more than 2cm, the alarm will be triggered.
but sometimes the level sensor gives a pulse for a short time that will make a fake alarm, I think ON-Delay will be enough


I mentioned the case details to see if there are other ideas


RE: ON Delay - Daniel - 01.09.2021

Compare the update time to OS time and if diff is grater than X then send your telegram.


RE: ON Delay - khalil - 02.09.2021

(01.09.2021, 15:04)Daniel. Wrote: Compare the update time to OS time and if diff is grater than X then send your telegram.

could you share an example


RE: ON Delay - Daniel - 02.09.2021

Code:
object = grp.find('1/1/1')

timer=10 --dealy
delta = os.time() - object.updatetime
    if object and object.data and delta > timer then
 
  --your action
  end
What is important is the delay and interval time of your script.  For example if delay is 10 and interval 2 then script will check 5 times the condition.


RE: ON Delay - khalil - 02.09.2021

(02.09.2021, 09:54)Daniel. Wrote:
Code:
object = grp.find('1/1/1')

timer=10 --dealy
delta = os.time() - object.updatetime
    if object and object.data and delta > timer then
 
  --your action
  end
What is important is the delay and interval time of your script.  For example if delay is 10 and interval 2 then script will check 5 times the condition.

thank you, Daniel
If I got your point, does the example you mentioned means that I will have a 5*10 delay?
What is your recommendation for the delay and interval time, should be (=,>,<) or didnt matter?


RE: ON Delay - Daniel - 02.09.2021

if you make 50s delay and put 10s interval then the last check will be 50s +~10 sec