Node-Red Flow Samples/Sharing

For people posting flows - use the Preformatted Text (</>) option to avoid formatting errors.

2 Likes

fixed in original post with preformatted text as recommended.

2 Likes

Thank you for letting us know. I will update post 1 (and any of mine) to include this as well!

Thanks again for this, for HE devices this works :wink: I think my issue is, I then have deCONZ devices and Hue. But I'll look at modifying the payload sections. Is there anyway to add to them to keep it in one node, do you think?

Hue is using true and false already as is deCONZ, it appears only to be HE which is passing a payload.value of on/off etc.

Cheers
Roy

You should be able to do hue and deCONZ would need their own "switch to Bool" block that attaches to the ultimate Boolean block.

2 Likes

Sensor offline example, sends a notice every 24 hours once offline.

flow
[{"id":"b8b8ccdf.bcde2","type":"pushover api","z":"43fe1c67.5ff464","keys":"2a52b42c.7e9f0c","title":"","name":"Push: No Response","x":960,"y":460,"wires":[]},{"id":"e24e0c27.56a52","type":"string","z":"43fe1c67.5ff464","name":"","methods":[{"name":"append","params":[{"type":"str","value":" has not responded in 24 Hours!"}]}],"prop":"topic","propout":"payload","object":"msg","objectout":"msg","x":790,"y":460,"wires":[["b8b8ccdf.bcde2"]]},{"id":"4244a3fe.9aa5bc","type":"stoptimer-varidelay","z":"43fe1c67.5ff464","duration":"24","durationType":"num","units":"Hour","payloadtype":"num","payloadval":"0","name":"","reporting":"last_minute_seconds","x":480,"y":460,"wires":[["e24e0c27.56a52","d9328383.536e3"],[],[]]},{"id":"d9328383.536e3","type":"hubitat device","z":"43fe1c67.5ff464","name":"Laundry Room: House Motion","server":"f17566a9.c052b8","deviceId":"2586","attribute":"","sendEvent":true,"x":190,"y":459,"wires":[["4244a3fe.9aa5bc"]]},{"id":"2a52b42c.7e9f0c","type":"pushover-keys","z":"","name":""},{"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,"useWebsocket":false}]
3 Likes

Is your Simple Button method here in this topic as well??

Has anyone used the "Projects" feature inside NR for sharing? It seems to be Git based and includes dependencies when sharing along with version control.

going to look into that this weekend!

Simple button toggle of a switch

Flow
[{"id":"159b72c8.b9b74d","type":"hubitat device","z":"5793d225.35133c","name":"Craig is Up button","server":"f17566a9.c052b8","deviceId":"3066","attribute":"pushed","sendEvent":true,"x":150,"y":980,"wires":[["a7d20c38.8fb72"]]},{"id":"a7d20c38.8fb72","type":"hubitat device","z":"5793d225.35133c","name":"Craig is Up","server":"f17566a9.c052b8","deviceId":"3002","attribute":"switch","sendEvent":false,"x":350,"y":980,"wires":[["b1ee3b98.867f38"]]},{"id":"b1ee3b98.867f38","type":"switch","z":"5793d225.35133c","name":"","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"neq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":500,"y":980,"wires":[["35e26801.810fd8"],["a6a7795.a1a4c88"]]},{"id":"35e26801.810fd8","type":"hubitat command","z":"5793d225.35133c","name":"Craig is Up","server":"f17566a9.c052b8","deviceId":"3002","command":"off","commandArgs":"","x":670,"y":960,"wires":[[]]},{"id":"a6a7795.a1a4c88","type":"hubitat command","z":"5793d225.35133c","name":"Craig is Up","server":"f17566a9.c052b8","deviceId":"3002","command":"on","commandArgs":"","x":670,"y":1000,"wires":[[]]},{"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,"useWebsocket":false}]

Quick question; I'm trying to wrap my head around this and the epiphany just hasn't hit yet. Very new and still learning. I need lighting triggered by motion, but I only want the flow to fire if the the target sensor is triggered and the hub is in a specific mode. I've gone through the flows in the post and haven't quite seen anything that is giving me the "ah ha" moment.

As an example, I've got 4 modes I want a flow to fire for (Morning, Day, Evening, Night) so that it is only firing if someone is actually home, from one motion sensor. I can get the thing to work if I just stick a mode node and switch to determine the mode, but I obviously don't want the lights turning on every time the mode changes to one of the allowed modes.


I'm sure the solution is easy, but for some reason I'm having trouble wrapping my head around it. Might be 36 hours of work in 3 days catching up...but it just isn't sticking.

I would suggest making Mode into a flow or global variable and then using it in a switch node. For example, in the sequence below, the closet light is turned on to 100% in home mode, or 10% in sleep mode. It is not turned on in Away mode unless another variable (maid switch) is "on".

3 Likes

You might be overcomplicating with the Boolean Logic node. Just put the mode check inline.

You also want to make sure that the Send events box in the mode node is deslected:

screenshot-10.10.10.228-1880-2020.07.24-22-40-20

Summary

[{"id":"951071b7.73859","type":"hubitat device","z":"bf2927e5.5af798","name":"Basement Motion Stairs","server":"2c08a6b7.b90c4a","deviceId":"546","attribute":"motion","sendEvent":true,"x":180,"y":1340,"wires":[["40335305.2b438c"]]},{"id":"d3ef4aeb.1af928","type":"hubitat mode","z":"bf2927e5.5af798","name":"","server":"2c08a6b7.b90c4a","sendEvent":false,"x":590,"y":1340,"wires":[["d757b69f.c68a68"]]},{"id":"d757b69f.c68a68","type":"switch","z":"bf2927e5.5af798","name":"Away?","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"Away","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":730,"y":1340,"wires":[[],[]]},{"id":"40335305.2b438c","type":"switch","z":"bf2927e5.5af798","name":"Active/Inactive?","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":410,"y":1340,"wires":[["d3ef4aeb.1af928"],[]]},{"id":"2c08a6b7.b90c4a","type":"hubitat config","z":"","name":"Hubitat","usetls":false,"host":"10.10.10.24","port":"80","appId":"32","nodeRedServer":"http://10.10.10.228:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false}]

3 Likes

I do it this way as well... mostly just to save myself some time adding the mode node a million times. Also, I store the previous mode in a global as well for use in some situations.

1 Like

Same here ...

Motion Lighting is one of those things many of us use over and over. So I created a 'template' on my 1st page of Node-Red. I can just copy/paste the nodes anytime I need them. Because it's a template, I also tried to add options.. so that I can just delete items vs adding them in. This one has both Mode and time-of-day..

I detailed a large portion of this in my video for Node-Red

Flow

[{"id":"c17b4e60.1855e8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"4ac9a4f7.b6b094","type":"hubitat device","z":"c17b4e60.1855e8","name":"MotionSensor","server":"4681f676.154b78","deviceId":"","attribute":"","sendEvent":true,"x":300,"y":320,"wires":[["2d67ce4e.fe0d8a","96d7be23.de1ed8"]]},{"id":"907ce4f9.26f49","type":"switch","z":"c17b4e60.1855e8","name":"Active/Inactive","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":546,"y":391,"wires":[["c065ee86.379aa8"],["1433aecc.60b411"]]},{"id":"ca479ee8.17a6","type":"hubitat command","z":"c17b4e60.1855e8","name":"Office Ceiling Light ON","server":"4681f676.154b78","deviceId":"","command":"","commandArgs":"","x":1185,"y":377,"wires":[["fa994e7.641dc3"]]},{"id":"bcc35300.a236d","type":"hubitat command","z":"c17b4e60.1855e8","name":"Office Ceiling Light OFF","server":"4681f676.154b78","deviceId":"","command":"","commandArgs":"","x":1174,"y":501,"wires":[["fa994e7.641dc3"]]},{"id":"69086cbb.978a64","type":"hubitat mode","z":"c17b4e60.1855e8","name":"Mode Is","server":"4681f676.154b78","sendEvent":true,"x":328,"y":120,"wires":[["396af26d.353eae"]]},{"id":"2d67ce4e.fe0d8a","type":"switch","z":"c17b4e60.1855e8","name":"Mode Switch","property":"currentMode","propertyType":"global","rules":[{"t":"eq","v":"Day","vt":"str"},{"t":"eq","v":"Evening","vt":"str"},{"t":"eq","v":"Night","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":270,"y":486,"wires":[["907ce4f9.26f49"],["907ce4f9.26f49"],["907ce4f9.26f49"],["bcc35300.a236d"]]},{"id":"4ef189ac.1550f","type":"change","z":"c17b4e60.1855e8","name":"saveCurrentMode","rules":[{"t":"set","p":"currentMode","pt":"global","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":673,"y":120,"wires":[["a4b0dca3.fa323"]]},{"id":"396af26d.353eae","type":"rbe","z":"c17b4e60.1855e8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":493,"y":120,"wires":[["4ef189ac.1550f"]]},{"id":"a4b0dca3.fa323","type":"debug","z":"c17b4e60.1855e8","d":true,"name":"SavedMode IS","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1298,"y":124,"wires":[]},{"id":"71a8a072.d0bcc","type":"inject","z":"c17b4e60.1855e8","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":130,"y":320,"wires":[["4ac9a4f7.b6b094"]]},{"id":"96d7be23.de1ed8","type":"debug","z":"c17b4e60.1855e8","d":true,"name":"Motion IS","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1330,"y":320,"wires":[]},{"id":"bd451cc7.0b89e","type":"comment","z":"c17b4e60.1855e8","name":"set a global mode variable, global.currentMode, useful everywhere in this Flow.","info":"","x":358,"y":58,"wires":[]},{"id":"161bd6c6.6c2dc9","type":"comment","z":"c17b4e60.1855e8","name":"sample of Motion by Mode","info":"","x":188,"y":261,"wires":[]},{"id":"c30c9e14.48887","type":"inject","z":"c17b4e60.1855e8","name":"","repeat":"","crontab":"","once":true,"onceDelay":"0.1","topic":"","payload":"Started!","payloadType":"str","x":138,"y":121,"wires":[["69086cbb.978a64"]]},{"id":"c065ee86.379aa8","type":"change","z":"c17b4e60.1855e8","name":"Cancelable","rules":[{"t":"delete","p":"payload.value","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":747,"y":384,"wires":[["f149ae45.565e","1433aecc.60b411"]]},{"id":"f149ae45.565e","type":"time-range-switch","z":"c17b4e60.1855e8","name":"Dawn-8PM","lat":"37.3230","lon":"-122.0322","startTime":"sunrise","endTime":"20:00","startOffset":0,"endOffset":0,"x":922,"y":384,"wires":[["ca479ee8.17a6"],["e100ee34.01d4e"]]},{"id":"e100ee34.01d4e","type":"hubitat command","z":"c17b4e60.1855e8","name":"Office Ceiling Light 10%","server":"4681f676.154b78","deviceId":"","command":"","commandArgs":"10","x":1175,"y":438,"wires":[[]]},{"id":"fa994e7.641dc3","type":"debug","z":"c17b4e60.1855e8","d":true,"name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1448,"y":438,"wires":[]},{"id":"1433aecc.60b411","type":"stoptimer-varidelay","z":"c17b4e60.1855e8","duration":"15","durationType":"num","units":"Second","payloadtype":"num","payloadval":"0","name":"","reporting":"none","x":908,"y":458,"wires":[["bcc35300.a236d"],[],[]]},{"id":"4681f676.154b78","type":"hubitat config","z":"","name":"TEST Hub","usetls":false,"host":"192.168.1.100","port":"80","appId":"33","nodeRedServer":"http://raspberrypi2.aclysnet.com:1880","webhookPath":"/hubitat/webhook_","autoRefresh":true,"useWebsocket":false}]

6 Likes

got projects 80% setup
stuck on getting connect to github working

Thanks guys; I'd forgotten I had saved the mode in a global variable. Figured I had to be overcomplicating it. Switched the flows I had to a pi from synology docker and missed setting up the global variable again. Works like a charm now.

I followed this thread and was able to successfully push.

1 Like

Here is my circadian lighting flow. It uses the circadian-light node, which will report the position of the sun in the sky from 0-100% and converts that percent into a specified range. I’m using two different ranges for different bulbs. one that goes from 2200-5000 and one that goes from 2700-5000 and back down again. it then puts this info into a global variable in node red and into a rule-machine-connector on two different hubs. It also graphs it on the node red dashboard.

works really well, better than my hubitat rules did since it is now using astronomical noon for the peak, which is about 2pm where I live this time of year.

Flow
[{"id":"e9166966.9cbf1","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"2bf3bbed.b3c15c","type":"debug","z":"e9166966.9cbf1","name":"2700","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":34,"wires":[]},{"id":"30a25f07.ef00a8","type":"Circadian Light","z":"e9166966.9cbf1","lat":"39.878050","lon":"-86.053259","period":"1","topic":"","name":"","x":128,"y":221,"wires":[["dc54d300.47f4","2e2d183a.df8ad"]]},{"id":"dc54d300.47f4","type":"range","z":"e9166966.9cbf1","minin":"0","maxin":"100","minout":"2700","maxout":"5000","action":"clamp","round":true,"property":"payload.percent","name":"","x":342,"y":187,"wires":[["beb9e90c.e8fcd"]]},{"id":"beb9e90c.e8fcd","type":"change","z":"e9166966.9cbf1","name":"global.circadian2700","rules":[{"t":"set","p":"circadian2700","pt":"global","to":"payload.percent","tot":"msg"},{"t":"set","p":"arguments","pt":"msg","to":"payload.percent","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload.percent","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"2700","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":559,"y":187,"wires":[["2bf3bbed.b3c15c","904442df.989218","181a2d9e.9a8732","a9bc4a50.9a95f8"]]},{"id":"2e2d183a.df8ad","type":"range","z":"e9166966.9cbf1","minin":"0","maxin":"100","minout":"2200","maxout":"5000","action":"clamp","round":true,"property":"payload.percent","name":"","x":342,"y":255,"wires":[["170a69db.2f54be"]]},{"id":"170a69db.2f54be","type":"change","z":"e9166966.9cbf1","name":"global.circadian2200","rules":[{"t":"set","p":"circadian2200","pt":"global","to":"payload.percent","tot":"msg"},{"t":"set","p":"arguments","pt":"msg","to":"payload.percent","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload.percent","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"2200","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":559,"y":255,"wires":[["9fdfa2a5.fd4b8","dbe4eecc.39b2a8","bc620dd.9acd5f","181a2d9e.9a8732"]]},{"id":"9fdfa2a5.fd4b8","type":"debug","z":"e9166966.9cbf1","name":"2200","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":408,"wires":[]},{"id":"dbe4eecc.39b2a8","type":"hubitat command","z":"e9166966.9cbf1","name":"North colorTemp","server":"319c6842.9a57d8","deviceId":"2066","command":"setColorTemperature","commandArgs":"","x":838,"y":255,"wires":[[]]},{"id":"904442df.989218","type":"hubitat command","z":"e9166966.9cbf1","name":"North colorTemp2700","server":"319c6842.9a57d8","deviceId":"2065","command":"setColorTemperature","commandArgs":"","x":848,"y":187,"wires":[[]]},{"id":"181a2d9e.9a8732","type":"ui_chart","z":"e9166966.9cbf1","name":"","group":"76293fc1.a8af3","order":0,"width":0,"height":0,"label":"Color Temperature","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"2000","ymax":"5200","removeOlder":"3","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":838,"y":221,"wires":[[]]},{"id":"f1a62368.faa898","type":"comment","z":"e9166966.9cbf1","name":"Circadian Level","info":"","x":115,"y":68,"wires":[]},{"id":"a9bc4a50.9a95f8","type":"hubitat command","z":"e9166966.9cbf1","name":"South colorTemp2700 circadian","server":"cd816c39.6978b","deviceId":"2241","command":"setColorTemperature","commandArgs":"","x":878,"y":153,"wires":[[]]},{"id":"bc620dd.9acd5f","type":"hubitat command","z":"e9166966.9cbf1","name":"South colorTemp circadian","server":"cd816c39.6978b","deviceId":"2240","command":"setColorTemperature","commandArgs":"","x":868,"y":289,"wires":[[]]},{"id":"319c6842.9a57d8","type":"hubitat config","z":"","name":"Hubitat North","usetls":false,"host":"hubnorth.local","port":"80","appId":"1685","nodeRedServer":"http://nodered.local:1880/","webhookPath":"/hubitat/webhook_","autoRefresh":true,"useWebsocket":false},{"id":"76293fc1.a8af3","type":"ui_group","z":"","name":"Default","tab":"f61e3daf.afe048","order":1,"disp":true,"width":"6","collapse":false},{"id":"cd816c39.6978b","type":"hubitat config","z":"","name":"Hubitat South","usetls":false,"host":"hubsouth.local","port":"80","appId":"2064","nodeRedServer":"http://nodered.local:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false},{"id":"f61e3daf.afe048","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
2 Likes