Logic Machine Forum
Hold a state when value changes - 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: Hold a state when value changes (/showthread.php?tid=5736)



Hold a state when value changes - FatMax - 12.11.2024

I have a script where I'm monitoring consumption, but can get no finer numbers than 1, 2, 3 and 4 for my measurements. When consumption is same or above 2 I set an object to true, and when it is below the object goes to false.

However, this is causing some issues as the consumption temporarily drops below 2 for a few milliseconds, causing my object to drop to false. 

Does anyone have a best practice or hysteresis-type solution to this kind of problem?


RE: Hold a state when value changes - Daniel - 12.11.2024

If it is event script then just add small delay to it and set Execution Mode: First instance only


RE: Hold a state when value changes - FatMax - 12.11.2024

But I want the object to go to false if it goes below 2 and stays there. Wouldn't your suggestion prevent that?


RE: Hold a state when value changes - Daniel - 12.11.2024

it will change only after the delay but if new telegram arrives in the meantime then the current script will be cancelled and new with new value will run.


RE: Hold a state when value changes - Erwin van der Zwart - 12.11.2024

Shouldn’t it be “last instance” then?


RE: Hold a state when value changes - Daniel - 12.11.2024

True Smile