Node-Red Flow Samples/Sharing

I don't think deleting flow deletes the associated config node. On the right panel, click to see all of the config nodes and I bet you will find offending node still there.

2 Likes

Looks like I deleted the config nodes the wrong way and it is now hidden. I am going to attempt a reinstall once I have exported my work.

I am very green at node-red so I expect to make errors as I have no coding experience and some of the nodes are alien to me. Thanks heaps for the help and quick replies.

1 Like

Hi all -
I'm needing a little advice on this flow I set up for dimming lights based on my Chromecasts player state. I don't want this flows sequence to be able to activate if the Hubitat mode node is currently in a DAY mode, we wouldn't need the lights to be doing anything during the day. Any ideas on how I can incorporate this into the sequence? This is my first attempt at anything node-red related, so hopefully this makes sense. Thanks!

Using a change node, save your mode to a flow variable.

Then insert switch nodes to test for that flow variable != DAY after your Playing/Paused nodes.

1 Like

Okay. I'll try and input that information and see what happens. Thanks kindly.

1 Like

Here's how you can save the mode to a flow variable, along with a switch node that tests if that flow variable is not DAY.

That switch node can be used anywhere within the same flow (tab). If you test for the mode in multiple flows, you might be better off saving it as a global variable.

Screen Shot 2020-12-29 at 7.08.20 PM

Here's the code for this sequence:

