Using an And gate (node-red-contrib-bool-gate) not working

Hi

First off, I'm no programmer.. at all..
So I've been googling, like most have.. aLOT.

I'm creating a dimmer for my philips hue lights (from an IDEC PLC industrial computer) and i'm aaaalmost there. If my And gate would work I wouldn't be posting this.

[{"id":"131a9b2d.4b6975","type":"modbus-read","z":"f335cfc5.09caa","name":"Switches","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"Input","adr":"0019","quantity":"8","rate":"250","rateUnit":"ms","delayOnStart":false,"startDelayTime":"","server":"c5860ee0.e13e9","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":140,"y":360,"wires":[["11d64092.fb22df"],[]]},{"id":"11d64092.fb22df","type":"function","z":"f335cfc5.09caa","name":"light switches","func":"var z = [0,0,0,0,0,0,0,0];\nvar msg_o = [msg,msg,msg,msg,msg,msg,msg,msg];\nfor (i = 0;i < 8; i++){\n\tz[i] = msg.payload[i];\n\tif (z[i] === true){\n\t    msg_o[i] = {payload: true};\n\t} else {\n\t    msg_o[i] = {payload: false};\n    }\n}\nreturn msg_o;","outputs":8,"noerr":0,"initialize":"","finalize":"","x":310,"y":360,"wires":[["9aefc896.f7c6b8"],[],[],[],[],[],[],[]]},{"id":"53524e13.49ff6","type":"modbus-read","z":"f335cfc5.09caa","name":"output coil","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"Coil","adr":"0080","quantity":"8","rate":"250","rateUnit":"ms","delayOnStart":false,"startDelayTime":"","server":"c5860ee0.e13e9","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":120,"y":680,"wires":[["a5ca47ce.f705e8"],[]]},{"id":"a5ca47ce.f705e8","type":"function","z":"f335cfc5.09caa","name":"Outputs","func":"var z = [0,0,0,0,0,0,0,0];\nvar msg_o = [msg,msg,msg,msg,msg,msg,msg,msg];\nfor (i = 0;i < 8; i++){\n\tz[i] = msg.payload[i];\n\tif (z[i] === true){\n\t    msg_o[i] = {payload: true};\n\t} else {\n\t    msg_o[i] = {payload: false};\n    }\n}\nreturn msg_o;","outputs":8,"noerr":0,"initialize":"","finalize":"","x":360,"y":660,"wires":[[],["6f4330e9.e1cca","f6ba2aa6.eecb98"],[],[],[],[],[],[]]},{"id":"9d5414d7.fb78b8","type":"hue-light","z":"f335cfc5.09caa","name":"tölvuherbergi","bridge":"f04cb683.d68c68","lightid":"1","colornamer":true,"skipevents":false,"universalevents":false,"x":370,"y":160,"wires":[["d886dfc0.589a8"]]},{"id":"d886dfc0.589a8","type":"function","z":"f335cfc5.09caa","name":"update variable","func":"flow.set('Lamp1_on',msg.payload.on);\nflow.set('Lamp1_brightness',msg.payload.brightness);\nflow.set('Lamp1_colorTemp',msg.payload.colorTemp);\nflow.set('Lamp1_brightnessLevel',msg.payload.brightnessLevel);\nflow.set('Lamp1_reachable',msg.payload.reachable);\n\n\nvar on = flow.get('Lamp1_on');\nvar bri = flow.get('Lamp1_brightness');\nvar colorTemp = flow.get('Lamp1_colorTemp');\nvar brilevel = flow.get('Lamp1_brightnessLevel');\nvar reach = flow.get('Lamp1_reaclable');\n\n\nmsg.payload = bri;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":160,"wires":[[]]},{"id":"b891aa9c.1360c8","type":"hue-light","z":"f335cfc5.09caa","name":"tölvuherbergi","bridge":"f04cb683.d68c68","lightid":"1","colornamer":true,"skipevents":false,"universalevents":false,"x":910,"y":600,"wires":[[]]},{"id":"b8efae1.b9ab25","type":"function","z":"f335cfc5.09caa","name":"Dimming VAR","func":"var x = flow.get('Lamp1_brightness')\n\nif(x <= 70) {\n\tmsg.payload = x;\n\treturn[msg,null];\n}\nif(x > 70) {\n\tmsg.payload = x;\n\treturn[null.msg];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":960,"y":320,"wires":[["66216aa4.78f714"],["7dcad04f.d9558"]]},{"id":"66216aa4.78f714","type":"function","z":"f335cfc5.09caa","name":"Decrement dimming","func":"var on = flow.get('Lamp1_on');\nvar bri = flow.get('Lamp1_brightness');\nvar colorTemp = flow.get('Lamp1_colorTemp');\nvar brilevel = flow.get('Lamp1_brightnessLevel');\nvar reach = flow.get('Lamp1_reaclable');\n\nvar brightness =  msg.payload;\n\nif(brightness > 0){\n    brightness = brightness + 5;    \n\t}\n\t\nif(brightness >= 100){\n    brightness = 95;\n    flow.set('Lamp1_brightness',brightness);\n//    flow.set('press', false);\n    }\n\nmsg.payload = {\n        \"on\": true,\n        \"brightness\": brightness,\n        \"colorTemp\": colorTemp,\n    };\n\tmsg.feedback = brightness;\n\tflow.set('Lamp1_brightness', brightness);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1200,"y":280,"wires":[["ae9e0446.dab278"]]},{"id":"7dcad04f.d9558","type":"function","z":"f335cfc5.09caa","name":"Incrament dimming","func":"var on = flow.get('Lamp1_on');\nvar bri = flow.get('Lamp1_brightness');\nvar colorTemp = flow.get('Lamp1_colorTemp');\nvar brilevel = flow.get('Lamp1_brightnessLevel');\nvar reach = flow.get('Lamp1_reaclable');\n\nvar brightness =  msg.payload;\n\nif(brightness <= 100){\n    brightness = brightness - 5;    \n\t}\n\t\nif(brightness <= 0){\n    brightness = 1;\n    flow.set('Lamp1_brightness',brightness);\n//    flow.set('press', false);\n    }\n\nmsg.payload = {\n        \"on\": true,\n        \"bri\": brightness,\n        \"colorTemp\": colorTemp,\n    };\n\tmsg.feedback = brightness;\n\tflow.set('Lamp1_brightness', brightness);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1210,"y":360,"wires":[["ae9e0446.dab278"]]},{"id":"6f4330e9.e1cca","type":"trigger","z":"f335cfc5.09caa","name":"Single false command","op1":"true","op2":"0","op1type":"bool","op2type":"str","duration":"0","extend":false,"overrideDelay":false,"units":"ms","reset":"false","bytopic":"all","topic":"topic","outputs":1,"x":630,"y":640,"wires":[["b891aa9c.1360c8"]]},{"id":"f6ba2aa6.eecb98","type":"trigger","z":"f335cfc5.09caa","name":"Single true command","op1":"false","op2":"0","op1type":"bool","op2type":"str","duration":"0","extend":false,"overrideDelay":false,"units":"ms","reset":"true","bytopic":"all","topic":"topic","outputs":1,"x":640,"y":600,"wires":[["b891aa9c.1360c8"]]},{"id":"c5d1b13d.9856d","type":"modbus-read","z":"f335cfc5.09caa","name":"dimmer coil","topic":"output","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"Coil","adr":"0082","quantity":"1","rate":"200","rateUnit":"ms","delayOnStart":false,"startDelayTime":"","server":"c5860ee0.e13e9","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":130,"y":480,"wires":[["9d75e55c.9f5898"],[]]},{"id":"9d75e55c.9f5898","type":"function","z":"f335cfc5.09caa","name":"Outputs","func":"var z = [0,0,0,0,0,0,0,0];\nvar msg_o = [msg,msg,msg,msg,msg,msg,msg,msg];\nfor (i = 0;i < 8; i++){\n\tz[i] = msg.payload[i];\n\tif (z[i] === true){\n\t    msg_o[i] = {payload: true};\n\t} else {\n\t    msg_o[i] = {payload: false};\n    }\n}\nreturn msg_o;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":480,"wires":[["9aefc896.f7c6b8"]]},{"id":"63172be.23e3dd4","type":"debug","z":"f335cfc5.09caa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1370,"y":540,"wires":[]},{"id":"ae9e0446.dab278","type":"hue-light","z":"f335cfc5.09caa","name":"tölvuherbergi","bridge":"f04cb683.d68c68","lightid":"1","colornamer":true,"skipevents":false,"universalevents":false,"x":1510,"y":340,"wires":[[]]},{"id":"9aefc896.f7c6b8","type":"and-gate","z":"f335cfc5.09caa","name":"","rules":[{"t":"true","propertyType":"msg","property":"payload","topic":"boolean"},{"t":"true","propertyType":"msg","property":"payload","topic":"boolean"}],"outputTopic":"boolean","gateType":"and","emitOnlyIfTrue":true,"x":620,"y":360,"wires":[["b8efae1.b9ab25"]]},{"id":"45c0d6a1.f87c48","type":"comment","z":"f335cfc5.09caa","name":"This is used so a single command goes to light","info":"the PLC outputs every 1-5 ms, so this \"output\" coil was created to output only once for the light to turn off / on. Hence, if a routine would be created in Philips Hue app it would work (the PLC wouldn't constantly output FALSE FALSE FALSE FALSE and disable the routing)","x":750,"y":560,"wires":[]},{"id":"e5b05b68.c33058","type":"comment","z":"f335cfc5.09caa","name":"Get status from light 1","info":"","x":510,"y":100,"wires":[]},{"id":"47dbd823.c6ea08","type":"comment","z":"f335cfc5.09caa","name":"All light switches are push switches","info":"So when you release it instantly reports false and would disable output coil, however, I have a rule inside the PLC to disable \"false\" after 1 sec and so the dimming coil activates instead, hense both switch and dimmer coil are \"true.true\"","x":290,"y":280,"wires":[]},{"id":"524736c.9bb74c8","type":"comment","z":"f335cfc5.09caa","name":"To my best knowledge, this works ? (I think)","info":"","x":1260,"y":220,"wires":[]},{"id":"c5860ee0.e13e9","type":"modbus-client","name":"idec","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.10.50","tcpPort":"503","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"f04cb683.d68c68","type":"hue-bridge","name":"Philips hue","bridge":"192.168.10.95","key":"GBGRALITdxKeC45W5hf9wfueIfyvfmCeI0tmvmNS","interval":"3000","disableupdates":false}]

If anyone has any great suggestions, I'm all eyes/ears :smiley:

Welcome to the forum @olafurfo.

For the future for a question like this it isn't necessary to post the full flow, since it is just one gate that is not performing correctly then all you needed to do was to feed the two inputs into a Debug node and show us what you see (that will tell us what is going into the AND node) show us how the AND node is configured, show use what comes out of the node and what you think should come out of it.

You have configured the AND node with two rules, but you say the both have a topic of "boolean", which I think is unlikely. The two rules have to specify different topics for the incoming messages as that is how it tells which is which.

As a beginner with node-red I think it would be worth your while to spend an hour watching the Node Red Essentials videos that are linked from the node red docs. Also read the docs page Working with Messages. Then I think that my answer above my make more sense to you.