Help with a flow - Node Red - understanding boolean and ultimate boolean node

Having some trouble with a lock flow. I think I'm just not wrapping my head around this right. I lay it out and tear it apart again. I'm getting nowhere.

I have a lock (obviously you knew that) on an interior foyer door to the garage that I want to lock only if the garage lock is locked and the overhead door is closed AND the foyer door is closed. (Looks ackward hanging wide open with the deadbolt hanging out of it). But I also want it to be cancelable and the kicker is that I'll go to leave get in my car, open the garage door, pull out and close it, so it's not the only thing that would be triggering it. So with all the variables, it's killing me to get this right. I don't even have a flow to paste right now, but I'll work on one and addit in a bit. Any help is much appreciated.

Not sure about the kicker, but the rest with a ultimate Boolean block should be do able

1 Like

can you give me a bit of guidance? I'm terrible with booleans

Here is the example I created, First column is all of your input devices. Second column is your checks for your desired state switch, what you want the state for the device to be in to lock get sent to the true, else false. then the payload gets sent to the true or false accordingly.

The magical boolean block checks that all 4 were last seen in the true state (that is the top output) and then sends a true or false out of that output. if true , we lock, else we unlock.

2 Likes

the easiest way to think of the boolean block is the top output is are all of my inputs conditions true, the second is are any of my inputs true, the third is are all my inputs different.

1 Like

I need to take some time to understand this.

2 Likes

I may be showing my age here but I would make a truth table for this type of problem. Because until I get the logic straight in my head its useless to start coding (either textural or graphical).

John

2 Likes

You also might look here for help converting the truth table to some logical circuit. I know its old old school but it works.

1 Like

For clarification: Do you want the foyer door to lock every time those conditions are met (regardless of which occurs last), or would the foyer door be locked by some other trigger, and you only want the command to work if all the conditions are met? The example that @napalmcsr posted will basically accomplish the first option.

If you wanted the second option, you could do it similarly, but instead of toggle the lock at the end of the sequence, you could toggle a variable, which you can then check in another sequence.

ps. @napalmcsr, perhaps you could also post the exported json of your flow, as that can make it easier to analyze and learn from.

I thought about exporting, but since I have none of the devices and created it for an examolr, I wasn't sure about the amount of confusion that might cause. I can do it again if April wants that.

Yes I want the lock to lock regardless of the order.

I would love that.

Here you go

