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

Especially me tonight. Just killed half a bottle of bourbon with my godson’s dad.

2 Likes

Think of it this way, if you can teach ME how to do this, you can teach anyone.

Even if influenced by bourbon.

2 Likes

Nah - you a smart girl.

1 Like

Yah, I think I'm going to become a boolean junkie now. Do they have a group for that?

2 Likes

Yeah, I need to convert some of my early flows now that I learned how to use the ultimate Boolean... Add me to the junkie group.

1 Like

1 Like

Question:
@aaiyar @napalmcsr @csteele

Can you explain to me how the inject works? Like why it works in this flow. Essentially I know what the inject does, but I'm curious why it is needed here and how that works. Also, is this the correct way for this flow to look if everything is locked up. Will this weigh on my pie or hub sitting like this? I don't want to create a monster and have trouble. I want to make sure I learn this correctly.
This shows the overhead door open, so it should be stopped, but if everything evaluates to false because it's closed, it still shows stopped.

The inject causes all of your conditions to be initialized in the Boolean block by doing a check on all of your inputs.

With the picture you showed, the stopped is because one of your inputs is false. Look at the and under the Boolean block to see the state of the block.

1 Like

We talk a lot about Hubitat being an Event driven machine.

Node-Red is the same EXCEPT we call them Messages in Node-Red. Hubitat has Attributes in Events, Node-Red has topics inside Messages. Really, they are far more similar than different. 90% of the difference is in the word(s) used.

The Event/Message occurs and then propagates through the Nodes and "falls out" the end. No load on the Pi or the Hub. Now if you had a Loop in there.. different answer.

2 Likes

Yes, I realize that the shot I provided has a false, but when all inputs are showing true - so the house is locked up, the rule still shows stopped. Is this an issue for processing? Or is it set up wrong? The foyer lock would be the false answer when the house is closed up because i have that opposite to get the rule to run correctly, so the first foyer lock is unlocked is set to true and locked is set to false. Otherwise the rule would never complete to lock the lock. That's why I wondered if I should do it differently, or if this status is ok to keep sitting like that? The Garage lock locks itself, and we have to close the doors, so the lock was the only one that if it was unlocked for whatever reason, it would lock again.

So with everything in the status that it should be in, the rule is stopped. I feel like that's hard on things.

Again, if you look at the tiny words under Ultimate Boolean, you'll see (AND) false... which means a message went out and was switched by "Is True" to the False output, causing a message with the word "stop" to be sent. That's the one specific situation where a Red Hollow Circle "Stopped" would appear.

