Need gate node with 2 outputs

I have this flow

[{"id":"157b003.89d2a","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"ebed8251.e6964","type":"hubitat device","z":"157b003.89d2a","name":"Front Porch","server":"5780d46e.3640ac","deviceId":"98","attribute":"illuminance","sendEvent":true,"x":210,"y":80,"wires":[["664a331c.ffb3fc"]]},{"id":"664a331c.ffb3fc","type":"range","z":"157b003.89d2a","minin":"0","maxin":"800","minout":"15","maxout":"80","action":"clamp","round":true,"property":"payload.value","name":"Scale Luminance to Dimmer Level","x":480,"y":80,"wires":[["2e14250f.be3d3a"]]},{"id":"f8ceaeea.d9e42","type":"hubitat device","z":"157b003.89d2a","name":"Upstairs Hall Motion #1","server":"7e632c0e.cc9424","deviceId":"835","attribute":"motion","sendEvent":true,"x":250,"y":260,"wires":[["b664f02b.da6e7"]]},{"id":"5064839e.703d9c","type":"hubitat device","z":"157b003.89d2a","name":"Upstairs Hall","server":"5780d46e.3640ac","deviceId":"487","attribute":"illuminance","sendEvent":true,"x":210,"y":180,"wires":[["9837ed94.f323a"]]},{"id":"f1882cb2.5322d","type":"gate","z":"157b003.89d2a","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":true,"x":710,"y":180,"wires":[["1f06a926.d36d67"]]},{"id":"62954787.90db78","type":"hubitat command","z":"157b003.89d2a","name":"Upstairs Hall","server":"7e632c0e.cc9424","deviceId":"194","command":"setLevel","commandArgs":"","x":1150,"y":180,"wires":[[]]},{"id":"19c44f16.991711","type":"hubitat command","z":"157b003.89d2a","name":"Upstairs Hall","server":"5780d46e.3640ac","deviceId":"194","command":"off","commandArgs":"","x":1150,"y":280,"wires":[[]]},{"id":"4bb62662.827088","type":"change","z":"157b003.89d2a","name":"Open Gate","rules":[{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":160,"wires":[["f1882cb2.5322d"]]},{"id":"9837ed94.f323a","type":"switch","z":"157b003.89d2a","name":"< 15","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"15","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":180,"wires":[["4bb62662.827088"],["3b9b25d0.f9745a"]]},{"id":"3b9b25d0.f9745a","type":"change","z":"157b003.89d2a","name":"Close Gate","rules":[{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":200,"wires":[["f1882cb2.5322d"]]},{"id":"b664f02b.da6e7","type":"trigger","z":"157b003.89d2a","name":"Delay Off 2 Min","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":460,"y":290,"wires":[["f1882cb2.5322d"],["19c44f16.991711","75618413.5d0e0c"]]},{"id":"1f06a926.d36d67","type":"change","z":"157b003.89d2a","name":"Get Dimmer Level","rules":[{"t":"set","p":"arguments","pt":"msg","to":"dimmer_level","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":180,"wires":[["62954787.90db78"]]},{"id":"2e14250f.be3d3a","type":"change","z":"157b003.89d2a","name":"Save Dimmer Level","rules":[{"t":"move","p":"payload.value","pt":"msg","to":"dimmer_level","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":80,"wires":[[]]},{"id":"521ca8c6.ca5c28","type":"hubitat device","z":"157b003.89d2a","name":"Upstairs Hall Motion #2","server":"7e632c0e.cc9424","deviceId":"577","attribute":"motion","sendEvent":true,"x":250,"y":320,"wires":[["b664f02b.da6e7"]]},{"id":"75618413.5d0e0c","type":"delay","z":"157b003.89d2a","name":"Delay 4s","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":800,"y":340,"wires":[["ee759992.22d828"]]},{"id":"ee759992.22d828","type":"hubitat command","z":"157b003.89d2a","name":"Upstairs Hall Environment","server":"7e632c0e.cc9424","deviceId":"487","command":"refresh","commandArgs":"","x":1110,"y":340,"wires":[[]]},{"id":"a3b7fe71.a3a48","type":"easing","z":"157b003.89d2a","name":"","easingType":"linear","outputType":"overTime","duration":"6000","interval":"2000","numberOfValues":10,"x":790,"y":140,"wires":[["1f06a926.d36d67"]]},{"id":"5780d46e.3640ac","type":"hubitat config","z":"","name":"Steve's Hubitat - webhook","usetls":false,"host":"192.168.1.12","port":"80","appId":"545","nodeRedServer":"http://pvr.localdomain:1880","webhookPath":"/hubitat/webhook_","autoRefresh":true,"useWebsocket":false},{"id":"7e632c0e.cc9424","type":"hubitat config","z":"","name":"Steve's Hubitat - websocket","usetls":false,"host":"hubitat.localdomain","port":"80","appId":"545","nodeRedServer":"http://pvr.localdomain:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":true}]

What I need is for the gate to pass on the message to the "easing" node when it's closed. I've scoured this forum and found a few similar requests that were resolved by using different nodes but none of those accomplish what I want, AFAICT. Even if there is a way it wouldn't be as simple to understand as having a 2nd output on the gate.

I've not found a 2-output gate, only a function node which passes 2 values, the msg and null like (msg, null) and (null, msg) and I find that cumbersome and hard to read compared to a gate with the 2nd output.

I'm hoping that someone here can point me to such a gate node, perhaps an unpublished one, or that the owner/maintainer of the existing gate will add the 2nd output. If not I suppose my best course would be to copy the gate node and make the addition myself. Not being a js programmer, that could take quite a while. :anguished:

Can you define in words what the two output gate would do? Do you mean effectively a Switch node that can be told which output to send messages to?

Modifing an exisiting node is normally the last resort

IIUYC you want to bypass the gate when its closed and send the messages that arrive when its closed to the easing node?

If so, just copy the 2 change nodes and the gate and paste them above existing nodes

Then just alter the logic of the change nodes so that they open the new gate when the existing one is closed and vice versa

Thanks for the quick response, Colin.

I want the gate to pass the incoming message directly to the "Get Dimmer Level" node when open and have the same message go through the Easing node before going to the "Get Dimmer Level" node when it's closed.

Agreed.

That's the more cumbersome and harder to read solution I mentioned and I prefer attempting to modify the gate node if I can.

I think I would do this by using a Join node to combine the Upstairs Hall message with the output from Delay Off 2 MIn to make a key/value object containing both payloads. They would have to have unique topics set, which they may already. Then use a switch node to test whether the value is <15 or not and send the message to output 1 or 2 as appropriate. That would remove the open and close nodes and replace a Switch and a Gate with a Join and a Switch. It might need Change nodes added to setup the topics however. Also the message format out will be different so you might need to adjust the later nodes.

[Edit] Oh, it would also need another switch on the output of the Join node to only pass on messages with topic == that from the delay node.

I think I get the idea but I have to implement it to be sure as I'm very visual. Thank you and I'll report back when I've tried it.

You will probably want the Join node in Manual mode, creating a Key/Value object, send after 2 message parts and every subsequent message.

Thanks again

OK, @Colin, in laying out what I think you mean I discovered that the flow I posted is NOT exactly what I want and the description is messed up to boot. :roll_eyes:

What I really want is the decision to bypass the easing node to be based on the light level from the front porch. Here is the issue in real world terms... I had the flow setup and working perfectly for nighttime and then discovered I had a problem during daytime because the upstairs hall light sensor is so fast that my shadow when walking past would drop its output below 15 and the hall lights would come on during the day. So I added the easing node to slow the response so that wouldn't happen. That works really well but then the nighttime response was slowed to where the lights wouldn't come on if they had just turned off after the delay. So what I need is to ease, or not, depending on the outside light level.

So here is the flow to better handle that. I have not coded the join or the following switch yet as I want to be sure this is what you had in mind (and given that I've now correctly stated the issue).

[{"id":"b5b5bccd.2c373","type":"tab","label":"Flow 2","disabled":true,"info":""},{"id":"b16e0fb3.4bbde","type":"hubitat device","z":"b5b5bccd.2c373","name":"Front Porch","server":"5780d46e.3640ac","deviceId":"98","attribute":"illuminance","sendEvent":true,"x":210,"y":80,"wires":[["521edcae.38bc44","55358e93.b170b"]]},{"id":"521edcae.38bc44","type":"range","z":"b5b5bccd.2c373","minin":"0","maxin":"800","minout":"15","maxout":"80","action":"clamp","round":true,"property":"payload.value","name":"Scale Luminance to Dimmer Level","x":520,"y":80,"wires":[["d7664141.49e2d"]]},{"id":"33b86da2.5de5b2","type":"hubitat device","z":"b5b5bccd.2c373","name":"Upstairs Hall Motion #1","server":"7e632c0e.cc9424","deviceId":"835","attribute":"motion","sendEvent":true,"x":250,"y":260,"wires":[["1f9c2dac.c68f62"]]},{"id":"64c15a0b.6af654","type":"hubitat device","z":"b5b5bccd.2c373","name":"Upstairs Hall","server":"5780d46e.3640ac","deviceId":"487","attribute":"illuminance","sendEvent":true,"x":210,"y":180,"wires":[["55358e93.b170b"]]},{"id":"490fa03d.a468c","type":"gate","z":"b5b5bccd.2c373","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":true,"x":1170,"y":180,"wires":[["686af387.80cd5c"]]},{"id":"d8d8cfea.536d8","type":"hubitat command","z":"b5b5bccd.2c373","name":"Upstairs Hall","server":"7e632c0e.cc9424","deviceId":"194","command":"setLevel","commandArgs":"","x":1510,"y":180,"wires":[[]]},{"id":"bcda335.293acd","type":"hubitat command","z":"b5b5bccd.2c373","name":"Upstairs Hall","server":"5780d46e.3640ac","deviceId":"194","command":"off","commandArgs":"","x":910,"y":280,"wires":[[]]},{"id":"d46c3bd.9a470c8","type":"change","z":"b5b5bccd.2c373","name":"Open Gate","rules":[{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":160,"wires":[["490fa03d.a468c"]]},{"id":"7eed4af1.4d6524","type":"switch","z":"b5b5bccd.2c373","name":"< 15","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"15","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":850,"y":180,"wires":[["d46c3bd.9a470c8"],["b482178e.9ecbf8"]]},{"id":"b482178e.9ecbf8","type":"change","z":"b5b5bccd.2c373","name":"Close Gate","rules":[{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":200,"wires":[["490fa03d.a468c"]]},{"id":"1f9c2dac.c68f62","type":"trigger","z":"b5b5bccd.2c373","name":"Delay Off 2 Min","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":480,"y":290,"wires":[["490fa03d.a468c"],["bcda335.293acd","4968b0a2.1212f"]]},{"id":"686af387.80cd5c","type":"change","z":"b5b5bccd.2c373","name":"Get Dimmer Level","rules":[{"t":"set","p":"arguments","pt":"msg","to":"dimmer_level","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1330,"y":180,"wires":[["d8d8cfea.536d8"]]},{"id":"d7664141.49e2d","type":"change","z":"b5b5bccd.2c373","name":"Save Dimmer Level","rules":[{"t":"move","p":"payload.value","pt":"msg","to":"dimmer_level","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":80,"wires":[[]]},{"id":"cea340e3.90b7e","type":"hubitat device","z":"b5b5bccd.2c373","name":"Upstairs Hall Motion #2","server":"7e632c0e.cc9424","deviceId":"577","attribute":"motion","sendEvent":true,"x":250,"y":320,"wires":[["1f9c2dac.c68f62"]]},{"id":"4968b0a2.1212f","type":"delay","z":"b5b5bccd.2c373","name":"Delay 4s","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":660,"y":340,"wires":[["c57e9885.a4d7c8"]]},{"id":"c57e9885.a4d7c8","type":"hubitat command","z":"b5b5bccd.2c373","name":"Upstairs Hall Environment","server":"7e632c0e.cc9424","deviceId":"487","command":"refresh","commandArgs":"","x":870,"y":340,"wires":[[]]},{"id":"b12fec7a.c1d4d","type":"easing","z":"b5b5bccd.2c373","name":"","easingType":"linear","outputType":"overTime","duration":"6000","interval":"2000","numberOfValues":10,"x":710,"y":140,"wires":[["7eed4af1.4d6524"]]},{"id":"337b60a1.d4d9d","type":"switch","z":"b5b5bccd.2c373","name":"FP light >500?","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"500","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":180,"wires":[["b12fec7a.c1d4d"],["7eed4af1.4d6524"]]},{"id":"55358e93.b170b","type":"join","z":"b5b5bccd.2c373","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":370,"y":180,"wires":[["337b60a1.d4d9d"]]},{"id":"5780d46e.3640ac","type":"hubitat config","z":"","name":"Steve's Hubitat - webhook","usetls":false,"host":"192.168.1.12","port":"80","appId":"545","nodeRedServer":"http://pvr.localdomain:1880","webhookPath":"/hubitat/webhook_","autoRefresh":true,"useWebsocket":false},{"id":"7e632c0e.cc9424","type":"hubitat config","z":"","name":"Steve's Hubitat - websocket","usetls":false,"host":"hubitat.localdomain","port":"80","appId":"545","nodeRedServer":"http://pvr.localdomain:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":true}]

In that case then if you want to hack the node, you need to find where your node-red-contrib-simple-gate code is

On my setup it is in my .node-red\node_modules\node-red-contrib-simple-gate folder

Then just edit the gate.html to tell it you want two outputs

image

and then alter gate.js to send to both outputs

image

restart NR and refresh your browser and you should now have two outputs - output1 will be original and output 2 will be the bypass when closed

Obviously, not a long term sustainable solution

1 Like

I'll try that. Thanks for the pointers on how-to!

Sorry, I am confused now, are you saying all you need to know when deciding whether to go through the easing node (in fact I have no idea what any of the contrib nodes actually do) is only based on the porch and hall light levels, so you don't need the second output on the gate at all? I thought the motion message had to go through the easing node.

I'm so sorry to have messed this up in the first place.

The decision on whether to go through, or bypass, the easing node is based on the outside light level from the front porch. The easing node only operates on the hall light level and that message goes only so far as the Open/Close change nodes to control the gate. The message that sets the level (which also turns on the dimmer) comes through the trigger node and is passed, or not, through the gate. I hope that helps.

OK, understood. In that case, yes that should work, except that you have missed the edit I added to my earlier post, you also need another Switch after the join node, that only passes messages whose topic is that of the upstairs hall light.

Ah, thank you. I didn't miss your edit, just thought I had it covered. I'd have found that I don't when coding the join and following switch nodes. :slightly_smiling_face:

First I'm going to take a shot at @cymplecy's 2-output gate, in no small part because I've never looked inside a node before.

This task has suddenly moved to the back seat because I just got my Pi Zero W cam working like I want and I want to wrap that up before switching contexts again. This old brain doesn't do that very well anymore. :thinking:

I'm late joining this discussion and have not had a chance to read the previous posts carefully, so I apologize if I miss the point or repeat other's ideas. If I understand correctly @LosinIt wants a flow that sends messages on one of two paths, depending on its state. Something like this might help:

[{"id":"f2e1eef3.0a76e8","type":"gate","z":"5faee2f.474159c","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":330,"y":80,"wires":[["8173c079.f9cb98"]]},{"id":"135ebead.282cb9","type":"gate","z":"5faee2f.474159c","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":330,"y":140,"wires":[["8d38a26f.6dfa78"]]},{"id":"d1d2b0fa.ec0f7","type":"inject","z":"5faee2f.474159c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":80,"wires":[["f2e1eef3.0a76e8","135ebead.282cb9"]]},{"id":"1408674.ccaad99","type":"inject","z":"5faee2f.474159c","name":"","topic":"control","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":140,"wires":[["f2e1eef3.0a76e8","135ebead.282cb9"]]},{"id":"8173c079.f9cb98","type":"debug","z":"5faee2f.474159c","name":"output 1","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":480,"y":80,"wires":[]},{"id":"8d38a26f.6dfa78","type":"debug","z":"5faee2f.474159c","name":"output 2","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":480,"y":140,"wires":[]}]
1 Like

I like it! Thanks!

By golly - I think I've cracked it :slight_smile:

Just add a parallel gate and change the open/close commands for it :slight_smile:

3 Likes

And that's more clear than what @drmibell posted with the toggle, at least to me. It wasn't my intent to have all you sleuths on the case but this has become a very informative topic. And I still want to make the 2-output gate just to see if I can git 'er done but I'm marking this as Solved as soon as I implement it.

Thanks, all!