[{"id":"1f36ecdd.e941e3","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"b92554d8.177de8","type":"switch","z":"1f36ecdd.e941e3","name":"is Locked","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"Locked","vt":"str"},{"t":"neq","v":"Locked","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":140,"wires":[["35b46728.1963a8"],["ee7201e7.dbb8e"]]},{"id":"35b46728.1963a8","type":"change","z":"1f36ecdd.e941e3","name":"set True","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":180,"wires":[["a878ebdf.97ce08"]]},{"id":"585889aa.3b9fa8","type":"hubitat device","z":"1f36ecdd.e941e3","name":"Garage Lock","server":"f17566a9.c052b8","deviceId":"","attribute":"","sendEvent":true,"x":160,"y":140,"wires":[["b92554d8.177de8"]]},{"id":"1f8062e5.b9f4ad","type":"hubitat command","z":"1f36ecdd.e941e3","name":"Unlock Foyer Lock","server":"f17566a9.c052b8","deviceId":"","command":"","commandArgs":"","x":1330,"y":400,"wires":[[]]},{"id":"a878ebdf.97ce08","type":"BooleanLogicUltimate","z":"1f36ecdd.e941e3","name":"","filtertrue":"both","persist":true,"sInitializeWith":"false","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"4","topic":"result","x":820,"y":240,"wires":[["d1146cc7.5f41c"],[],[]]},{"id":"38ccad1f.303332","type":"hubitat device","z":"1f36ecdd.e941e3","name":"Overhead Door","server":"f17566a9.c052b8","deviceId":"","attribute":"","sendEvent":true,"x":160,"y":200,"wires":[["fddb93b0.4cf1b"]]},{"id":"ed43e2fc.0294f","type":"hubitat device","z":"1f36ecdd.e941e3","name":"Front Door","server":"f17566a9.c052b8","deviceId":"","attribute":"","sendEvent":true,"x":150,"y":260,"wires":[["fddb93b0.4cf1b"]]},{"id":"9083cc8a.894f5","type":"hubitat device","z":"1f36ecdd.e941e3","name":"Override switch","server":"f17566a9.c052b8","deviceId":"","attribute":"","sendEvent":true,"x":160,"y":320,"wires":[["ce5bbbbf.cad058"]]},{"id":"aa8d41ae.f014f","type":"hubitat device","z":"1f36ecdd.e941e3","name":"Foyer Lock","server":"f17566a9.c052b8","deviceId":"","attribute":"","sendEvent":false,"x":1130,"y":240,"wires":[["5adbe11b.e0516"]]},{"id":"4d5bc2ef.5d49fc","type":"hubitat device","z":"1f36ecdd.e941e3","name":"Foyer Lock","server":"f17566a9.c052b8","deviceId":"","attribute":"","sendEvent":false,"x":1090,"y":400,"wires":[["e857ffbb.5b92b"]]},{"id":"68a5251f.7f061c","type":"hubitat command","z":"1f36ecdd.e941e3","name":"Lock Foyer Lock","server":"f17566a9.c052b8","deviceId":"","command":"","commandArgs":"","x":1320,"y":240,"wires":[[]]},{"id":"fddb93b0.4cf1b","type":"switch","z":"1f36ecdd.e941e3","name":"is Closed","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"closed","vt":"str"},{"t":"neq","v":"closed","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":240,"wires":[["35b46728.1963a8"],["ee7201e7.dbb8e"]]},{"id":"ce5bbbbf.cad058","type":"switch","z":"1f36ecdd.e941e3","name":"is On","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"neq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":320,"wires":[["35b46728.1963a8"],["ee7201e7.dbb8e"]]},{"id":"ee7201e7.dbb8e","type":"change","z":"1f36ecdd.e941e3","name":"set False","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":260,"wires":[["a878ebdf.97ce08"]]},{"id":"5adbe11b.e0516","type":"switch","z":"1f36ecdd.e941e3","name":"not locked","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"Locked","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1240,"y":320,"wires":[["68a5251f.7f061c"]]},{"id":"e857ffbb.5b92b","type":"switch","z":"1f36ecdd.e941e3","name":"locked?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"locked","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1250,"y":480,"wires":[["1f8062e5.b9f4ad"]]},{"id":"d1146cc7.5f41c","type":"switch","z":"1f36ecdd.e941e3","name":"is True","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":940,"y":360,"wires":[["aa8d41ae.f014f"],["4d5bc2ef.5d49fc"]]},{"id":"f17566a9.c052b8","type":"hubitat config","z":"","name":"","usetls":false,"host":"192.168.2.3","port":"80","appId":"3424","nodeRedServer":"http://192.168.2.9:1880","webhookPath":"/hubitat/webhook","autoRefresh":true}]

2 Likes

I have to wait 8 whole hours before I can node red to my heart's content. It's going to be a painful wait.

1 Like

3 hours to go :wink:

1 Like

OH I KNOW! Then a 25 minute drive home. Maybe I'll skip dinner.

It is officially 7:31 pm and I still .. have not ... been able to node red. UGH!
Why am I responsible?
#adulting

1 Like

OMGOSH! This is so elegant!
Tells me that I have so very much to learn.

1 Like

I don't understand why the switch is showing both locked, both closed, both on. Can you explain?
image

They all have 2 outputs, one for true, in the case of is locked, the lock is engaged. And one for false, the lock isn't engaged. We use those 2 outputs to send to a change to make the payload trueor false for the Boolean.