Node-Red Flow Samples/Sharing

That said, mine is looking at .co.uk :expressionless: We're a smaller fix maybe :wink:

If your Alexa isn't working yet, I had luck with manually refreshing the cookie and restarting all flows.

1 Like

It seems to be working now. :crossed_fingers:

2 Likes

Dammit mines gone again. My node to obtain the "Device Activity" is outputting nothing at all when I speak to any device. So without that, I cant trigger my flows. It was working, but now gone again.

Maybe this is the cause? I don't remember the node showing grey?

image

Updated They are clearly still having issues, its up one minute, down the next. Hope it levels out at some point. :expressionless:

I always remember it being grey. Once it "hears" a response it turns green and says event fired but AFAIK the listening state has always been grey.

3 Likes

In case anyone is looking for a way to maintain log data outside of HE....

2 Likes

In case someone is looking to capture and restore the state of an RGBW device (bulb, light strip etc), here's a flow that does it without using any function nodes.

RGBW device capture/restore
[{"id":"bd43a28e31299b4e","type":"join","z":"91a3133eb0da7fd1","name":"json join","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":900,"y":460,"wires":[["1a20d06b3e2b00de"]]},{"id":"33c87a8fe098f670","type":"change","z":"91a3133eb0da7fd1","name":"hue","rules":[{"t":"set","p":"topic","pt":"msg","to":"hue","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"nightstand_hue","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":420,"wires":[["bd43a28e31299b4e"]]},{"id":"9e9ff88f8850ec97","type":"delay","z":"91a3133eb0da7fd1","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":775,"y":460,"wires":[["bd43a28e31299b4e"]],"l":false},{"id":"882f9aa4ccd461d8","type":"delay","z":"91a3133eb0da7fd1","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":775,"y":500,"wires":[["bd43a28e31299b4e"]],"l":false},{"id":"1a20d06b3e2b00de","type":"change","z":"91a3133eb0da7fd1","name":"setColor","rules":[{"t":"set","p":"command","pt":"msg","to":"setColor","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"$string(payload)","tot":"jsonata"},{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":460,"wires":[["752c91c1499e6c0d"]]},{"id":"ebaff8760d384dad","type":"inject","z":"91a3133eb0da7fd1","name":"capture","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":190,"y":220,"wires":[["d493e99a42f7e962"]]},{"id":"b844cd04e44b82c2","type":"change","z":"91a3133eb0da7fd1","name":"sat","rules":[{"t":"set","p":"topic","pt":"msg","to":"saturation","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"nightstand_sat","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":460,"wires":[["9e9ff88f8850ec97"]]},{"id":"a068ec247987c0a3","type":"change","z":"91a3133eb0da7fd1","name":"lvl","rules":[{"t":"set","p":"topic","pt":"msg","to":"level","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"nightstand_level","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":500,"wires":[["882f9aa4ccd461d8"]]},{"id":"752c91c1499e6c0d","type":"hubitat command","z":"91a3133eb0da7fd1","deviceLabel":"Nightstand","name":"","server":"a22e0ea9.276dc8","deviceId":"1848","command":"","commandArgs":"","x":1230,"y":400,"wires":[[]]},{"id":"34509478991b20e0","type":"change","z":"91a3133eb0da7fd1","name":"setCT","rules":[{"t":"set","p":"command","pt":"msg","to":"setColorTemperature","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"$string(payload)","tot":"jsonata"},{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1070,"y":340,"wires":[["752c91c1499e6c0d"]]},{"id":"0b1d78c881efdaa9","type":"join","z":"91a3133eb0da7fd1","name":"string join","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":900,"y":340,"wires":[["34509478991b20e0"]]},{"id":"3a6e9026443d9a4b","type":"change","z":"91a3133eb0da7fd1","name":"CT","rules":[{"t":"set","p":"topic","pt":"msg","to":"CT","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"nightstand_ct","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":300,"wires":[["0b1d78c881efdaa9"]]},{"id":"fa09d8b57c2cae11","type":"delay","z":"91a3133eb0da7fd1","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":775,"y":340,"wires":[["0b1d78c881efdaa9"]],"l":false},{"id":"a172a41701dca630","type":"delay","z":"91a3133eb0da7fd1","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":775,"y":380,"wires":[["0b1d78c881efdaa9"]],"l":false},{"id":"a29e26c0b164ffaa","type":"inject","z":"91a3133eb0da7fd1","name":"restore","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":190,"y":400,"wires":[["d7d131b5316c0ae1"]]},{"id":"6c7591caf5a8ae1b","type":"change","z":"91a3133eb0da7fd1","name":"lvl","rules":[{"t":"set","p":"topic","pt":"msg","to":"level","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"nightstand_level","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":340,"wires":[["fa09d8b57c2cae11"]]},{"id":"adc81e31e3a921e5","type":"change","z":"91a3133eb0da7fd1","name":"time","rules":[{"t":"set","p":"topic","pt":"msg","to":"time","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":380,"wires":[["a172a41701dca630"]]},{"id":"d493e99a42f7e962","type":"hubitat device","z":"91a3133eb0da7fd1","deviceLabel":"Nightstand","name":"","server":"a22e0ea9.276dc8","deviceId":"1848","attribute":"","sendEvent":false,"x":350,"y":220,"wires":[["335faf55a5b1b2e2"]]},{"id":"335faf55a5b1b2e2","type":"change","z":"91a3133eb0da7fd1","name":"nightstand","rules":[{"t":"set","p":"nightstand_switch","pt":"flow","to":"payload.switch.value","tot":"msg"},{"t":"set","p":"nightstand_colorMode","pt":"flow","to":"payload.colorMode.value","tot":"msg"},{"t":"set","p":"nightstand_ct","pt":"flow","to":"payload.colorTemperature.value","tot":"msg"},{"t":"set","p":"nightstand_hue","pt":"flow","to":"payload.hue.value","tot":"msg"},{"t":"set","p":"nightstand_sat","pt":"flow","to":"payload.saturation.value","tot":"msg"},{"t":"set","p":"nightstand_level","pt":"flow","to":"payload.level.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":220,"wires":[[]]},{"id":"d7d131b5316c0ae1","type":"switch","z":"91a3133eb0da7fd1","name":"on?","property":"nightstand_switch","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":330,"y":400,"wires":[["ae9b298edeef2436"]]},{"id":"ae9b298edeef2436","type":"switch","z":"91a3133eb0da7fd1","name":"CT or RGB","property":"nightstand_colorMode","propertyType":"flow","rules":[{"t":"eq","v":"CT","vt":"str"},{"t":"eq","v":"RGB","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":400,"wires":[["3a6e9026443d9a4b","6c7591caf5a8ae1b","adc81e31e3a921e5"],["33c87a8fe098f670","b844cd04e44b82c2","a068ec247987c0a3"]]},{"id":"de897648d00e3312","type":"comment","z":"91a3133eb0da7fd1","name":"CAPTURE","info":"","x":180,"y":160,"wires":[]},{"id":"88864d62853db2d2","type":"comment","z":"91a3133eb0da7fd1","name":"RESTORE","info":"","x":180,"y":340,"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,"colorEnabled":true,"color":"#5dd049"}]
6 Likes

Title: Christmas Lights

Summary: Control Christmas lights, based on hub mode and enablement switches.

Description:

This is the flow that controls my Christmas lights, based on hub mode. To start with, I use five modes for my hub:

  • Late Night - midnight to 5:00AM
  • Early Morning - 5:00AM to 7:00AM or Sunrise (whichever is later)
  • Day - 7:00AM or Sunrise (whichever is later) to Sunset or 6:00PM (whichever is earlier)
  • Evening - Sunset or 6:00PM (whichever is earlier) to 9:00PM
  • Night - 9:00PM to Midnight

Additionally, I'm on the lazy side. I want to be able to tap a few switches on my dashboard and enable or disable the rule, so I have three enabler switches:

  • Enable Christmas Lights - Overall enabler switch
  • Enable Inside Christmas Lights All Day (Weekday) - Leave inside lights on all day Mon.-Fri.
  • Enable Inside Christmas Lights All Day (Weekend) - Leave inside lights on all day on Sat./Sun.

Flow:

Code
[{"id":"2f63e299838a554f","type":"tab","label":"Christmas Lights","disabled":false,"info":"","env":[]},{"id":"4f681d70b6fedee7","type":"hubitat mode","z":"2f63e299838a554f","name":"","server":"7655a118644027a5","sendEvent":true,"x":270,"y":320,"wires":[["3fbf334427cf954f"]]},{"id":"3fbf334427cf954f","type":"switch","z":"2f63e299838a554f","name":"Mode is","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"Late Night","vt":"str"},{"t":"eq","v":"Early Morning","vt":"str"},{"t":"eq","v":"Day","vt":"str"},{"t":"eq","v":"Evening","vt":"str"},{"t":"eq","v":"Night","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":420,"y":320,"wires":[["61f8b8908e56522a","9c2d1e4a497ec98b"],["16d5754d0bc20d4a","dc196fca301b94e6"],["61f8b8908e56522a","c8bc9f173e6b2b4f"],["16d5754d0bc20d4a","dc196fca301b94e6"],["16d5754d0bc20d4a","dc196fca301b94e6"]]},{"id":"a4b0bed5c8fe96f3","type":"hubitat command","z":"2f63e299838a554f","deviceLabel":"Inside Christmas Lights","name":"Turn on Inside Christmas Lights","server":"7655a118644027a5","deviceId":"45","command":"on","commandArgs":"","x":1230,"y":80,"wires":[["8be708066b4ff70f"]]},{"id":"6dcef8a94c272a92","type":"hubitat command","z":"2f63e299838a554f","deviceLabel":"Inside Christmas Lights","name":"Turn off Inside Christmas Lights","server":"7655a118644027a5","deviceId":"45","command":"off","commandArgs":"","x":1230,"y":240,"wires":[["8be708066b4ff70f"]]},{"id":"24ee5de59b1db25a","type":"hubitat command","z":"2f63e299838a554f","deviceLabel":"Inside Christmas Lights","name":"Turn on Outside Christmas Lights","server":"7655a118644027a5","deviceId":"48","command":"on","commandArgs":"","x":1240,"y":820,"wires":[["8be708066b4ff70f"]]},{"id":"d0e4a2640bb7792a","type":"hubitat command","z":"2f63e299838a554f","deviceLabel":"Inside Christmas Lights","name":"Turn off Outside Christmas Lights","server":"7655a118644027a5","deviceId":"48","command":"off","commandArgs":"","x":1240,"y":980,"wires":[["8be708066b4ff70f"]]},{"id":"16d5754d0bc20d4a","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Enable Christmas Lights","name":"","server":"7655a118644027a5","deviceId":"40","attribute":"switch","sendEvent":false,"x":730,"y":820,"wires":[["d7305ada73f9043c"]]},{"id":"d7305ada73f9043c","type":"switch","z":"2f63e299838a554f","name":"Is on","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":950,"y":820,"wires":[["86d3469488640d27"],["8be708066b4ff70f"]]},{"id":"61f8b8908e56522a","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Outside Christmas Lights","name":"","server":"7655a118644027a5","deviceId":"48","attribute":"switch","sendEvent":false,"x":730,"y":980,"wires":[["8410b820258d50b3"]]},{"id":"8410b820258d50b3","type":"switch","z":"2f63e299838a554f","name":"Is on","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":950,"y":980,"wires":[["d0e4a2640bb7792a"],["8be708066b4ff70f"]]},{"id":"8be708066b4ff70f","type":"debug","z":"2f63e299838a554f","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1750,"y":340,"wires":[]},{"id":"86d3469488640d27","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Outside Christmas Lights","name":"","server":"7655a118644027a5","deviceId":"48","attribute":"switch","sendEvent":false,"x":730,"y":900,"wires":[["4a0903f5dd841a80"]]},{"id":"4a0903f5dd841a80","type":"switch","z":"2f63e299838a554f","name":"Is on","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":950,"y":900,"wires":[["8be708066b4ff70f"],["24ee5de59b1db25a"]]},{"id":"dc196fca301b94e6","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Enable Christmas Lights","name":"","server":"7655a118644027a5","deviceId":"40","attribute":"switch","sendEvent":false,"x":730,"y":80,"wires":[["f740e1e3901b2036"]]},{"id":"f740e1e3901b2036","type":"switch","z":"2f63e299838a554f","name":"Is on","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":950,"y":80,"wires":[["1eea891d1bf346b2"],["8be708066b4ff70f"]]},{"id":"1eea891d1bf346b2","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Inside Christmas Lights","name":"","server":"7655a118644027a5","deviceId":"45","attribute":"switch","sendEvent":false,"x":730,"y":160,"wires":[["c8010e485999bddf"]]},{"id":"c8010e485999bddf","type":"switch","z":"2f63e299838a554f","name":"Is on","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":950,"y":160,"wires":[["8be708066b4ff70f"],["a4b0bed5c8fe96f3"]]},{"id":"9c2d1e4a497ec98b","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Inside Christmas Lights","name":"","server":"7655a118644027a5","deviceId":"45","attribute":"switch","sendEvent":false,"x":730,"y":240,"wires":[["f9ef51b0b19f1de8"]]},{"id":"f9ef51b0b19f1de8","type":"switch","z":"2f63e299838a554f","name":"Is on","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":950,"y":240,"wires":[["6dcef8a94c272a92"],["8be708066b4ff70f"]]},{"id":"301fced593fda3ae","type":"switch","z":"2f63e299838a554f","name":"is on","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":350,"y":440,"wires":[["4f681d70b6fedee7"],["61f8b8908e56522a","9c2d1e4a497ec98b"]]},{"id":"8d2dcaddd07ea59e","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Enable Christmas Lights","name":"","server":"7655a118644027a5","deviceId":"40","attribute":"switch","sendEvent":true,"x":150,"y":440,"wires":[["301fced593fda3ae"]]},{"id":"3a61a6dcdd058301","type":"comment","z":"2f63e299838a554f","name":"Turn lights on/off as mode changes or enable switch status changes","info":"","x":280,"y":240,"wires":[]},{"id":"26cec17f6ffb592f","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Enable Inside Christmas Lights All Day (Weekday)","name":"","server":"7655a118644027a5","deviceId":"84","attribute":"switch","sendEvent":true,"x":230,"y":540,"wires":[["4f681d70b6fedee7"]]},{"id":"d7e1f0f494661021","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Enable Inside Christmas Lights All Day (Weekend)","name":"","server":"7655a118644027a5","deviceId":"91","attribute":"switch","sendEvent":true,"x":230,"y":600,"wires":[["4f681d70b6fedee7"]]},{"id":"c8bc9f173e6b2b4f","type":"simpletime","z":"2f63e299838a554f","name":"Add timestamp","mydate":false,"myymd":false,"myyear":false,"mymonth":false,"mymonthn":false,"mydom":false,"mydoy":false,"myday":false,"myhourpm":false,"myhour":false,"mytime":false,"mytimes":false,"myminute":false,"myminutes":false,"mysecond":false,"mymillis":false,"myepoch":false,"myrawdate":true,"mypm":false,"x":700,"y":440,"wires":[["ea6e44527d57097b"]]},{"id":"ea6e44527d57097b","type":"moment","z":"2f63e299838a554f","name":"Set weekday","topic":"","input":"myrawdate","inputType":"msg","inTz":"ETC/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd","locale":"en-US","output":"payload.weekday","outputType":"msg","outTz":"America/Chicago","x":890,"y":440,"wires":[["7ffc4495c09c4ca4"]]},{"id":"7ffc4495c09c4ca4","type":"switch","z":"2f63e299838a554f","name":"Day is","property":"payload.weekday","propertyType":"msg","rules":[{"t":"eq","v":"Sun","vt":"str"},{"t":"eq","v":"Mon","vt":"str"},{"t":"eq","v":"Tue","vt":"str"},{"t":"eq","v":"Wed","vt":"str"},{"t":"eq","v":"Thu","vt":"str"},{"t":"eq","v":"Fri","vt":"str"},{"t":"eq","v":"Sat","vt":"str"}],"checkall":"true","repair":false,"outputs":7,"x":710,"y":520,"wires":[["b3091cc0736c1520"],["77fc5085128131dc"],["77fc5085128131dc"],["77fc5085128131dc"],["77fc5085128131dc"],["77fc5085128131dc"],["b3091cc0736c1520"]]},{"id":"b3091cc0736c1520","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Enable Inside Christmas Lights All Day (Weekend)","name":"","server":"7655a118644027a5","deviceId":"91","attribute":"switch","sendEvent":false,"x":1010,"y":560,"wires":[["02710a0ca65eb28c"]]},{"id":"77fc5085128131dc","type":"hubitat device","z":"2f63e299838a554f","deviceLabel":"Enable Inside Christmas Lights All Day (Weekday)","name":"","server":"7655a118644027a5","deviceId":"84","attribute":"switch","sendEvent":false,"x":1010,"y":500,"wires":[["02710a0ca65eb28c"]]},{"id":"02710a0ca65eb28c","type":"switch","z":"2f63e299838a554f","name":"Is on","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":1310,"y":520,"wires":[["dc196fca301b94e6"],["9c2d1e4a497ec98b"]]},{"id":"29106bb5a68a830a","type":"comment","z":"2f63e299838a554f","name":"Leave inside lights on all day, if enabled","info":"","x":770,"y":380,"wires":[]},{"id":"7655a118644027a5","type":"hubitat config","name":"Home","usetls":false,"host":"172.27.201.5","port":"80","appId":"397","nodeRedServer":"http://172.27.201.1:1880","webhookPath":"/hubitat/webhook_","autoRefresh":true,"useWebsocket":false,"colorEnabled":false,"color":"#ace043"}]
5 Likes

Is there an attribute for either the Inovelli Red Switch or the GE/Jasco Z-wave smart switch that distinguishes when a light is turned on manually versus an automation?

What I want to do is when an automation turns off a light but I want it on for the time being, I'd like to manually switch it on and not have the automation turning it off again.

Thanks,

For the GE/Jasco, I use the "Type" attribute (physical/digital) to distinguish manual/automation. Not sure about Inovelli

2 Likes

I see the type in the events log for the switch but not as an option in Node-Red.

Screen Shot 2021-12-05 at 7.40.25 AM

I am using the GE device Type.

@douglaspitman

Here's how you do it:

  1. Evaluate on "switch"
  2. if "msg.payload.value == on", then evaluate if "msg.payload.type == physical".

I use this routinely in my flows with a variety of switches including Zooz, one GE, and multiple Caseta.

Type is not a command, so it will not show up as a command in node-red. It is an event, that shows up as msg.payload.type, if you look for events from "switch".

3 Likes

I found it. But... I am having trouble figuring out how to include it in a motion flow. Do you have an example you would be willing to share?

Thanks,

The way you do this is to set a global variable like "hallSwitchDisable" to true when you manually turn on the switch and false when you manually turn it off.. then in your motion sequence just test for "hallSwitchDisable" if it is true then ignore the auto shut off..

1 Like

Sure, I’ll try to put a sample together later today. Basically, my approach is similar to that described by @erktrek.

1 Like

Here's an example:

  1. My closet light is controlled by events from a motion sensor and a contact sensor.
  2. If the switch is turned on manually, then contact and motion events are not used to control the light.
  3. When the switch is turned off (by any means - physical or digital), after 30 seconds, control is restored to motion/contact events.

Sequence for import
[{"id":"a59873edf4b6c732","type":"switch","z":"387332bd262639e8","name":"physical","property":"payload.type","propertyType":"msg","rules":[{"t":"eq","v":"physical","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":680,"y":360,"wires":[["b944d6b5cf1ed913","189e58365736b00b","900932d992fc024b"]]},{"id":"b944d6b5cf1ed913","type":"change","z":"387332bd262639e8","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":815,"y":360,"wires":[["65a6a38de7df05f0"]],"l":false},{"id":"65a6a38de7df05f0","type":"delay","z":"387332bd262639e8","name":"30s","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":815,"y":300,"wires":[["f717b2d07000d4f9"]],"l":false},{"id":"9278527930f6824d","type":"switch","z":"387332bd262639e8","name":"off/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":650,"y":300,"wires":[["65a6a38de7df05f0"],["a59873edf4b6c732"]]},{"id":"f2954135ed5ebc16","type":"hubitat device","z":"387332bd262639e8","deviceLabel":"Closet Light","name":"","server":"662851c4.3ccad","deviceId":"4197","attribute":"switch","sendEvent":true,"x":490,"y":300,"wires":[["9278527930f6824d"]]},{"id":"189e58365736b00b","type":"change","z":"387332bd262639e8","name":"g.physical_switch=true","rules":[{"t":"set","p":"physical_switch","pt":"global","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":360,"wires":[[]]},{"id":"f717b2d07000d4f9","type":"change","z":"387332bd262639e8","name":"g.physical_switch=false","rules":[{"t":"set","p":"physical_switch","pt":"global","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":300,"wires":[[]]},{"id":"9a511e9dda84aa32","type":"switch","z":"387332bd262639e8","name":"g.physical_switch=false","property":"physical_switch","propertyType":"global","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":430,"y":480,"wires":[["84351932e13b16a3"]]},{"id":"6d4841a811373d8c","type":"hubitat device","z":"387332bd262639e8","deviceLabel":"Motion - Closet","name":"","server":"a22e0ea9.276dc8","deviceId":"1977","attribute":"motion","sendEvent":true,"x":200,"y":520,"wires":[["9a511e9dda84aa32"]]},{"id":"d0893423e00178ea","type":"hubitat device","z":"387332bd262639e8","deviceLabel":"Contact - Closet Door","name":"","server":"a22e0ea9.276dc8","deviceId":"1974","attribute":"contact","sendEvent":true,"x":180,"y":440,"wires":[["9a511e9dda84aa32"]]},{"id":"84351932e13b16a3","type":"switch","z":"387332bd262639e8","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":700,"y":480,"wires":[["900932d992fc024b"],["477edd2a05b35a2c"]]},{"id":"900932d992fc024b","type":"change","z":"387332bd262639e8","name":"stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":460,"wires":[["477edd2a05b35a2c","85a4800e17daf003"]]},{"id":"477edd2a05b35a2c","type":"stoptimer-varidelay","z":"387332bd262639e8","duration":"3","durationType":"num","units":"Minute","payloadtype":"num","payloadval":"0","name":"3 min","reporting":"last_minute_seconds","persist":true,"x":930,"y":520,"wires":[["68c6a6762f95e59c"],[],[]]},{"id":"85a4800e17daf003","type":"change","z":"387332bd262639e8","name":"setLevel","rules":[{"t":"set","p":"arguments","pt":"msg","to":"100,0","tot":"str"},{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1035,"y":460,"wires":[["f823567d37b92354"]],"l":false},{"id":"f823567d37b92354","type":"hubitat command","z":"387332bd262639e8","deviceLabel":"Closet Light","name":"","server":"662851c4.3ccad","deviceId":"4197","command":"","commandArgs":"","x":1190,"y":480,"wires":[[]]},{"id":"68c6a6762f95e59c","type":"change","z":"387332bd262639e8","name":"off","rules":[{"t":"set","p":"command","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1035,"y":520,"wires":[["f823567d37b92354"]],"l":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,"colorEnabled":true,"color":"#51b8f0"},{"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,"colorEnabled":true,"color":"#5dd049"}]
2 Likes

Here's my much more hasty, unoptimized, and likely fraught with errors take! :wink:

Note: I changed "hallSwitchDisable" to "hallMotionDisable" for clarity..

edit: yep, had some glitches.. updated and switched around a bit.

2 Likes

Here is another sample - I have a closet light that is triggered by a contact sensor or a motion sensor.

The flow is below:

[{"id":"7a679ded.632d3c","type":"group","z":"68be3b45.fb2464","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["223f8f81.d081b","1cbbb6.5d09944b","bca58ba8.42b388","8fd5ceab.e22d8","3dad0999.738496","5c95557c.f2fa1c","efba6397.f64548","5fe04c4b.58c7cc","4f23536f.10b63c","8a24fd46.088ec8","69bba408.237eb4","9cc3f20a.e27598","7147e912.9d9508","a238abb2.ec5cc8","fa0a6e24.bc8568","c89fcf93.59d198","4bfaf310.5170a4"],"x":113.1666374206543,"y":4309.500192642212,"w":1495.0001106262207,"h":350.9998073577881},{"id":"223f8f81.d081b","type":"hubitat device","z":"68be3b45.fb2464","g":"7a679ded.632d3c","deviceLabel":"Bedroom Closet Motion","name":"","server":"2e073620.1f85c2","deviceId":"716","attribute":"motion","sendEvent":true,"x":266.6666564941406,"y":4535.6669921875,"wires":[["1cbbb6.5d09944b"]]},{"id":"1cbbb6.5d09944b","type":"switch","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Motion (Y/N)?","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":482.6666488647461,"y":4535.4169664382935,"wires":[["bca58ba8.42b388","8fd5ceab.e22d8"],["3dad0999.738496"]],"outputLabels":["Active","Inactive"]},{"id":"bca58ba8.42b388","type":"change","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Reset Delay","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":647.6666107177734,"y":4474.666991233826,"wires":[["efba6397.f64548"]]},{"id":"8fd5ceab.e22d8","type":"hubitat device","z":"68be3b45.fb2464","g":"7a679ded.632d3c","deviceLabel":"Pantry Light","name":"Closet Light State","server":"2e073620.1f85c2","deviceId":"708","attribute":"switch","sendEvent":false,"x":877.3333129882812,"y":4528.33349609375,"wires":[["5fe04c4b.58c7cc"]]},{"id":"3dad0999.738496","type":"delay","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Delay 5 minute","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":666.9166717529297,"y":4587.916993141174,"wires":[["8a24fd46.088ec8"]]},{"id":"5c95557c.f2fa1c","type":"switch","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Turned off manually?","property":"payload.type = 'physical'  and payload.currentValue = 'off'","propertyType":"jsonata","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":417.3332977294922,"y":4475,"wires":[["bca58ba8.42b388"]]},{"id":"efba6397.f64548","type":"link out","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Reset Delay (C) - Out","links":["4f23536f.10b63c"],"x":848.0832977294922,"y":4474.666991233826,"wires":[],"l":true},{"id":"5fe04c4b.58c7cc","type":"switch","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Light Off?","property":"payload.currentValue","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1073.9999313354492,"y":4528.416991233826,"wires":[["9cc3f20a.e27598"]]},{"id":"4f23536f.10b63c","type":"link in","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Reset Delay (C) - In","links":["efba6397.f64548","4370e12d.0acc18"],"x":461.0832939147949,"y":4588.166940689087,"wires":[["3dad0999.738496"]],"l":true},{"id":"8a24fd46.088ec8","type":"hubitat device","z":"68be3b45.fb2464","g":"7a679ded.632d3c","deviceLabel":"Pantry Light","name":"Closet Light State","server":"2e073620.1f85c2","deviceId":"708","attribute":"switch","sendEvent":false,"x":881.6666870117188,"y":4587.33349609375,"wires":[["7147e912.9d9508"]]},{"id":"69bba408.237eb4","type":"hubitat device","z":"68be3b45.fb2464","g":"7a679ded.632d3c","deviceLabel":"Bedroom Closet Switch","name":"","server":"2e073620.1f85c2","deviceId":"708","attribute":"switch","sendEvent":true,"x":267.3333435058594,"y":4416.0000076293945,"wires":[["5c95557c.f2fa1c"]]},{"id":"9cc3f20a.e27598","type":"change","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Turn On","rules":[{"t":"set","p":"command","pt":"msg","to":"on","tot":"str"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250.416748046875,"y":4528.9169921875,"wires":[["a238abb2.ec5cc8"]]},{"id":"7147e912.9d9508","type":"switch","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Light On?","property":"payload.currentValue","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1072.6666259765625,"y":4587.33349609375,"wires":[["fa0a6e24.bc8568"]]},{"id":"a238abb2.ec5cc8","type":"hubitat command","z":"68be3b45.fb2464","g":"7a679ded.632d3c","deviceLabel":"Bedroom Closet Switch","name":"","server":"2e073620.1f85c2","deviceId":"708","command":"","commandArgs":"","x":1472.166748046875,"y":4554.4169921875,"wires":[[]]},{"id":"fa0a6e24.bc8568","type":"change","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Turn Off","rules":[{"t":"set","p":"command","pt":"msg","to":"off","tot":"str"},{"t":"delete","p":"reset","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1247.9167022705078,"y":4587.4169921875,"wires":[["a238abb2.ec5cc8"]]},{"id":"c89fcf93.59d198","type":"comment","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Change Log","info":"2021-09-24: Created\n2021-09-24: Combined logic for turning off/on based on motion. Also added link from light turning on with contact sensor\n2021-10-10: Added steps to delete msg.payload and msg.reset when sending msg.command\n2021-11-27: Added code to handle case where switch is turned of manually","x":217.41664123535156,"y":4619.5,"wires":[]},{"id":"4bfaf310.5170a4","type":"comment","z":"68be3b45.fb2464","g":"7a679ded.632d3c","name":"Closet Light: Turn on/off if motion detected","info":"","x":309.1666374206543,"y":4350.500192642212,"wires":[]},{"id":"2e073620.1f85c2","type":"hubitat config","name":"Hubitat_Prod","usetls":false,"host":"192.168.1.113","port":"80","appId":"225","nodeRedServer":"http://192.168.1.82:1880","webhookPath":"/hubitat/webhook_","autoRefresh":true,"useWebsocket":false},{"id":"f7e698db.8e7188","type":"group","z":"68be3b45.fb2464","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["bae51b4b.a976b8","1caffd07.c1a45b","bfcb6579.92d99","4c92f5e1.c8c30c","39a9f2d6.51cd46","522336b7.9ef018","a2d66cc7.60dad","4370e12d.0acc18"],"x":113,"y":4033.6670303344727,"w":934.9999694824219,"h":222.33349609375},{"id":"bae51b4b.a976b8","type":"hubitat device","z":"68be3b45.fb2464","g":"f7e698db.8e7188","deviceLabel":"Bedroom Closet Contact","name":"","server":"2e073620.1f85c2","deviceId":"710","attribute":"contact","sendEvent":true,"x":254,"y":4135.6669921875,"wires":[["1caffd07.c1a45b"]]},{"id":"1caffd07.c1a45b","type":"switch","z":"68be3b45.fb2464","g":"f7e698db.8e7188","name":"Open or Closed?","property":"payload.currentValue","propertyType":"msg","rules":[{"t":"eq","v":"open","vt":"str"},{"t":"eq","v":"closed","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":497,"y":4135.6669921875,"wires":[["bfcb6579.92d99"],["4c92f5e1.c8c30c"]]},{"id":"bfcb6579.92d99","type":"change","z":"68be3b45.fb2464","g":"f7e698db.8e7188","name":"Turn On","rules":[{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"99,0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":4106.6669921875,"wires":[["39a9f2d6.51cd46","4370e12d.0acc18"]]},{"id":"4c92f5e1.c8c30c","type":"change","z":"68be3b45.fb2464","g":"f7e698db.8e7188","name":"Turn Off","rules":[{"t":"set","p":"command","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":691.333251953125,"y":4168.00048828125,"wires":[["4370e12d.0acc18"]]},{"id":"39a9f2d6.51cd46","type":"hubitat command","z":"68be3b45.fb2464","g":"f7e698db.8e7188","deviceLabel":"Hall Closet","name":"Bedroom Closet Light","server":"2e073620.1f85c2","deviceId":"708","command":"","commandArgs":"","x":911.9999694824219,"y":4107.6669921875,"wires":[[]]},{"id":"522336b7.9ef018","type":"comment","z":"68be3b45.fb2464","g":"f7e698db.8e7188","name":"Bedroom Closet Light: Turn on/off when door open/closed","info":"","x":359,"y":4074.6670303344727,"wires":[]},{"id":"a2d66cc7.60dad","type":"comment","z":"68be3b45.fb2464","g":"f7e698db.8e7188","name":"Change Log","info":"2021-09-21: Created\n2021-09-22: Changed on command to setLevel and 99,0 to handle if swtich was dimmed to 0 manually\n2021-09-25: Changed to turn off light 5 minutes after closet door is closed if no motion.","x":217.33331298828125,"y":4215.000526428223,"wires":[]},{"id":"4370e12d.0acc18","type":"link out","z":"68be3b45.fb2464","g":"f7e698db.8e7188","name":"Reset Delay (C) - Out","links":["4f23536f.10b63c"],"x":901.6665954589844,"y":4169.6669921875,"wires":[],"l":true}]

Hope this helps.

2 Likes

Yeah I skimmed too quickly and did not include the "contact sensor" bit.. sorry! :man_facepalming:

I wonder why you would need both for a closet though - I have motion sensors and a routine similar to the above. Contact sensor isn't necessary for my use-case unless I was worried about a door remaining open or enforcing lights off on a door close.

Thanks, I appreciate everyones thoughts on this, these give me some clarity on how to do it.

1 Like