Hi,
First post here.
For the context, I'm receiving a temperature from a KNX node and I would like to compare it with a set value to trigger a Reset Set gate.
What I would like my flow to do is :
If temperature is bigger or equal than the high value set the RS gate to true but if the temperature is below than the low value set to false.
If the set value (high or low ) change the function is triggered but I struggle to keep the last state of my previous payload or function if it wasn't refreshed and the output become wrong or alternate.
Hope this is understandable. Here is a simplified flow without the KNX part:
[{"id":"1ee4050.64e7dfb","type":"function","z":"eeca8943.a75718","name":">=","func":"var local=context.get('data') || {};\n\nlocal.In1=msg.In1;\nlocal.In2=msg.In2;\n\nif (local.In1===undefined)//test exists\n{\n local.In1=20;\n}\n\nif (local.In2===undefined)//test exists\n{\n local.In2=18;\n}\n\n\nif (local.In1 >= local.In2) {\n result = true\n} \nelse {\n result = false\n}\nmsg = {topic : \">=\", payload : result};\n\ncontext.set('data',local);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":400,"wires":[["b5eed4d1.ed7b28"]]},{"id":"9cadaae7.757b48","type":"function","z":"eeca8943.a75718","name":"<","func":"var local=context.get('data') || {};\n\nlocal.In1=msg.In1;\nlocal.In2=msg.In2;\n\nif (local.In1===undefined)//test exists\n{\n local.In1=20;\n}\n\nif (local.In2===undefined)//test exists\n{\n local.In2=15;\n}\n\n\nif (local.In1 < local.In2) {\n result = true\n} \nelse {\n result = false\n}\nmsg = {topic : \">=\", payload : result};\n\ncontext.set('data',local);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":500,"wires":[["20c1fbaa.5b1fa4"]]},{"id":"4192a5ba.60707c","type":"function","z":"eeca8943.a75718","name":"RS","func":"var local=context.get('data') || {};\n\nlocal.In1=msg.In1;\nlocal.In2=msg.In2;\n\nif (local.In1===undefined)//test exists\n{\n local.In1=false;\n}\n\nif (local.In2===undefined)//test exists\n{\n local.In2=false;\n}\n\n\nif (local.In2 == true) {\n result = false;\n} else if (local.In1 == true) {\n result = true;\n} else {\n result = false;\n}\ncontext.set('data',local);\nmsg = {topic : \"RS\", payload : result};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1150,"y":440,"wires":[["c64cac0e.761cb"]]},{"id":"b5eed4d1.ed7b28","type":"change","z":"eeca8943.a75718","name":"In1","rules":[{"t":"move","p":"payload","pt":"msg","to":"In1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":400,"wires":[["4192a5ba.60707c"]]},{"id":"20c1fbaa.5b1fa4","type":"change","z":"eeca8943.a75718","name":"In2","rules":[{"t":"move","p":"payload","pt":"msg","to":"In2","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":500,"wires":[["4192a5ba.60707c"]]},{"id":"de34e696.58d1f8","type":"change","z":"eeca8943.a75718","name":"In1","rules":[{"t":"move","p":"payload","pt":"msg","to":"In1","tot":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":380,"wires":[["1ee4050.64e7dfb"]]},{"id":"310651a0.b5617e","type":"change","z":"eeca8943.a75718","name":"In2","rules":[{"t":"move","p":"payload","pt":"msg","to":"In2","tot":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":420,"wires":[["1ee4050.64e7dfb"]]},{"id":"684d7bad.15cdb4","type":"change","z":"eeca8943.a75718","name":"In1","rules":[{"t":"set","p":"payload","pt":"msg","to":"In1","tot":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":480,"wires":[["9cadaae7.757b48"]]},{"id":"a91f8395.f0304","type":"change","z":"eeca8943.a75718","name":"In2","rules":[{"t":"set","p":"payload","pt":"msg","to":"In2","tot":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":520,"wires":[["9cadaae7.757b48"]]},{"id":"c64cac0e.761cb","type":"debug","z":"eeca8943.a75718","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1450,"y":440,"wires":[]},{"id":"7247de3a.b7449","type":"inject","z":"eeca8943.a75718","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"23","payloadType":"num","x":200,"y":340,"wires":[["de34e696.58d1f8","684d7bad.15cdb4"]]},{"id":"a580aa23.718368","type":"inject","z":"eeca8943.a75718","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":190,"y":420,"wires":[["310651a0.b5617e"]]},{"id":"fdfdfa54.77cd08","type":"inject","z":"eeca8943.a75718","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"18","payloadType":"num","x":220,"y":520,"wires":[["a91f8395.f0304"]]}]
I would greatly appreciate some help or material that can help me find a solution