How to set an output that requires both switch and setpoint criteria?

Hi, I'm trying to control an I/O module to turn on/off some Heater relays based on some input temperatures and a set point. I've created a very basic Dashboard and some Node-RED logic to do this, and I am struggling to get the Heater output to require both a setpoint requirement and a switch to be on. I know that this could be done easily with an If statement, but I can't seem to get it to work. Any help would be greatly appreciated!

[{"id":"d59c70e9.a2416","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2b695eb3.2f03b2","type":"set-do-value","z":"d59c70e9.a2416","name":"T3 Heater Relay","write_ch":"0","write_ch_type":"write_do_1","x":740,"y":360,"wires":[["9950bc0e.6d425"]]},{"id":"71a698c0.f303a8","type":"set-do-value","z":"d59c70e9.a2416","name":"Fan Relay","write_ch":"2","write_ch_type":"write_do_1","x":730,"y":640,"wires":[[]]},{"id":"aac70c2a.51829","type":"ADAM-read","z":"d59c70e9.a2416","name":"","rate":"1000","host":"10.0.0.80","serialPortCfg":"","unit_id":1,"readDI":true,"readDO":false,"readAI":true,"readAO":true,"reconnecttimeout":"","mboutputStyle":"Multiple Outputs","Series":"mbtcp","advDevTypeTCP":"ADAM-6017","advDevTypeRTU":"ADAM-4015","advDevType":"ADAM-6017","outputs":8,"x":120,"y":260,"wires":[[],[],[],[],["c82b1905.573978"],["5d8f1d05.64d844"],["a8bb1b95.1f0978"],["a14406a9.3fb108"]]},{"id":"6ae35d37.94f0c4","type":"ui_numeric","z":"d59c70e9.a2416","name":"","label":"Enclosure Set Point","tooltip":"","group":"27fbd503.471f2a","order":4,"width":"5","height":"1","wrap":false,"passthru":false,"topic":"","format":"{{value}}","min":"0","max":"40","step":"2","x":330,"y":60,"wires":[["f657acc7.a60b1"]]},{"id":"d24103af.39722","type":"ui_switch","z":"d59c70e9.a2416","name":"","label":"Heater","tooltip":"","group":"27fbd503.471f2a","order":3,"width":"5","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":550,"y":580,"wires":[["f120373f.d1ee18"]]},{"id":"176de8d7.9e17e7","type":"ui_switch","z":"d59c70e9.a2416","name":"","label":"Fan","tooltip":"","group":"27fbd503.471f2a","order":2,"width":"5","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":550,"y":640,"wires":[["71a698c0.f303a8"]]},{"id":"f657acc7.a60b1","type":"change","z":"d59c70e9.a2416","name":"Set Point","rules":[{"t":"set","p":"setPoint","pt":"global","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Set Point","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":60,"wires":[["5d64787d.b727c8","5fb08e12.2ac9"]]},{"id":"c82b1905.573978","type":"change","z":"d59c70e9.a2416","name":"Interior T1","rules":[{"t":"set","p":"T1","pt":"global","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Interior T1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":180,"wires":[["794373e5.1bc21c"]]},{"id":"5d8f1d05.64d844","type":"change","z":"d59c70e9.a2416","name":"Interior T2","rules":[{"t":"set","p":"T2","pt":"global","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Interior T2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":220,"wires":[["38f32b3b.ba9514"]]},{"id":"a8bb1b95.1f0978","type":"change","z":"d59c70e9.a2416","name":"Exterior T3","rules":[{"t":"set","p":"T3","pt":"global","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Exterior T3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":260,"wires":[["95734680.01de78","94ea6bbd.e2cfd8"]]},{"id":"a14406a9.3fb108","type":"change","z":"d59c70e9.a2416","name":"Exterior T4","rules":[{"t":"set","p":"T4","pt":"global","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Exterior T4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":300,"wires":[["678daac2.037204","22a0e313.dd612c"]]},{"id":"794373e5.1bc21c","type":"ui_text","z":"d59c70e9.a2416","group":"27fbd503.471f2a","order":6,"width":"5","height":"1","name":"","label":"Interior T1","format":"{{msg.payload|number:2}} C","layout":"row-spread","x":570,"y":180,"wires":[]},{"id":"38f32b3b.ba9514","type":"ui_text","z":"d59c70e9.a2416","group":"27fbd503.471f2a","order":7,"width":"5","height":"1","name":"","label":"Interior T2","format":"{{msg.payload|number:2}}C","layout":"row-spread","x":570,"y":220,"wires":[]},{"id":"95734680.01de78","type":"ui_text","z":"d59c70e9.a2416","group":"27fbd503.471f2a","order":8,"width":"5","height":"1","name":"","label":"Exterior T3","format":"{{msg.payload|number:2}}C","layout":"row-spread","x":570,"y":260,"wires":[]},{"id":"678daac2.037204","type":"ui_text","z":"d59c70e9.a2416","group":"27fbd503.471f2a","order":9,"width":"5","height":"1","name":"","label":"Exterior T4","format":"{{msg.payload|number:2}}C","layout":"row-spread","x":570,"y":300,"wires":[]},{"id":"94ea6bbd.e2cfd8","type":"switch","z":"d59c70e9.a2416","name":"Set Point Decision","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"lowerBand","vt":"global"},{"t":"gte","v":"upperBand","vt":"global"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":380,"wires":[["f23da55c.424f58"],["7f5a830b.35794c"]]},{"id":"5d64787d.b727c8","type":"change","z":"d59c70e9.a2416","name":"Set Point Upper Band","rules":[{"t":"set","p":"upperBand","pt":"global","to":"$number($$.payload) + 2","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":40,"wires":[[]]},{"id":"5fb08e12.2ac9","type":"change","z":"d59c70e9.a2416","name":"Set Point Lower Band","rules":[{"t":"set","p":"lowerBand","pt":"global","to":"$number($$.payload) - 2","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":80,"wires":[[]]},{"id":"c7c8ad07.cedda","type":"inject","z":"d59c70e9.a2416","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"setPoint","payloadType":"global","x":140,"y":60,"wires":[["6ae35d37.94f0c4"]]},{"id":"56eeb522.3276bc","type":"set-do-value","z":"d59c70e9.a2416","name":"T4 Heater Relay","write_ch":"1","write_ch_type":"write_do_1","x":740,"y":440,"wires":[["98b7ef3e.e4567"]]},{"id":"22a0e313.dd612c","type":"switch","z":"d59c70e9.a2416","name":"Set Point Decision","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"lowerBand","vt":"global"},{"t":"gte","v":"upperBand","vt":"global"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":420,"wires":[["5adc9330.1ac7ac"],["ee30cc48.79ea3"]]},{"id":"f23da55c.424f58","type":"change","z":"d59c70e9.a2416","name":"On","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":340,"wires":[["2b695eb3.2f03b2"]]},{"id":"7f5a830b.35794c","type":"change","z":"d59c70e9.a2416","name":"Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":380,"wires":[["2b695eb3.2f03b2"]]},{"id":"ee30cc48.79ea3","type":"change","z":"d59c70e9.a2416","name":"Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":460,"wires":[["56eeb522.3276bc"]]},{"id":"5adc9330.1ac7ac","type":"change","z":"d59c70e9.a2416","name":"On","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":420,"wires":[["56eeb522.3276bc"]]},{"id":"cba528fb.349a88","type":"ui_text","z":"d59c70e9.a2416","group":"27fbd503.471f2a","order":9,"width":0,"height":0,"name":"","label":"T3 Heater","format":"{{msg.payload}}","layout":"row-spread","x":1120,"y":360,"wires":[]},{"id":"9950bc0e.6d425","type":"change","z":"d59c70e9.a2416","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"On","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":360,"wires":[["cba528fb.349a88"]]},{"id":"98b7ef3e.e4567","type":"change","z":"d59c70e9.a2416","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"On","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"Off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":440,"wires":[["d7803183.89fd4"]]},{"id":"d7803183.89fd4","type":"ui_text","z":"d59c70e9.a2416","group":"27fbd503.471f2a","order":9,"width":0,"height":0,"name":"","label":"T4 Heater","format":"{{msg.payload}}","layout":"row-spread","x":1120,"y":440,"wires":[]},{"id":"f120373f.d1ee18","type":"change","z":"d59c70e9.a2416","name":"","rules":[{"t":"set","p":"heater","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":580,"wires":[[]]},{"id":"e5b51612.54d648","type":"inject","z":"d59c70e9.a2416","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"heater","payloadType":"global","x":380,"y":580,"wires":[["d24103af.39722"]]},{"id":"27fbd503.471f2a","type":"ui_group","name":"Controls","tab":"20d4bd59.a21a22","order":1,"disp":true,"width":"5","collapse":false},{"id":"20d4bd59.a21a22","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":true}]

In order to be able to access both setpoint and the switch state at the same time you need to get them both into one message. You can do that using a Join node in key/value mode. See this article in the cookbook for an example of how to join messages into one object.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.