[{"id":"4a2e77b6.1488b","type":"inject","z":"39ff9adc.6bcbfe","name":"","repeat":"","crontab":"","once":true,"onceDelay":"10","topic":"","payload":"10 secs","payloadType":"str","x":160,"y":100,"wires":[["27f5d0b3.c7df3"]]},{"id":"27f5d0b3.c7df3","type":"hubitat mode","z":"39ff9adc.6bcbfe","name":"","server":"a22e0ea9.276dc8","sendEvent":true,"x":310,"y":100,"wires":[["119b016b.beacb7"]]},{"id":"119b016b.beacb7","type":"change","z":"39ff9adc.6bcbfe","name":"flow.hubitat_mode","rules":[{"t":"set","p":"hubitat_mode","pt":"flow","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":485,"y":100,"wires":[[]]},{"id":"a31a2dd6.44a0a","type":"switch","z":"39ff9adc.6bcbfe","name":"mode != DAY","property":"hubitat_mode","propertyType":"flow","rules":[{"t":"neq","v":"DAY","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":310,"y":160,"wires":[[]]},{"id":"a22e0ea9.276dc8","type":"hubitat config","name":"HubitatM","usetls":false,"host":"192.168.1.46","port":"80","appId":"1522","nodeRedServer":"http://192.168.1.4:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false}]
5 Likes

Hi All, Happy New Year to all. Let's hope this one gets better and better.

I have been working on this flow for a number of weeks and it has been a one step forward, one back. Hoping one of you guru's can help me out with some challenges I have encountered. I am trying to create a scene to overcome some limitations or the Hubitat Scenes and a genetic RGBW driver.

For some unknown reason the RGBW downlights I am using need to be on prior to changing the colour. Conversely, I want to reset the colour back to white when I turn the scene off.

I need to be able to combine the Romantic On and Test2 switch (test2 status) into an anded output so both need to be ON for the flow to work. I have not been able to find a node to accomplish this outcome. On Romantic being turned off I need to reset the lamp to white and then turn the lamp off, but I am unsure how to execute the flow only once so it does not impact the normal operation of the lamp.

I am also unable to change the colour of the light despite following the node's syntax.

Flow:
[{"id":"702c0e64.df0a5","type":"tab","label":"Colour change test","disabled":false,"info":""},{"id":"1bf3ba49.504296","type":"switch","z":"702c0e64.df0a5","name":"test2 Light On/Off","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":120,"wires":[["e2f5a65f.943818","32f7959a.b950da"],["b3ffbf5b.2677f","f488f659.187268"]],"inputLabels":["Light on or off"],"outputLabels":["on","off"]},{"id":"31297b8c.3ca234","type":"hubitat device","z":"702c0e64.df0a5","deviceLabel":"Romantic","name":"","server":"ed7b94dd.a8e348","deviceId":"551","attribute":"switch","sendEvent":true,"x":120,"y":120,"wires":[["67ea406e.58f94"]]},{"id":"e2f5a65f.943818","type":"hubitat command","z":"702c0e64.df0a5","deviceLabel":"Test 2","name":"Make Blue","server":"ed7b94dd.a8e348","deviceId":"35","command":"setColor","commandArgs":"{"hue":64,"saturation":100,:"level":20}","x":910,"y":60,"wires":[[]]},{"id":"b3ffbf5b.2677f","type":"hubitat command","z":"702c0e64.df0a5","d":true,"deviceLabel":"Vicki’s Light ","name":"Turn test2 Light ON","server":"ed7b94dd.a8e348","deviceId":"35","command":"on","commandArgs":"","x":930,"y":180,"wires":[[]]},{"id":"67ea406e.58f94","type":"hubitat device","z":"702c0e64.df0a5","d":true,"deviceLabel":"Test2 ","name":"Test2 Light ON/OFF State","server":"ed7b94dd.a8e348","deviceId":"35","attribute":"switch","sendEvent":true,"x":350,"y":120,"wires":[["1bf3ba49.504296"]]},{"id":"32f7959a.b950da","type":"debug","z":"702c0e64.df0a5","name":"light on","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.value","targetType":"msg","statusVal":"","statusType":"auto","x":1040,"y":114,"wires":[]},{"id":"f488f659.187268","type":"debug","z":"702c0e64.df0a5","name":"light off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.value","targetType":"msg","statusVal":"","statusType":"auto","x":900,"y":280,"wires":[]},{"id":"76ed8070.ee354","type":"switch","z":"702c0e64.df0a5","name":"Romantic Off","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":130,"y":340,"wires":[["c83522b8.bad25"]],"inputLabels":["Light on or off"]},{"id":"c83522b8.bad25","type":"hubitat command","z":"702c0e64.df0a5","deviceLabel":"Test 2","name":"Make White","server":"ed7b94dd.a8e348","deviceId":"35","command":"setColor","commandArgs":"{"hue":0,"saturation":0,:"level":50}","x":570,"y":340,"wires":[["cdfc4557.26f398"]]},{"id":"cdfc4557.26f398","type":"hubitat command","z":"702c0e64.df0a5","deviceLabel":"Test2 ","name":"Turn test2 Light OFF","server":"ed7b94dd.a8e348","deviceId":"35","command":"off","commandArgs":"","x":920,"y":340,"wires":[[]]},{"id":"e4ddb66d.ab2298","type":"switch","z":"702c0e64.df0a5","name":"Romantic On","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":200,"wires":[[]],"inputLabels":["Light on or off"]},{"id":"ed7b94dd.a8e348","type":"hubitat config","name":"SCHOME","usetls":false,"host":"192.168.100.1xx","port":"80","appId":"430","nodeRedServer":"http://192.168.100.1xx","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false}]

Happy New Year to you as well, I too am hoping for the best. Some very promising stuff on the HA front on the horizon it seems at least.

Not sure exactly what your intended outcome is based on your post nor what your intended trigger(s) are, but the nodes I show below should help.

I would take a look at these nodes, very powerful and I have mainly used them for combining multiple motion sensors or presence sensors together.

1 Like

You COULD use something more exotic like ultimate boolean (I do in some scenarios), but for only 2 conditions you can just put them in series... Device node -> Switch that checks the result -> next device node -> switch to check the result

Something like:

If either condition can initiate the flow, then just do it twice, reversing the order of the device nodes.

Fro ultimate boolean it would look something more like this (this is just a test flow, but you can see the general layout - the TOP output from the Boolean Logic node is the AND condition):

2 Likes

Hi @cjkeenan, The trigger in the flow is supposed to be Romantic = ON, The problem I have is the flow is being triggered by the state of Test2 without the Romantic trigger being enabled. The state of the lamp is acting as the trigger no matter the state of the Romantic trigger.

The objective of the flow is on turning Romantic ON, I then want to evaluate the state of Test2 and based on the state either turn the lamp Blue or if it is OFF turn it on and make the lamp blue. In testing, when the state of Test2 changes the following nodes complete with the exception of the colour of the lamp.

The problem I have is the flow is being triggered by the state of Test2 without the Romantic trigger being enabled. The state of the lamp is acting as the trigger no matter the state of the Romantic trigger.

The trigger for the bottom flow is also Romantic and, is intended to revert the Test2 lamp to white then turn it off. I need this flow to either stop after 1 execution of not trigger during normal lamp usage.

Hope this makes more sense.

1 Like

Make sure that "Send Events" is not selected for Test2 device node.

4 Likes

This is another motion lighting example. Sometimes, I need to override my motion sequence such that the lights stay on for an extended period even if there is no motion. The most convenient override is to physically turn on the light switch, and that's what is done in the motion lighting sequence for my closet lighting shown below.

  1. The sequence is triggered by either the closet door being opened or the motion being detected within the closet.

  2. The sequence continues only if the flow variable "flow.closet_light" is true. This variable is set to false if the switch is turned on physically. Therefore, when the closet light switch is physically turned on, motion inactive and contact closed triggers cannot continue past the switch that checks flow.closet_light = true. So the lights stay on.

  3. flow.closet_light is set to true 30 seconds after the light turns off (giving time to exit the closet without triggering it again). Thus when the lights are turned off, the sequence is ready to function again purely based on motion & contact sensor status.

Hope someone else finds this useful. The JSON code is pasted below:

[{"id":"d7f7b2b8.fccee8","type":"hubitat device","z":"6ecfca6d.86e7cc","deviceLabel":"","name":"Contact - Closet Door","server":"a22e0ea9.276dc8","deviceId":"1974","attribute":"contact","sendEvent":true,"x":140,"y":400,"wires":[["1719a348.60b89d"]]},{"id":"1719a348.60b89d","type":"switch","z":"6ecfca6d.86e7cc","name":"closet_light = true","property":"closet_light","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":360,"wires":[["a72bce28.4de7a8"]]},{"id":"221c8697.f11162","type":"hubitat device","z":"6ecfca6d.86e7cc","deviceLabel":"","name":"Motion - Closet","server":"a22e0ea9.276dc8","deviceId":"1977","attribute":"motion","sendEvent":true,"x":160,"y":320,"wires":[["1719a348.60b89d"]]},{"id":"a72bce28.4de7a8","type":"switch","z":"6ecfca6d.86e7cc","name":"active|open / inactive|closed","property":"payload.value","propertyType":"msg","rules":[{"t":"regex","v":"active|open","vt":"str","case":false},{"t":"regex","v":"inactive|closed","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":2,"x":620,"y":360,"wires":[["3f415410.59ce8c"],["8d7185a4.742d7"]]},{"id":"3f415410.59ce8c","type":"change","z":"6ecfca6d.86e7cc","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":340,"wires":[["35d97ad8.ad1476"]]},{"id":"8d7185a4.742d7","type":"change","z":"6ecfca6d.86e7cc","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":380,"wires":[["35d97ad8.ad1476"]]},{"id":"35d97ad8.ad1476","type":"BooleanLogicUltimate","z":"6ecfca6d.86e7cc","name":"","filtertrue":"both","persist":true,"sInitializeWith":"false","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"2","topic":"motion","x":1000,"y":360,"wires":[[],["4eac0d5.4a8fb74"],[]]},{"id":"4eac0d5.4a8fb74","type":"rbe","z":"6ecfca6d.86e7cc","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1135,"y":360,"wires":[["6b8b9ff0.36f808"]],"l":false},{"id":"6b8b9ff0.36f808","type":"switch","z":"6ecfca6d.86e7cc","name":"true/false","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":1240,"y":360,"wires":[["56fb8108.df59f"],["6da3011d.9809e8"]]},{"id":"56fb8108.df59f","type":"change","z":"6ecfca6d.86e7cc","name":"stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1390,"y":340,"wires":[["475c7fa6.4c2178","e7538079.d26a68"]]},{"id":"6da3011d.9809e8","type":"change","z":"6ecfca6d.86e7cc","name":"go","rules":[{"t":"set","p":"payload","pt":"msg","to":"go","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1390,"y":380,"wires":[["475c7fa6.4c2178"]]},{"id":"475c7fa6.4c2178","type":"stoptimer-varidelay","z":"6ecfca6d.86e7cc","duration":"3","durationType":"num","units":"Minute","payloadtype":"num","payloadval":"0","name":"3 min","reporting":"last_minute_seconds","persist":false,"x":1530,"y":400,"wires":[["6845940d.67a83c"],[],[]]},{"id":"e7538079.d26a68","type":"switch","z":"6ecfca6d.86e7cc","name":"Hubitat Mode","property":"hubitat_mode","propertyType":"global","rules":[{"t":"eq","v":"Home","vt":"str"},{"t":"eq","v":"Sleep","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1560,"y":340,"wires":[["540c9c59.c31794"],["1da18444.f87ccc"]]},{"id":"6845940d.67a83c","type":"hubitat device","z":"6ecfca6d.86e7cc","deviceLabel":"Closet Light","name":"","server":"662851c4.3ccad","deviceId":"4197","attribute":"switch","sendEvent":false,"x":1690,"y":400,"wires":[["e2500b.fe977ff8"]]},{"id":"540c9c59.c31794","type":"change","z":"6ecfca6d.86e7cc","name":"100","rules":[{"t":"set","p":"arguments","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1730,"y":320,"wires":[["c2256e08.951668"]]},{"id":"1da18444.f87ccc","type":"change","z":"6ecfca6d.86e7cc","name":"10","rules":[{"t":"set","p":"arguments","pt":"msg","to":"10","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1730,"y":360,"wires":[["c2256e08.951668"]]},{"id":"e2500b.fe977ff8","type":"switch","z":"6ecfca6d.86e7cc","name":"on","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1850,"y":400,"wires":[["c8d5baf8.14098"]]},{"id":"c2256e08.951668","type":"hubitat device","z":"6ecfca6d.86e7cc","deviceLabel":"Closet Light","name":"","server":"662851c4.3ccad","deviceId":"4197","attribute":"switch","sendEvent":false,"x":1890,"y":340,"wires":[["3827fb5.ef95c04"]]},{"id":"c8d5baf8.14098","type":"hubitat command","z":"6ecfca6d.86e7cc","deviceLabel":"Closet Light","name":"","server":"662851c4.3ccad","deviceId":"4197","command":"off","commandArgs":"","x":2010,"y":400,"wires":[[]]},{"id":"3827fb5.ef95c04","type":"switch","z":"6ecfca6d.86e7cc","name":"off","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2050,"y":340,"wires":[["bebc68dd.c4708"]]},{"id":"bebc68dd.c4708","type":"hubitat command","z":"6ecfca6d.86e7cc","deviceLabel":"Closet Light","name":"","server":"662851c4.3ccad","deviceId":"4197","command":"setLevel","commandArgs":"","x":2210,"y":340,"wires":[[]]},{"id":"dc2eca4a.4d99e8","type":"hubitat device","z":"6ecfca6d.86e7cc","deviceLabel":"Closet Light","name":"","server":"662851c4.3ccad","deviceId":"4197","attribute":"","sendEvent":true,"x":190,"y":160,"wires":[["e0f84fd1.eab4","717db071.f77138"]]},{"id":"e0f84fd1.eab4","type":"switch","z":"6ecfca6d.86e7cc","name":"physical","property":"payload.type","propertyType":"msg","rules":[{"t":"eq","v":"physical","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":360,"y":140,"wires":[["b73477e2.45b0e"]]},{"id":"717db071.f77138","type":"switch","z":"6ecfca6d.86e7cc","name":"off","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":180,"wires":[["7dfa00e0.066128"]]},{"id":"b73477e2.45b0e","type":"change","z":"6ecfca6d.86e7cc","name":"closet_light false","rules":[{"t":"set","p":"closet_light","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":140,"wires":[[]]},{"id":"7dfa00e0.066128","type":"delay","z":"6ecfca6d.86e7cc","name":"30s","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":435,"y":180,"wires":[["66b62337.ad99dc"]],"l":false},{"id":"66b62337.ad99dc","type":"change","z":"6ecfca6d.86e7cc","name":"closet_light true","rules":[{"t":"set","p":"closet_light","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":180,"wires":[[]]},{"id":"57c6c9e5.9407e","type":"comment","z":"6ecfca6d.86e7cc","name":"Flow variable \"flow.closet_light\" is a Boolean that determines if the sequence runs or not","info":"","x":390,"y":80,"wires":[]},{"id":"410faece.8db968","type":"comment","z":"6ecfca6d.86e7cc","name":"Closet light turned on by the door opening or motion detected. Lights turn off only if the closet light switch is not physically turned on.","info":"","x":490,"y":260,"wires":[]},{"id":"a22e0ea9.276dc8","type":"hubitat config","name":"HubitatM","usetls":false,"host":"192.168.1.46","port":"80","appId":"1522","nodeRedServer":"http://192.168.1.4:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false},{"id":"662851c4.3ccad","type":"hubitat config","name":"HubitatS","usetls":false,"host":"192.168.1.36","port":"80","appId":"4489","nodeRedServer":"http://192.168.1.4:1880","webhookPath":"/hubitat/webhook2","autoRefresh":true,"useWebsocket":false}]
4 Likes

I was having trouble with a command node where the status kept displaying as "deviceID undefined". It took me the longest time to figure out that a device node upstream had the "send event" checked and every time the command node turned the switch on/off, the device node would send an event where the msg.deviceID was not defined! :man_facepalming:t2:

4 Likes

Thank you @aaiyar, that solved my issue. Now I just need to get the colour change step to work. I have followed the nodes sample syntax with no luck thus far.

1 Like

Hi All, with @aaiyar guidance I have my flow 90% working but, I am still struggling to get the colour of the lights to change. I am using the Hubitat "Command" node, configured as below and have entered the syntax as shown.

Blue = "hue":64,"saturation":100,"level":20 I have tried with and with out the {} brackets and get NO colour change. Any suggestions to what I have not got correct?

If you are passing it via "msg.command" and "msg.arguments" it should look something like this:

This works for me... note the arguments is a "string" NOT a JSON value.

This hard-coded version in the command node works for me as well:

2 Likes

I just use "setHue"

3 Likes

This works for me with Inovelli LEDs. I was testing this using an inject node to send msg.arguements to the Command node (I left the "Arguments" section blank)

RED:


BLUE:

3 Likes

Thanks heaps for the point in the right direction with option and examples. Hope to have time tomorrow to get back in the test lab.

1 Like

Thank you sir for the pointers with option and examples. Hope to have time tomorrow to get back in the test lab.