Troubles with AND gate - Output

Hi There,
I have some troubles to evaluate the output from the ANG gate as described in the manual:
Get following informatio from the debug:

result : msg : Object
object
topic: "result"
payload: "off"
bool: true
_msgid: "e203f5712eddba08"

--> Wanted to evaluate the "bool: true" value, but could not find how it works.
My simple test flow is as following:

[{"id":"4824aac14feb7c65","type":"and-gate","z":"475e1acb7ac09aff","name":"","rules":[{"t":"eq","v":"on","vt":"str","propertyType":"msg","property":"payload","topic":"input_boolean.autolight"},{"t":"eq","v":"off","vt":"str","propertyType":"msg","property":"payload","topic":"input_boolean.autolightstop"}],"outputTopic":"result","gateType":"and","emitOnlyIfTrue":false,"x":503.50001525878906,"y":214.6428680419922,"wires":[["91fb0f67c0db0b0a","0fbf6df5cce40f95"]]},{"id":"91fb0f67c0db0b0a","type":"debug","z":"475e1acb7ac09aff","name":"Out AND","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":704.750020980835,"y":213.3928680419922,"wires":[]},{"id":"d468d5aaa9b53f27","type":"trigger-state","z":"475e1acb7ac09aff","name":"","server":"a11aa034.815b8","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_boolean.autolight","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":171.5,"y":196.14286708831787,"wires":[["4824aac14feb7c65"],["4824aac14feb7c65"]]},{"id":"0a194e339c3615cd","type":"trigger-state","z":"475e1acb7ac09aff","name":"","server":"a11aa034.815b8","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_boolean.autolightstop","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":176.25000762939453,"y":238.39287567138672,"wires":[["4824aac14feb7c65"],["4824aac14feb7c65"]]},{"id":"0fbf6df5cce40f95","type":"switch","z":"475e1acb7ac09aff","name":"","property":"bool","propertyType":"flow","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":641.1785697937012,"y":265.25001430511475,"wires":[["fd9644abed13f92a"],[]]},{"id":"fd9644abed13f92a","type":"debug","z":"475e1acb7ac09aff","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":833.6929473876953,"y":260.3642635345459,"wires":[]},{"id":"a11aa034.815b8","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Any help? Tx - JJ

I see you have an (unknown to me) contrib node you are using. To help debugging your issue, you should add a debug node to both of those nodes. That way you could create an inject node with the data and use it for testing and allow someone else to replicate your issue and give you some help.

ADDITIONAL NOTE: Where are you setting flow.bool?

Tx for your swift help. flow.bool was still in for some tests, as I do not know how to get the output of the boolean node evaluated. I am also no t sticked to this AND gate I just want to performe a proper AND function, maybe you have another approach?

Below latest flow:

[{"id":"4824aac14feb7c65","type":"and-gate","z":"475e1acb7ac09aff","name":"","rules":[{"t":"eq","v":"on","vt":"str","propertyType":"msg","property":"payload","topic":"input_boolean.autolight"},{"t":"eq","v":"off","vt":"str","propertyType":"msg","property":"payload","topic":"input_boolean.autolightstop"}],"outputTopic":"result","gateType":"and","emitOnlyIfTrue":false,"x":503.50001525878906,"y":214.6428680419922,"wires":[["91fb0f67c0db0b0a","0fbf6df5cce40f95"]]},{"id":"91fb0f67c0db0b0a","type":"debug","z":"475e1acb7ac09aff","name":"Out AND","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":704.750020980835,"y":213.3928680419922,"wires":[]},{"id":"d468d5aaa9b53f27","type":"trigger-state","z":"475e1acb7ac09aff","name":"","server":"a11aa034.815b8","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_boolean.autolight","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":171.5,"y":196.14286708831787,"wires":[["4824aac14feb7c65"],["4824aac14feb7c65"]]},{"id":"0a194e339c3615cd","type":"trigger-state","z":"475e1acb7ac09aff","name":"","server":"a11aa034.815b8","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_boolean.autolightstop","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":176.25000762939453,"y":238.39287567138672,"wires":[["4824aac14feb7c65"],["4824aac14feb7c65"]]},{"id":"0fbf6df5cce40f95","type":"switch","z":"475e1acb7ac09aff","name":"","property":"object.bool","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":641.1785697937012,"y":265.25001430511475,"wires":[["fd9644abed13f92a"],["0e14ebeb013c591e"]]},{"id":"fd9644abed13f92a","type":"debug","z":"475e1acb7ac09aff","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":833.6929473876953,"y":260.3642635345459,"wires":[]},{"id":"0e14ebeb013c591e","type":"debug","z":"475e1acb7ac09aff","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":834.5999755859375,"y":318,"wires":[]},{"id":"a11aa034.815b8","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Tx - JJ

Your switch node is checking that msg.object.bool is equal to string "true", should that be "is true" rather than equal to "=="?
[edit] and should msg.object.bool be msg.bool ?

Once again it would be easier to see the actual data going into the AND then trying to guess.

So, I made it with some switches at the input, fo easlier testing.
My problem is still, how to evaluate the output of the AND gate, such as:

payload : msg : Object
object
topic: "payload"
payload: true
bool: true
_msgid: "7fa023cd65549d14"

Flow is as following:

[{"id":"94e9d37f57440912","type":"inject","z":"475e1acb7ac09aff","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button1","payload":"true","payloadType":"bool","x":168,"y":644,"wires":[["614e8af0131ccf6d"]]},{"id":"75525d14f7c63483","type":"inject","z":"475e1acb7ac09aff","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button1","payload":"false","payloadType":"bool","x":168,"y":684,"wires":[["614e8af0131ccf6d"]]},{"id":"afe2503b500b9e3b","type":"inject","z":"475e1acb7ac09aff","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button2","payload":"true","payloadType":"bool","x":165,"y":742.0000123977661,"wires":[["614e8af0131ccf6d"]]},{"id":"7fce47c88ada20d1","type":"inject","z":"475e1acb7ac09aff","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button2","payload":"false","payloadType":"bool","x":168,"y":804,"wires":[["614e8af0131ccf6d"]]},{"id":"614e8af0131ccf6d","type":"and-gate","z":"475e1acb7ac09aff","name":"","rules":[{"t":"true","propertyType":"msg","property":"payload","topic":"button1"},{"t":"true","propertyType":"msg","property":"payload","topic":"button2"}],"outputTopic":"payload","gateType":"and","emitOnlyIfTrue":false,"x":456,"y":714,"wires":[["2ccac5187002a55b","5c3acec9800c0258"]]},{"id":"2ccac5187002a55b","type":"debug","z":"475e1acb7ac09aff","name":"Out AND SW","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":667.2500057220459,"y":712.75,"wires":[]},{"id":"5c3acec9800c0258","type":"switch","z":"475e1acb7ac09aff","name":"","property":"bool","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":593.6785545349121,"y":764.6071462631226,"wires":[["21e84cea14b3e014"],["fd5554ef17d36866"]]},{"id":"21e84cea14b3e014","type":"debug","z":"475e1acb7ac09aff","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":786.1929321289062,"y":759.7213954925537,"wires":[]},{"id":"fd5554ef17d36866","type":"debug","z":"475e1acb7ac09aff","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":787.0999603271484,"y":817.3571319580078,"wires":[]}]

Tx - JJ

One issue maybe that this node hasn't been updated in 4+ years. You could try node-red-contrib-boolean-logic-ultimate which is a little newer.

With that msg output from the And gate it should work.
You could just join the incoming msg.payload's and use a JSONata expression in the switch node.
e.g.

[{"id":"94e9d37f57440912","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button1","payload":"true","payloadType":"bool","x":180,"y":1500,"wires":[["d0974b4.75f67b8"]]},{"id":"d0974b4.75f67b8","type":"join","z":"b779de97.b1b46","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":380,"y":1620,"wires":[["5c3acec9800c0258"]]},{"id":"75525d14f7c63483","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button1","payload":"false","payloadType":"bool","x":180,"y":1540,"wires":[["d0974b4.75f67b8"]]},{"id":"afe2503b500b9e3b","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button2","payload":"true","payloadType":"bool","x":177,"y":1598.000012397766,"wires":[["d0974b4.75f67b8"]]},{"id":"7fce47c88ada20d1","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button2","payload":"false","payloadType":"bool","x":180,"y":1660,"wires":[["d0974b4.75f67b8"]]},{"id":"5c3acec9800c0258","type":"switch","z":"b779de97.b1b46","name":"","property":"payload.button1 =  true and payload.button2 = true","propertyType":"jsonata","rules":[{"t":"true"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":600,"y":1600,"wires":[["21e84cea14b3e014"],["fd5554ef17d36866"]]},{"id":"21e84cea14b3e014","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":798.1929321289062,"y":1615.7213954925537,"wires":[]},{"id":"fd5554ef17d36866","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":799.0999603271484,"y":1673.3571319580078,"wires":[]}]

TX - that helped to see how to evaluate "bool: True" - JJ

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