In other words, the flow locks the door because of True after a delay (which means the timer is stopped), which causes a false, which stops the timer (which wasn't running anyway) doing nothing but put a Hollow Red Circle on the page.

Sooo ... that's not going to be a processing nightmare then? Asking for a friend.

It's quiescent.. waiting for the next "Event" there's no processing going on and on and on

1 Like

Ok good. So is this the best way to make this flow work then? Or is there something that's even more mind blowing?

It's a computer.. so there's almost always 3 ways of doing the same thing. Ask any programmer that's ever picked up someone else's work. "Theirs" is always the wrong way to do it.

You can do it with a Function, but rather like RM, it's a big thing to load. It's a great way, but because of the bulk, people look for other ways. I'm not as biased but maybe one day soon I'll catch on. I think I'd have tackled this with a Function because it can condense so many nodes. The question always is: do the Nodes that get condensed overcome the overhead of Function ?

1 Like

Thank you for all of your help on this. You guys make it look so easy. I hope one day it will be that easy for me. Thank you for helping me to understand the concepts used here as well. I'm going to change the topic a bit to reflect tha.

2 Likes

I feel ya @april.brandt i often know exactly what I want to happen. Getting the logic to work always seems to fall down somewhere and I give up lol. I admire the perseverance

2 Likes

I pm'd @april.brandt my flow also, (as i said i would) but looks like it got sorted,
But in the interest of sharing and incase anyone else comes along and needs ideas, ill post my boolean flow also.

I only care about "true" output and based on 2 topics

``````[{"id":"7a75a4f2.88bc2c","type":"hubitat mode-setter","z":"dad19d67.dbd38","name":"Quiet","server":"26c9a23e.36f4ce","modeId":"161","x":1650,"y":400,"wires":[[]]},{"id":"4d870d1e.b688e4","type":"hubitat mode-setter","z":"dad19d67.dbd38","name":"Asleep","server":"26c9a23e.36f4ce","modeId":"132","x":1650,"y":360,"wires":[[]]},{"id":"f97d2038.f2a84","type":"hubitat mode-setter","z":"dad19d67.dbd38","name":"Home","server":"26c9a23e.36f4ce","modeId":"130","x":1650,"y":440,"wires":[[]]},{"id":"75059a8b.12cce4","type":"hubitat mode-setter","z":"dad19d67.dbd38","name":"Away","server":"26c9a23e.36f4ce","modeId":"131","x":1650,"y":480,"wires":[[]]},{"id":"68b9e6be.778578","type":"mqtt in","z":"dad19d67.dbd38","name":"mqtt: presence/Adam","topic":"presence/Adam","qos":"0","datatype":"auto","broker":"db0e212c.8ecc","x":140,"y":400,"wires":[["550c46e7.7b2a78","b97280ad.978a1","3f1489a6.64bfd6"]]},{"id":"5ad5ab85.4ccd44","type":"mqtt in","z":"dad19d67.dbd38","name":"mqtt: presence/Trina","topic":"presence/Trina","qos":"0","datatype":"auto","broker":"db0e212c.8ecc","x":140,"y":480,"wires":[["7d8d26a2.072c28","cd8dc83d.667848","92109fcb.93a56"]]},{"id":"8ec91cd.72f2ee","type":"hubitat device","z":"dad19d67.dbd38","name":"Adam Quiet Mode","server":"26c9a23e.36f4ce","deviceId":"417","attribute":"switch","sendEvent":true,"x":890,"y":360,"wires":[["8b7aa1e9.dbe2d","840db884.813fd8"]]},{"id":"41c7db1c.319114","type":"hubitat device","z":"dad19d67.dbd38","name":"Trina Quiet Mode","server":"26c9a23e.36f4ce","deviceId":"545","attribute":"switch","sendEvent":true,"x":890,"y":420,"wires":[["491762.27e4a8a","bfd9b9a8.473b28"]]},{"id":"9d1d0275.83d2e","type":"BooleanLogicUltimate","z":"dad19d67.dbd38","name":"Either Home","filtertrue":"onlytrue","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":2,"topic":"result","x":600,"y":400,"wires":[[],["8ec91cd.72f2ee","41c7db1c.319114"],[]]},{"id":"550c46e7.7b2a78","type":"change","z":"dad19d67.dbd38","name":"Home=True","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"str","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":380,"wires":[["9d1d0275.83d2e"]]},{"id":"7d8d26a2.072c28","type":"change","z":"dad19d67.dbd38","name":"Home=True","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"str","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":460,"wires":[["9d1d0275.83d2e"]]},{"id":"e4b1595d.06d7b8","type":"BooleanLogicUltimate","z":"dad19d67.dbd38","name":"Both On or 1 On","filtertrue":"onlytrue","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"2","topic":"result","x":1360,"y":360,"wires":[["4d870d1e.b688e4"],[],["7a75a4f2.88bc2c"]]},{"id":"8b7aa1e9.dbe2d","type":"change","z":"dad19d67.dbd38","name":"On=True","rules":[{"t":"set","p":"payload","pt":"msg","to":"\$contains(payload.value,\"on\") ? 1:0","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":340,"wires":[["e4b1595d.06d7b8"]]},{"id":"491762.27e4a8a","type":"change","z":"dad19d67.dbd38","name":"On=True","rules":[{"t":"set","p":"payload","pt":"msg","to":"\$contains(payload.value,\"on\") ? 1:0","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":420,"wires":[["e4b1595d.06d7b8"]]},{"id":"840db884.813fd8","type":"change","z":"dad19d67.dbd38","name":"Off=True","rules":[{"t":"set","p":"payload","pt":"msg","to":"\$contains(payload.value,\"off\") ? 1:0","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":380,"wires":[["5c42c70c.5efea8"]]},{"id":"bfd9b9a8.473b28","type":"change","z":"dad19d67.dbd38","name":"Off=True","rules":[{"t":"set","p":"payload","pt":"msg","to":"\$contains(payload.value,\"off\") ? 1:0","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":460,"wires":[["5c42c70c.5efea8"]]},{"id":"5c42c70c.5efea8","type":"BooleanLogicUltimate","z":"dad19d67.dbd38","name":"Both Off","filtertrue":"onlytrue","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"2","topic":"result","x":1330,"y":440,"wires":[["f97d2038.f2a84"],[],[]]},{"id":"48ee5b2.727cfa4","type":"BooleanLogicUltimate","z":"dad19d67.dbd38","name":"Both Away","filtertrue":"onlytrue","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"2","topic":"result","x":600,"y":480,"wires":[["75059a8b.12cce4"],[],[]]},{"id":"b97280ad.978a1","type":"change","z":"dad19d67.dbd38","name":"Away=True","rules":[{"t":"set","p":"payload","pt":"msg","to":"\$number( payload = 'false')","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":420,"wires":[["48ee5b2.727cfa4"]]},{"id":"cd8dc83d.667848","type":"change","z":"dad19d67.dbd38","name":"Away=True","rules":[{"t":"set","p":"payload","pt":"msg","to":"\$number( payload = 'false')","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":500,"wires":[["48ee5b2.727cfa4"]]},{"id":"f7f500f7.8764d","type":"hubitat command","z":"dad19d67.dbd38","name":"Adam Home","server":"26c9a23e.36f4ce","deviceId":"705","command":"arrived","commandArgs":"","x":590,"y":300,"wires":[[]]},{"id":"3f1489a6.64bfd6","type":"switch","z":"dad19d67.dbd38","name":"Home/Away","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":340,"wires":[["f7f500f7.8764d"],["b77db2ba.3c5eb"]]},{"id":"b77db2ba.3c5eb","type":"hubitat command","z":"dad19d67.dbd38","name":"Adam Away","server":"26c9a23e.36f4ce","deviceId":"705","command":"departed","commandArgs":"","x":590,"y":340,"wires":[[]]},{"id":"92109fcb.93a56","type":"switch","z":"dad19d67.dbd38","name":"Home/Away","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":540,"wires":[["36500a46.341576"],["464b47c4.d0b578"]]},{"id":"36500a46.341576","type":"hubitat command","z":"dad19d67.dbd38","name":"Trina Home","server":"26c9a23e.36f4ce","deviceId":"706","command":"arrived","commandArgs":"","x":590,"y":540,"wires":[[]]},{"id":"464b47c4.d0b578","type":"hubitat command","z":"dad19d67.dbd38","name":"Trina Home","server":"26c9a23e.36f4ce","deviceId":"706","command":"departed","commandArgs":"","x":590,"y":580,"wires":[[]]},{"id":"26c9a23e.36f4ce","type":"hubitat config","z":"","name":"Hubitat","usetls":false,"host":"192.168.1.202","port":"80","appId":"545","nodeRedServer":"http://192.168.1.18:1880","webhookPath":"/hubitat/webhook","autoRefresh":true},{"id":"db0e212c.8ecc","type":"mqtt-broker","z":"","name":"Mosquitto","broker":"192.168.1.13","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
``````

There is probably better ways, but atm its working!!

1 Like

@csteele @napalmcsr @aaiyar
Can you tell me why xor worked here?

I have the railing motion only to wake up the lights, but the other rule keeps the lights at 100% until they are all inactive and the light is off. I have an inject at the beginning. Why does xor work for this? I'll post the flow in the next post.

`[{"id":"b5f97317.fefa9","type":"switch","z":"d3b0329e.892a5","name":"Is Active","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"active","vt":"str"},{"t":"eq","v":"inactive","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":660,"y":2020,"wires":[["f2ce42d2.dcc14"],["d219b4e4.e296a8"]]},{"id":"3743adc3.bd99d2","type":"hubitat device","z":"d3b0329e.892a5","name":"Railing Motion","server":"791ed0f2.6643c","deviceId":"1430","attribute":"motion","sendEvent":true,"x":580,"y":1900,"wires":[["c4b41c7c.e0117"]]},{"id":"46805f89.2effb","type":"hubitat device","z":"d3b0329e.892a5","name":"Table Motion","server":"791ed0f2.6643c","deviceId":"1435","attribute":"motion","sendEvent":true,"x":450,"y":1960,"wires":[["b5f97317.fefa9"]]},{"id":"e8418133.1c559","type":"hubitat device","z":"d3b0329e.892a5","name":"Island Motion","server":"791ed0f2.6643c","deviceId":"1439","attribute":"motion","sendEvent":true,"x":450,"y":2020,"wires":[["b5f97317.fefa9"]]},{"id":"bba6ca2b.12e0c8","type":"hubitat device","z":"d3b0329e.892a5","name":"Sink Motion","server":"791ed0f2.6643c","deviceId":"1908","attribute":"motion","sendEvent":true,"x":450,"y":2080,"wires":[["b5f97317.fefa9"]]},{"id":"200f02e8.b0b13e","type":"hubitat device","z":"d3b0329e.892a5","name":"Stove Motion","server":"791ed0f2.6643c","deviceId":"1684","attribute":"motion","sendEvent":true,"x":450,"y":2140,"wires":[["b5f97317.fefa9"]]},{"id":"f2ce42d2.dcc14","type":"change","z":"d3b0329e.892a5","name":"set True","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":2000,"wires":[["9c55dc9d.8d96"]]},{"id":"9c55dc9d.8d96","type":"BooleanLogicUltimate","z":"d3b0329e.892a5","name":"","filtertrue":"both","persist":true,"sInitializeWith":"false","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"6","topic":"result","x":1000,"y":2060,"wires":[[],[],["e801f40f.978af8"]]},{"id":"d219b4e4.e296a8","type":"change","z":"d3b0329e.892a5","name":"set False","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":2140,"wires":[["9c55dc9d.8d96"]]},{"id":"e801f40f.978af8","type":"switch","z":"d3b0329e.892a5","name":"is True","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":1150,"y":2060,"wires":[["ce20a6e.e7cd558"],["a157988b.c6d198"]]},{"id":"ce20a6e.e7cd558","type":"stoptimer","z":"d3b0329e.892a5","duration":"30","units":"Second","payloadtype":"num","payloadval":"0","name":"","x":1350,"y":2040,"wires":[["8070b905.afa218"],[]]},{"id":"a157988b.c6d198","type":"change","z":"d3b0329e.892a5","name":"stop the timer","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1320,"y":1980,"wires":[["ce20a6e.e7cd558"]]},{"id":"3ffdf125.506c6e","type":"time-range-switch","z":"d3b0329e.892a5","name":"sunset to sunrise = output 1","lat":"43.4561268","lon":"-96.4379696","startTime":"sunset","endTime":"sunrise","startOffset":"-59","endOffset":"+59","x":980,"y":1900,"wires":[["cacb7ddd.76681"],["c07144ca.f07048"]]},{"id":"8132c43f.b092c8","type":"hubitat command","z":"d3b0329e.892a5","name":"RGBW E 100%","server":"791ed0f2.6643c","deviceId":"2330","command":"setLevel","commandArgs":"100","x":1580,"y":1860,"wires":[["a5593237.8757a"]]},{"id":"a5593237.8757a","type":"hubitat command","z":"d3b0329e.892a5","name":"RGBW N 100%","server":"791ed0f2.6643c","deviceId":"2331","command":"setLevel","commandArgs":"100","x":1760,"y":1860,"wires":[[]]},{"id":"cacb7ddd.76681","type":"hubitat mode","z":"d3b0329e.892a5","name":"Mode","server":"791ed0f2.6643c","sendEvent":false,"x":1230,"y":1880,"wires":[["579b1270.bb39ac"]]},{"id":"579b1270.bb39ac","type":"switch","z":"d3b0329e.892a5","name":"Mode is NOT Night","property":"payload.value","propertyType":"msg","rules":[{"t":"neq","v":"Night","vt":"str"},{"t":"eq","v":"Night","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1390,"y":1880,"wires":[["8132c43f.b092c8"],["f2b274df.d1f918"]]},{"id":"f2b274df.d1f918","type":"hubitat command","z":"d3b0329e.892a5","name":"RGBW N 50%","server":"791ed0f2.6643c","deviceId":"2331","command":"setLevel","commandArgs":"50","x":1580,"y":1900,"wires":[[]]},{"id":"c07144ca.f07048","type":"hubitat command","z":"d3b0329e.892a5","name":"RGBW E Off","server":"791ed0f2.6643c","deviceId":"2330","command":"off","commandArgs":"","x":1250,"y":1920,"wires":[["c299f5e0.f31f48"]]},{"id":"c299f5e0.f31f48","type":"hubitat command","z":"d3b0329e.892a5","name":"RGBW N Off","server":"791ed0f2.6643c","deviceId":"2331","command":"off","commandArgs":"","x":1410,"y":1920,"wires":[[]]},{"id":"8070b905.afa218","type":"time-range-switch","z":"d3b0329e.892a5","name":"sunset to sunrise = output 1","lat":"43.4561268","lon":"-96.4379696","startTime":"sunset","endTime":"sunrise","startOffset":"-59","endOffset":"+59","x":1380,"y":2100,"wires":[["c8074316.1456"],["d56e935e.4486b"]]},{"id":"c8074316.1456","type":"hubitat mode","z":"d3b0329e.892a5","name":"Mode","server":"791ed0f2.6643c","sendEvent":false,"x":1570,"y":2080,"wires":[["b26517f4.732eb8"]]},{"id":"b26517f4.732eb8","type":"switch","z":"d3b0329e.892a5","name":"Mode is NOT Night","property":"payload.value","propertyType":"msg","rules":[{"t":"neq","v":"Night","vt":"str"},{"t":"eq","v":"Night","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1730,"y":2080,"wires":[["31e6c0f0.3d16d"],["849306bd.dd7fc8"]]},{"id":"d56e935e.4486b","type":"hubitat command","z":"d3b0329e.892a5","name":"RGBW E Off","server":"791ed0f2.6643c","deviceId":"2330","command":"off","commandArgs":"","x":1590,"y":2140,"wires":[["2f889091.d6c68"]]},{"id":"2f889091.d6c68","type":"hubitat command","z":"d3b0329e.892a5","name":"RGBW N Off","server":"791ed0f2.6643c","deviceId":"2331","command":"off","commandArgs":"","x":1750,"y":2140,"wires":[[]]},{"id":"c4b41c7c.e0117","type":"switch","z":"d3b0329e.892a5","name":"Is Active","property":"payload.currentValue","propertyType":"msg","rules":[{"t":"eq","v":"active","vt":"str"},{"t":"eq","v":"inactive","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":760,"y":1900,"wires":[["3ffdf125.506c6e"],[]]},{"id":"7384af31.fd283","type":"hubitat device","z":"d3b0329e.892a5","name":"Railing Motion","server":"791ed0f2.6643c","deviceId":"1430","attribute":"motion","sendEvent":true,"x":440,"y":2200,"wires":[["b5f97317.fefa9"]]},{"id":"54d17bc8.6e5494","type":"inject","z":"d3b0329e.892a5","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"0.5","x":200,"y":2100,"wires":[["46805f89.2effb","e8418133.1c559","bba6ca2b.12e0c8","200f02e8.b0b13e","7384af31.fd283","ad953f15.d45b7"]]},{"id":"ad953f15.d45b7","type":"hubitat device","z":"d3b0329e.892a5","name":"Cans (switch)","server":"791ed0f2.6643c","deviceId":"221","attribute":"switch","sendEvent":true,"x":440,"y":2260,"wires":[["ebc4a225.15705"]]},{"id":"ebc4a225.15705","type":"switch","z":"d3b0329e.892a5","name":"is on","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":2260,"wires":[["f2ce42d2.dcc14"],["d219b4e4.e296a8"]]},{"id":"31e6c0f0.3d16d","type":"hubitat command","z":"d3b0329e.892a5","name":"RGBW E 15%","server":"791ed0f2.6643c","deviceId":"2330","command":"setLevel","commandArgs":"15","x":1920,"y":2040,"wires":[["554039c1.1609d8"]]},{"id":"849306bd.dd7fc8","type":"hubitat command","z":"d3b0329e.892a5","name":"RGBW N 15%","server":"791ed0f2.6643c","deviceId":"2331","command":"setLevel","commandArgs":"15","x":1920,"y":2120,"wires":[[]]},{"id":"554039c1.1609d8","type":"hubitat command","z":"d3b0329e.892a5","name":"RGBW N 15%","server":"791ed0f2.6643c","deviceId":"2331","command":"setLevel","commandArgs":"15","x":2100,"y":2040,"wires":[[]]},{"id":"791ed0f2.6643c","type":"hubitat config","z":"","name":"Hubitat","usetls":false,"host":"192.168.86.32","port":"80","appId":"3451","nodeRedServer":"http://192.168.86.51:1880","webhookPath":"/hubitat/webhook_","autoRefresh":true}]`