Hi guys, I' am an old automation engineer, but new with Node Red (which is an awesome tool btw.)
I am stuck at one point, so I take two temperatures of my sensors, compare them with an setpoint temp, and if one of those comparisons is true start heat pump which is controlled with Siemens S7 LOGO!, problem is, when state is changed from true to false, the or logic does not do the job and heat pump is always on.
So my question is, what am I doing wrong, and can someone help me to fix my flow.
I am running Home Automation on RAPI 3b+ and latest Node Red, and my code is down below.
Thank you very much.
[{"id":"97b34efde9c39373","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"8e7345938b206492","type":"s7 in","z":"97b34efde9c39373","endpoint":"c389e1d7ecaa6e32","mode":"single","variable":"RELAY_0","diff":true,"name":"","x":1840,"y":380,"wires":[["200bca8328f0b58c"]]},{"id":"200bca8328f0b58c","type":"debug","z":"97b34efde9c39373","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1990,"y":380,"wires":[]},{"id":"72d690b70587cc44","type":"inject","z":"97b34efde9c39373","name":"inject heater_id_living","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"099950821892","payloadType":"str","x":120,"y":260,"wires":[["de04a8c0c2430bb2"]]},{"id":"de04a8c0c2430bb2","type":"fritz-thermostat","z":"97b34efde9c39373","connection":"c2e6322e.33404","name":"Living","action":"getDevice","x":310,"y":260,"wires":[["aca319070f62a09c","aad7ac76f471e74f","45ea11ecb6e599dc"]]},{"id":"aca319070f62a09c","type":"change","z":"97b34efde9c39373","name":"is_temperature","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature.celsius","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":200,"wires":[["c3fdda121228a26f"]]},{"id":"c3fdda121228a26f","type":"function","z":"97b34efde9c39373","name":"convert_t_to_celsius","func":"msg.topic='Actual Temp';\nmsg.payload=msg.payload/10;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":740,"y":200,"wires":[["fd11bb69297f5a29","ed1c284429eac662"]]},{"id":"aad7ac76f471e74f","type":"change","z":"97b34efde9c39373","name":"comfort_temperature","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.hkr.komfort","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":320,"wires":[["7748dfaee9f2117c"]]},{"id":"7748dfaee9f2117c","type":"function","z":"97b34efde9c39373","name":"convert_t_to_celsius","func":"msg.topic='SetPoint Temp';\nmsg.payload=msg.payload*0.5;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":320,"wires":[["47e60a682a2fe46d","ed1c284429eac662"]]},{"id":"45ea11ecb6e599dc","type":"debug","z":"97b34efde9c39373","name":"Device_info","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":140,"wires":[]},{"id":"47e60a682a2fe46d","type":"debug","z":"97b34efde9c39373","name":"Comfort_temperatura_Living","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1060,"y":320,"wires":[]},{"id":"fd11bb69297f5a29","type":"debug","z":"97b34efde9c39373","name":"Real Temp Living room","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1020,"y":200,"wires":[]},{"id":"b98d8ffb67ea0fa0","type":"s7 out","z":"97b34efde9c39373","endpoint":"c389e1d7ecaa6e32","variable":"RELAY_0","name":"RELAY","x":1680,"y":380,"wires":[]},{"id":"ed1c284429eac662","type":"function","z":"97b34efde9c39373","name":"Compare ACC and SP","func":"context.node = context.node || 0;\ncontext.node1 = context.node1 || 0;\n\nif(msg.topic == 'Actual Temp'){\n\tcontext.node = msg.payload;\n}else if (msg.topic == 'SetPoint Temp'){\n\tcontext.node1 = msg.payload;\n}\nif (context.node < context.node1){\n\treturn { topic: 'Current temp is Less than SP', payload: 'Start Boiler'}\n}else{\n\treturn { topic: 'Current temp is Higher than SP', payload: 'Stop Boiler'}\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":260,"wires":[["219fe1fe67733ef5"]]},{"id":"3f50cb93bbe8a1ef","type":"debug","z":"97b34efde9c39373","name":"Status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1450,"y":200,"wires":[]},{"id":"219fe1fe67733ef5","type":"change","z":"97b34efde9c39373","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"Start Boiler","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"Stop Boiler","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1260,"y":260,"wires":[["3f50cb93bbe8a1ef","48e4d748115f190f"]]},{"id":"f08decc9892e2c2c","type":"inject","z":"97b34efde9c39373","name":"inject heater_id_dining","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"099950818803","payloadType":"str","x":130,"y":500,"wires":[["4ea197cf60ede151"]]},{"id":"4ea197cf60ede151","type":"fritz-thermostat","z":"97b34efde9c39373","connection":"c2e6322e.33404","name":"Dining","action":"getDevice","x":310,"y":500,"wires":[["ded944ebf002b3d1","c50ae13f4d296a60","c2461bf793a0af97"]]},{"id":"ded944ebf002b3d1","type":"change","z":"97b34efde9c39373","name":"is_temperature","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature.celsius","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":440,"wires":[["7b7185bc189dfdd8"]]},{"id":"7b7185bc189dfdd8","type":"function","z":"97b34efde9c39373","name":"convert_t_to_celsius","func":"msg.topic='Actual Temp';\nmsg.payload=msg.payload/10;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":740,"y":440,"wires":[["047ff7e3af7d2669","e346efcbc8ed4d22"]]},{"id":"c50ae13f4d296a60","type":"change","z":"97b34efde9c39373","name":"comfort_temperature","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.hkr.komfort","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":540,"wires":[["a84fd06e228dcbc2"]]},{"id":"a84fd06e228dcbc2","type":"function","z":"97b34efde9c39373","name":"convert_t_to_celsius","func":"msg.topic='SetPoint Temp';\nmsg.payload=msg.payload*0.5;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":540,"wires":[["0e68341f6cbc5734","e346efcbc8ed4d22"]]},{"id":"c2461bf793a0af97","type":"debug","z":"97b34efde9c39373","name":"Device_info","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":380,"wires":[]},{"id":"0e68341f6cbc5734","type":"debug","z":"97b34efde9c39373","name":"Comfort_Temp_Dining","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1020,"y":540,"wires":[]},{"id":"047ff7e3af7d2669","type":"debug","z":"97b34efde9c39373","name":"Real Temp Dining Room","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1050,"y":440,"wires":[]},{"id":"e346efcbc8ed4d22","type":"function","z":"97b34efde9c39373","name":"Compare ACC and SP","func":"context.node = context.node || 0;\ncontext.node1 = context.node1 || 0;\n\nif(msg.topic == 'Actual Temp'){\n\tcontext.node = msg.payload;\n}else if (msg.topic == 'SetPoint Temp'){\n\tcontext.node1 = msg.payload;\n}\nif (context.node < context.node1){\n\treturn { topic: 'Current temp is Less than SP', payload: 'Start Boiler'}\n\t//msg.payload = 'Start Boiler';\n}else{\n\treturn { topic: 'Current temp is Higher than SP', payload: 'Stop Boiler'}\n\t//msg.payload = 'Stop Boiler';\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":480,"wires":[["90f7f3016e47dc35"]]},{"id":"e41acc6ced0d69ba","type":"debug","z":"97b34efde9c39373","name":"Status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1450,"y":540,"wires":[]},{"id":"90f7f3016e47dc35","type":"change","z":"97b34efde9c39373","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"Start Boiler","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"Stop Boiler","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1260,"y":480,"wires":[["e41acc6ced0d69ba","48e4d748115f190f"]]},{"id":"48e4d748115f190f","type":"BooleanLogicUltimate","z":"97b34efde9c39373","name":"","filtertrue":"both","persist":false,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"2","topic":"result","restrictinputevaluation":false,"x":1500,"y":380,"wires":[[],["b98d8ffb67ea0fa0"],[]]},{"id":"a44982d0621f043a","type":"inject","z":"97b34efde9c39373","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":1530,"y":320,"wires":[["b98d8ffb67ea0fa0"]]},{"id":"0b6526ab2f27357f","type":"inject","z":"97b34efde9c39373","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":1530,"y":440,"wires":[["b98d8ffb67ea0fa0"]]},{"id":"c389e1d7ecaa6e32","type":"s7 endpoint","transport":"iso-on-tcp","address":"192.168.178.249","port":"102","rack":"0","slot":"2","localtsaphi":"02","localtsaplo":"00","remotetsaphi":"02","remotetsaplo":"00","connmode":"tsap","adapter":"","busaddr":"2","cycletime":"500","timeout":"1500","name":"LOGO!","vartable":[{"addr":"Q0.0","name":"RELAY_0"},{"addr":"Q0.1","name":"RELAY_1"},{"addr":"Q0.2","name":"RELAY_2"},{"addr":"I0.0","name":"INPUT_1"}]},{"id":"c2e6322e.33404","type":"fritz-api","name":"fritzBox","host":"http://fritz.box","strictSSL":true}]