# Struggle with boolean

**URL:** https://discourse.nodered.org/t/struggle-with-boolean/41581
**Category:** General
**Created:** [24 February 2021 19:04 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581 "2021-02-24T19:04:28Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)
#### Post date: [24 February 2021 19:04 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/1 "2021-02-24T19:04:28Z")

</div>

Hi, I am pretty new here and started working with NR a couple of weeks ago, so still a novice.

Currently struggeling with simple boolean logic. I just want to made a simple AND logic, where  
one input is a state-change and the other one a simple boolean\_switch. I could not bring this into work, does anybody have an idea on that? Thank you.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/992ebc2ca3e1af352d17ed09c5ac1e81504b3cda.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/b/0b53fe7a980562538ed30955a2389c214052872f.png)

```auto
[{"id":"e3081cd7.670e1","type":"BooleanLogicUltimate","z":"b04b838e.cc29c","name":"","filtertrue":"onlytrue","persist":true,"sInitializeWith":"false","triggertopic":"trigger","outputtriggeredby":"all","inputCount":2,"topic":"payload","x":450,"y":180,"wires":[["3ded3887.f8a1c8","58d92cf.b2ba7d4"],[],[]]}]

```

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [24 February 2021 19:30 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/2 "2021-02-24T19:30:52Z")

</div>

Hi Dave, welcome to the forum.  
Your flow is not importable, please [read this post](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) about how to share flows in the forum.  
You can then edit your post using the pencil icon, and make the necessary changes.

---

<div class="post-metadata">

### Author: ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)
#### Post date: [24 February 2021 21:12 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/3 "2021-02-24T21:12:05Z")

</div>

Hi Paul, thank you for letting me know about the correct format, hope it is now OK, Dave

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [24 February 2021 21:49 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/4 "2021-02-24T21:49:32Z")

</div>

Aah I see that you are using the `node-red-contrib-boolean-logic-ultimate` node.  
I can't help with that node as I've never used it, or have it in my palette.

I usually get around similar logic problems by using the more common node-RED nodes such as [node-red-contrib-simple-gate](https://flows.nodered.org/node/node-red-contrib-simple-gate) which has inbuilt persistence, and maybe an easier option.

It's hard to give you better advice without knowing what your project is, and how you want it to work.

---

<div class="post-metadata">

### Author: ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)
#### Post date: [25 February 2021 05:56 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/5 "2021-02-25T05:56:38Z")

</div>

Thank you,  
I really want to do just a simple AND function. Saying when a signal (given from a switch) changes from off to on AND a boolean switch is on then let the output = ON, otherwise = OFF.

Really not yet seen any functionable solution for that. Thank you

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [25 February 2021 06:47 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/6 "2021-02-25T06:47:21Z")

</div>

> Really not yet seen any functionable solution for that. Thank you

This is done regularly.  
I don't use home assistant, so have no idea what it produces or how your flow works.

Like the simple gate suggestion would work. But personally, I prefer (flow/global/node) contexts to keep track of states. ie. the HA node sets a flow variable instead of sending it off through the flow, and whenever you need to know the state, simply read the context value.

---

<div class="post-metadata">

### Author: ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)
#### Post date: [25 February 2021 06:56 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/7 "2021-02-25T06:56:55Z")

</div>

OK, but this not exactly what I look for. Simple example: switch on a light ONLY when 2 boolean inputs are on, if one them changes to off, then the light must switch to off too.  
sounds simple but I could not implement it correctly. Any help?

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [25 February 2021 07:12 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/8 "2021-02-25T07:12:17Z")

</div>

Try this example flow

```auto
[{"id":"5dfa49af.8e191","type":"inject","z":"c28fcd8e.4dd2b","name":"device1 - on","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":118,"y":360,"wires":[["78a3fe6f.1a52d8","56683060.4a9a1"]]},{"id":"56683060.4a9a1","type":"switch","z":"c28fcd8e.4dd2b","name":"device1_state ?","property":"device1_state","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":392,"y":480,"wires":[["a0c76c9f.589c3"],["264f939a.c8bdfc"]]},{"id":"a0c76c9f.589c3","type":"switch","z":"c28fcd8e.4dd2b","name":"device2_state ?","property":"device2_state","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":584,"y":456,"wires":[["afa86581.9147d"],["68a594bd.066c24"]]},{"id":"373c972b.ab751","type":"inject","z":"c28fcd8e.4dd2b","name":"device1 - off","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":118,"y":408,"wires":[["78a3fe6f.1a52d8","56683060.4a9a1"]]},{"id":"78a3fe6f.1a52d8","type":"change","z":"c28fcd8e.4dd2b","name":"","rules":[{"t":"set","p":"device1_state","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":412,"y":360,"wires":[[]]},{"id":"5a6e05d6.24d3ec","type":"inject","z":"c28fcd8e.4dd2b","name":"device2 - on","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":118,"y":552,"wires":[["d894a266.bfaa2","56683060.4a9a1"]]},{"id":"1efdeebb.f56f41","type":"inject","z":"c28fcd8e.4dd2b","name":"device2 - off","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":118,"y":624,"wires":[["d894a266.bfaa2","56683060.4a9a1"]]},{"id":"d894a266.bfaa2","type":"change","z":"c28fcd8e.4dd2b","name":"","rules":[{"t":"set","p":"device2_state","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":388,"y":624,"wires":[[]]},{"id":"ba713890.7006a","type":"debug","z":"c28fcd8e.4dd2b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":951,"y":432,"wires":[],"l":false},{"id":"afa86581.9147d","type":"change","z":"c28fcd8e.4dd2b","name":"dev1 and dev2 on","rules":[{"t":"set","p":"payload","pt":"msg","to":"Both on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":786,"y":432,"wires":[["ba713890.7006a"]]},{"id":"264f939a.c8bdfc","type":"change","z":"c28fcd8e.4dd2b","name":"dev1 off","rules":[{"t":"set","p":"payload","pt":"msg","to":"dev 1 is off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":588,"y":504,"wires":[["b8a8c38.dca9ac"]]},{"id":"c5bbe1e5.5a24a8","type":"debug","z":"c28fcd8e.4dd2b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":951,"y":480,"wires":[],"l":false},{"id":"68a594bd.066c24","type":"change","z":"c28fcd8e.4dd2b","name":"dev1 = on, dev2 = off","rules":[{"t":"set","p":"payload","pt":"msg","to":"dev1 = on, dev2 = off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":796,"y":480,"wires":[["c5bbe1e5.5a24a8"]]},{"id":"b8a8c38.dca9ac","type":"debug","z":"c28fcd8e.4dd2b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":711,"y":528,"wires":[],"l":false},{"id":"975c1230.cac36","type":"change","z":"c28fcd8e.4dd2b","name":"","rules":[{"t":"set","p":"device1_state","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":207,"y":168,"wires":[[]],"l":false},{"id":"28a5ecd9.8f921c","type":"change","z":"c28fcd8e.4dd2b","name":"","rules":[{"t":"set","p":"device2_state","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":207,"y":216,"wires":[[]],"l":false},{"id":"a2d5a4eb.e27a1","type":"inject","z":"c28fcd8e.4dd2b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":109,"y":192,"wires":[["975c1230.cac36","28a5ecd9.8f921c"]],"l":false},{"id":"7aa780d2.581bd8","type":"comment","z":"c28fcd8e.4dd2b","name":"intialize variables - they need to exist before flow works","info":"","x":270,"y":120,"wires":[]}]

```

It is a very literal flow.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [25 February 2021 07:16 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/9 "2021-02-25T07:16:52Z")

</div>

I have found node-red-contrib-bool-gate good for such applications.

---

<div class="post-metadata">

### Author: ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)
#### Post date: [25 February 2021 07:49 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/10 "2021-02-25T07:49:58Z")

</div>

_Admin Edit: surrounded your code with backticks as it was not importable_

I have that one too, but not able to implement such simple flow. Below example does work until first time both switches have been on, then the light is on even if only one input is on.

```auto
[
    {
        "id": "7a9e8cd2.3dbc64",
        "type": "tab",
        "label": "Flow 3",
        "disabled": false,
        "info": ""
    },
    {
        "id": "b2293f72.fdabd",
        "type": "debug",
        "z": "7a9e8cd2.3dbc64",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 470,
        "y": 180,
        "wires": []
    },
    {
        "id": "a1d982d3.3ad08",
        "type": "debug",
        "z": "7a9e8cd2.3dbc64",
        "name": "amb",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 430,
        "y": 340,
        "wires": []
    },
    {
        "id": "c97da7b5.50a9d8",
        "type": "server-state-changed",
        "z": "7a9e8cd2.3dbc64",
        "name": "",
        "server": "a11aa034.815b8",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "input_boolean.security",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "habool",
        "haltifstate": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "x": 190,
        "y": 220,
        "wires": [
            [
                "3df6af6.801745",
                "b2293f72.fdabd"
            ],
            []
        ]
    },
    {
        "id": "3e622d7.80817d2",
        "type": "server-state-changed",
        "z": "7a9e8cd2.3dbc64",
        "name": "",
        "server": "a11aa034.815b8",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "input_boolean.amblight",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "habool",
        "haltifstate": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "x": 190,
        "y": 280,
        "wires": [
            [
                "3df6af6.801745",
                "a1d982d3.3ad08"
            ],
            []
        ]
    },
    {
        "id": "286b8fc6.b8744",
        "type": "api-call-service",
        "z": "7a9e8cd2.3dbc64",
        "name": "",
        "server": "a3cbae53.1f436",
        "version": 1,
        "debugenabled": false,
        "service_domain": "switch",
        "service": "turn_on",
        "entityId": "switch.shelly1_reserve_3",
        "data": "",
        "dataType": "jsonata",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 790,
        "y": 200,
        "wires": [
            []
        ]
    },
    {
        "id": "517522f6.9fbf2c",
        "type": "api-call-service",
        "z": "7a9e8cd2.3dbc64",
        "name": "",
        "server": "a3cbae53.1f436",
        "version": 1,
        "debugenabled": false,
        "service_domain": "switch",
        "service": "turn_off",
        "entityId": "switch.shelly1_reserve_3",
        "data": "",
        "dataType": "jsonata",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 790,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "3df6af6.801745",
        "type": "BooleanLogic",
        "z": "7a9e8cd2.3dbc64",
        "name": "",
        "operation": "AND",
        "inputCount": "2",
        "topic": "result",
        "x": 480,
        "y": 240,
        "wires": [
            [
                "286b8fc6.b8744"
            ]
        ]
    },
    {
        "id": "a11aa034.815b8",
        "type": "server",
        "name": "RasPi2",
        "legacy": false,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true
    },
    {
        "id": "a3cbae53.1f436",
        "type": "server",
        "name": "Home Assistant",
        "addon": true
    }
]

```

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [25 February 2021 09:01 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/11 "2021-02-25T09:01:49Z")

</div>

> [@JJdave](#):
>
> I have that one too, but not able to implement such simple flow.

> [@JJdave](#):
>
> `"type": "BooleanLogic",`

That isn't node-red-contrib-bool-gate.

---

<div class="post-metadata">

### Author: ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)
#### Post date: [25 February 2021 09:20 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/12 "2021-02-25T09:20:04Z")

</div>

sorry, just changed but still no success - see below, thank you

```auto
[{"id":"1975b7b0.57e908","type":"and-gate","z":"3d71077c.496e98","name":"","rules":[{"t":"eq","v":"on","vt":"str","propertyType":"msg","property":"payload","topic":"input_boolean.security"},{"t":"eq","v":"on","vt":"str","propertyType":"msg","property":"payload","topic":"input_boolean.amblight"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":false,"x":520,"y":220,"wires":[["791518d2.0d00d8","dbf4ea16.ffa358"]]},{"id":"7265a0ad.4f9f5","type":"debug","z":"3d71077c.496e98","name":"secu","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":160,"wires":[]},{"id":"4387de51.ec71a","type":"debug","z":"3d71077c.496e98","name":"amb","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":340,"wires":[]},{"id":"192464.f66bcb9c","type":"server-state-changed","z":"3d71077c.496e98","name":"","server":"a11aa034.815b8","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.security","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":230,"y":200,"wires":[["7265a0ad.4f9f5","1975b7b0.57e908"],[]]},{"id":"11cf3ea5.91fb71","type":"server-state-changed","z":"3d71077c.496e98","name":"","server":"a11aa034.815b8","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.amblight","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":230,"y":260,"wires":[["4387de51.ec71a","1975b7b0.57e908"],[]]},{"id":"791518d2.0d00d8","type":"api-call-service","z":"3d71077c.496e98","name":"","server":"a11aa034.815b8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.shelly1_reserve_3","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":830,"y":180,"wires":[[]]},{"id":"fb999f26.8b80a","type":"api-call-service","z":"3d71077c.496e98","name":"","server":"a11aa034.815b8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.shelly1_reserve_3","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":830,"y":260,"wires":[[]]},{"id":"dbf4ea16.ffa358","type":"debug","z":"3d71077c.496e98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":690,"y":140,"wires":[]},{"id":"a11aa034.815b8","type":"server","name":"RasPi2","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

```

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [25 February 2021 09:23 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/13 "2021-02-25T09:23:42Z")

</div>

As per the posts above, please format your flow correctly when pasting it in the forum!

> [@Struggle with boolean](https://discourse.nodered.org/t/struggle-with-boolean/41581/2):
>
> Hi Dave, welcome to the forum. Your flow is not importable, please [read this post](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) about how to share flows in the forum. You can then edit your post using the pencil icon, and make the necessary changes.

---

<div class="post-metadata">

### Author: ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)
#### Post date: [25 February 2021 09:40 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/14 "2021-02-25T09:40:38Z")

</div>

thank you, changed, Dave

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [25 February 2021 09:43 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/15 "2021-02-25T09:43:14Z")

</div>

You have not configured the AND node with the appropriate data to tell it what to do. You have to tell it about both the inputs using two rules and tell it which topics to look for. [node-red-contrib-bool-gate (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-bool-gate)

---

<div class="post-metadata">

### Author: ![sfedo](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sfedo](https://discourse.nodered.org/u/sfedo)
#### Post date: [25 February 2021 09:50 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/16 "2021-02-25T09:50:31Z")

</div>

have you red the documentation for boolean ultimate on github?? they have an example there that is pretty much what you are asking for. Take a look at: [https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate](https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate)

---

<div class="post-metadata">

### Author: ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)
#### Post date: [25 February 2021 10:12 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/17 "2021-02-25T10:12:52Z")

</div>

yes, I did, but did not really work as I expcted.

---

<div class="post-metadata">

### Author: ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)
#### Post date: [25 February 2021 10:13 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/18 "2021-02-25T10:13:44Z")

</div>

Hi Colin,  
could you help me finding the right configuration for my application. Really not sure what I have to put into for topic. Thank you

Below flow does always trigger the output when the inputs are still "off"

```auto
[{"id":"1975b7b0.57e908","type":"and-gate","z":"3d71077c.496e98","name":"","rules":[{"t":"eq","v":"on","vt":"str","propertyType":"msg","property":"payload","topic":"input_boolean.security"},{"t":"eq","v":"on","vt":"str","propertyType":"msg","property":"payload","topic":"input_boolean.amblight"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":false,"x":520,"y":220,"wires":[["791518d2.0d00d8","dbf4ea16.ffa358"]]}]

```

---

<div class="post-metadata">

### Author: ![sfedo](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sfedo](https://discourse.nodered.org/u/sfedo)
#### Post date: [25 February 2021 10:16 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/19 "2021-02-25T10:16:22Z")

</div>

try this one and tell where are you struggeling

```auto
[{"id":"e3081cd7.670e1","type":"BooleanLogicUltimate","z":"73cba448.81c14c","name":"","filtertrue":"both","persist":true,"sInitializeWith":"false","triggertopic":"trigger","outputtriggeredby":"all","inputCount":2,"topic":"result","x":600,"y":3360,"wires":[["71ca6a67.86cdf4"],[],[]]},{"id":"da07fdb8.500f1","type":"inject","z":"73cba448.81c14c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button2","payload":"true","payloadType":"bool","x":290,"y":3300,"wires":[["e3081cd7.670e1"]]},{"id":"98b1fa98.0f2688","type":"inject","z":"73cba448.81c14c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button1","payload":"true","payloadType":"bool","x":290,"y":3440,"wires":[["e3081cd7.670e1"]]},{"id":"71ca6a67.86cdf4","type":"debug","z":"73cba448.81c14c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":3360,"wires":[]},{"id":"817c4961.bd8628","type":"inject","z":"73cba448.81c14c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button2","payload":"false","payloadType":"bool","x":290,"y":3340,"wires":[["e3081cd7.670e1"]]},{"id":"b24f6681.532498","type":"inject","z":"73cba448.81c14c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"button1","payload":"false","payloadType":"bool","x":290,"y":3480,"wires":[["e3081cd7.670e1"]]},{"id":"a05c68b8.b6a2f8","type":"comment","z":"73cba448.81c14c","name":"if 2 buttons are true, then payload: true, else payload: false","info":"","x":690,"y":3300,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)
#### Post date: [25 February 2021 10:32 UTC](https://discourse.nodered.org/t/struggle-with-boolean/41581/20 "2021-02-25T10:32:57Z")

</div>

after changing the output to "only true results" it works. But right now missing a false output, so  
getting the false state of the logic, any idea?

[Next page](https://discourse.nodered.org/t/struggle-with-boolean/41581.md?page=2)
