Node-Red Flow Samples/Sharing

Credit to @JasonJoel - I felt it's worth linking here as well from the main NR thread. These are a great examples of simple motion lighting timer sequences.

4 Likes

Sorry mate, completely overlooked your reply.

In that example it would, but only because deCONZ has an "end" action, whereas the HE NR pallet, you can continue after the lights are on, to say put it back into the timer loop, if you see what I mean?

where does one find the GATE node

3 Likes

Any thoughts on the best way to accomplish this? I want the light to stay on in the bonus room if motion is detected at any time, and stay on for 15 minutes. If it's a weekday between 7:00-17:00, I want the light to come on if motion and stay on until 17:00.

I think this will work, but I believe if I leave the room (no motion) before 17:00, the light would stay on. What am I doing wrong or anyone have a better way to accomplish this. TU.

If I'm interpreting this correctly, you basically want active motion to switch ON the light, no matter what time or day. But you want the inactive event to switch OFF the light only outside of the given windows of time. Correct?

I think you basically just need to move the time-related stuff to after the delay node. So, if you leave the room at 10 minutes before 17:00, the countdown will still run, and by the time the 15 minute countdown is done, the light will switch off (at 17:05). If you really want to force the light off at 17:00 even if there's still some time left on the countdown, you could have a separate sequence that switches the light off at 17:00 if no motion is currently active.

1 Like

I believe you're correct. This is what I have now.

1 Like

I do something similar in my sensor alert light depending on mode turn it on and off and delay for 1 minute before returning it to previous state

@aaiyar would you be willing to share you Sleep By Number bed flow or at least an example that show how you deflate and inflate it to set it back to 100 daily. I was reading your post on the Sleep Number Controller page. Thanks

2 Likes

This flow deflates it to 1 (in steps of 10), then inflates it to 100 (in steps of 10), then waits a couple minutes and sets it to my preferred Sleep Number. This is only for one side. I have an equivalent flow for the other side. Also, the flow only begins if the bed is not occupied. I have my Sleep Number bed plugged into a controlled outlet which is switched off when the mode is Away, so the flow also runs only when that outlet is on.

[{"id":"fd0ec42f.7d087","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"7bc67c56.7d8fcc","type":"hubitat device","z":"fd0ec42f.7d087","name":"Bed - Outlet","server":"662851c4.3ccad","deviceId":"4394","attribute":"switch","sendEvent":false,"x":330,"y":540,"wires":[["5b33a630.b169d8"]]},{"id":"fe500e5e.df95e8","type":"cronplus","z":"fd0ec42f.7d087","name":"","outputField":"payload","timeZone":"","persistDynamic":true,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"str","payload":"","expressionType":"cron","expression":"0 15 19 * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":80,"y":540,"wires":[["7bc67c56.7d8fcc"]]},{"id":"5b33a630.b169d8","type":"switch","z":"fd0ec42f.7d087","name":"on","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":490,"y":540,"wires":[["219c2f39.a481b8"]]},{"id":"219c2f39.a481b8","type":"switch","z":"fd0ec42f.7d087","name":"vacation off","property":"vacation_status","propertyType":"global","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":650,"y":540,"wires":[["f4140fef.3aa0e8"]]},{"id":"f4140fef.3aa0e8","type":"hubitat device","z":"fd0ec42f.7d087","name":"Ashok","server":"662851c4.3ccad","deviceId":"4642","attribute":"presence","sendEvent":false,"x":810,"y":540,"wires":[["f4ead7eb.fba35"]]},{"id":"f4ead7eb.fba35","type":"switch","z":"fd0ec42f.7d087","name":"not present","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"not present","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":990,"y":540,"wires":[["46e373e0.8d983c"]]},{"id":"46e373e0.8d983c","type":"hubitat device","z":"fd0ec42f.7d087","name":"Ashok","server":"662851c4.3ccad","deviceId":"4642","attribute":"level","sendEvent":false,"x":1150,"y":540,"wires":[["747afba0.c0b9ac"]]},{"id":"3b38b2b5.8cf7c6","type":"delay","z":"fd0ec42f.7d087","name":"30","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2230,"y":540,"wires":[["46e373e0.8d983c"]]},{"id":"747afba0.c0b9ac","type":"delay","z":"fd0ec42f.7d087","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1255,"y":540,"wires":[["af4c2fc8.132868"]],"l":false},{"id":"87aceb32.8cb1d","type":"hubitat command","z":"fd0ec42f.7d087","name":"Ashok","server":"662851c4.3ccad","deviceId":"4642","command":"setLevel","commandArgs":"msg.arguments","x":2090,"y":540,"wires":[["3b38b2b5.8cf7c6"]]},{"id":"af4c2fc8.132868","type":"change","z":"fd0ec42f.7d087","name":"","rules":[{"t":"set","p":"arguments","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1390,"y":540,"wires":[["a446366d.eded28"]]},{"id":"98576f10.cbfe2","type":"switch","z":"fd0ec42f.7d087","name":"<1/>1/1","property":"arguments","propertyType":"msg","rules":[{"t":"lt","v":"1","vt":"num"},{"t":"gt","v":"1","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":3,"x":1880,"y":540,"wires":[["b1fde12f.bb02d8"],["87aceb32.8cb1d"],["a446366d.eded28"]]},{"id":"b1fde12f.bb02d8","type":"change","z":"fd0ec42f.7d087","name":"","rules":[{"t":"set","p":"arguments","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1995,"y":520,"wires":[["87aceb32.8cb1d"]],"l":false},{"id":"a446366d.eded28","type":"switch","z":"fd0ec42f.7d087","name":">1/1","property":"arguments","propertyType":"msg","rules":[{"t":"gt","v":"1","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1570,"y":540,"wires":[["c0f27c62.43c0e"],["fecc06b1.96a2f"]]},{"id":"c0f27c62.43c0e","type":"change","z":"fd0ec42f.7d087","name":"Sub 10","rules":[{"t":"set","p":"arguments","pt":"msg","to":"arguments - 10","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1720,"y":540,"wires":[["98576f10.cbfe2"]]},{"id":"fecc06b1.96a2f","type":"delay","z":"fd0ec42f.7d087","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1115,"y":620,"wires":[["30143c1e.5aadfc"]],"l":false},{"id":"30143c1e.5aadfc","type":"hubitat device","z":"fd0ec42f.7d087","name":"Ashok","server":"662851c4.3ccad","deviceId":"4642","attribute":"level","sendEvent":false,"x":1230,"y":620,"wires":[["2025dd13.859b82"]]},{"id":"2025dd13.859b82","type":"delay","z":"fd0ec42f.7d087","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1335,"y":620,"wires":[["68c3d69a.c835c8"]],"l":false},{"id":"289aa599.f3f4ba","type":"delay","z":"fd0ec42f.7d087","name":"30","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2350,"y":620,"wires":[["30143c1e.5aadfc"]]},{"id":"68c3d69a.c835c8","type":"change","z":"fd0ec42f.7d087","name":"","rules":[{"t":"set","p":"arguments","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1470,"y":620,"wires":[["32c900a3.ca0158"]]},{"id":"325a514a.094966","type":"hubitat command","z":"fd0ec42f.7d087","name":"Ashok","server":"662851c4.3ccad","deviceId":"4642","command":"setLevel","commandArgs":"msg.arguments","x":2210,"y":620,"wires":[["289aa599.f3f4ba"]]},{"id":"32c900a3.ca0158","type":"switch","z":"fd0ec42f.7d087","name":"<100/100","property":"arguments","propertyType":"msg","rules":[{"t":"lt","v":"100","vt":"num"},{"t":"eq","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1660,"y":620,"wires":[["4d955af9.87b32c"],["6e4d3735.e0347","a4f7a37b.e9633"]]},{"id":"f1ca3d7d.cdd57","type":"switch","z":"fd0ec42f.7d087","name":">100/<=100","property":"arguments","propertyType":"msg","rules":[{"t":"gt","v":"100","vt":"str"},{"t":"lte","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1990,"y":620,"wires":[["f6cbf1ff.0ebd88"],["325a514a.094966"]]},{"id":"f6cbf1ff.0ebd88","type":"change","z":"fd0ec42f.7d087","name":"","rules":[{"t":"set","p":"arguments","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":2115,"y":600,"wires":[["325a514a.094966"]],"l":false},{"id":"4d955af9.87b32c","type":"change","z":"fd0ec42f.7d087","name":"Add 10","rules":[{"t":"set","p":"arguments","pt":"msg","to":"arguments + 10","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1820,"y":620,"wires":[["f1ca3d7d.cdd57"]]},{"id":"6e4d3735.e0347","type":"change","z":"fd0ec42f.7d087","name":"Ashok's Head Position","rules":[{"t":"set","p":"arguments","pt":"msg","to":"12","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1860,"y":740,"wires":[["78fa50ff.4160c8"]]},{"id":"a4f7a37b.e9633","type":"delay","z":"fd0ec42f.7d087","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1775,"y":680,"wires":[["788dce2e.ff7c8"]],"l":false},{"id":"78fa50ff.4160c8","type":"hubitat command","z":"fd0ec42f.7d087","name":"Ashok Head","server":"662851c4.3ccad","deviceId":"4643","command":"setLevel","commandArgs":"msg.arguments","x":2070,"y":740,"wires":[[]]},{"id":"788dce2e.ff7c8","type":"change","z":"fd0ec42f.7d087","name":"Ashok's Sleep Number","rules":[{"t":"set","p":"arguments","pt":"msg","to":"55","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1930,"y":680,"wires":[["e13d0e18.1189f"]]},{"id":"e13d0e18.1189f","type":"hubitat command","z":"fd0ec42f.7d087","name":"Ashok","server":"662851c4.3ccad","deviceId":"4642","command":"setLevel","commandArgs":"msg.arguments","x":2130,"y":680,"wires":[[]]},{"id":"662851c4.3ccad","type":"hubitat config","z":"","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}]

@aaiyar Thanks you so much for sharing.

1 Like

@leeonestop and anyone else using the SleepIQ node-red sequence I posted a few days ago:

There's an error in it, because the mattress doesn't respond to inflation levels that are not numbers ending in 0 or 5.

But this is simple to fix in the change nodes that use JSONata for subtraction and addition.

In the change node named "Sub 10",

Change:
arguments - 10
to
$round(arguments, -1) - 10

Similarly, in the change node named, "Add 10",
Change
arguments + 10
to
$round(arguments, -1) + 10

Sorry about the previous error ....

Hey guys - I posted a Node-RED solution for shutting down and restarting the hub in case of power outages (Shutdown and restart Hub in case of power outage (Node-red solution) - LONG READ).

Thought I would link it here in case anyone wanted to take a look.

5 Likes

Here are some Sonos flows, so that if you have Sonos playing somewhere (Master), and then walk into another room with a motion sensor, then it will start playing in that room. There are a couple of versions. There are switches on a Node Red dashboard that turn "party time" on and off.

This is for actived by motion in the slave, and will join the master Sonos, at a set volume.

[{"id":"4f62b245.556d2c","type":"hubitat device","z":"7f5e3dd.11d05c4","name":"MD - Kitchen 2","server":"2120cd99.47cc12","deviceId":"12","attribute":"motion","sendEvent":true,"x":560,"y":80,"wires":[["63d16379.ed480c"]]},{"id":"e8b0988d.5de038","type":"hubitat device","z":"7f5e3dd.11d05c4","name":"MDChild -  Kitchen","server":"b37b2cbb.28c06","deviceId":"18","attribute":"motion","sendEvent":true,"x":550,"y":140,"wires":[["63d16379.ed480c"]]},{"id":"33894329.82eb1c","type":"comment","z":"7f5e3dd.11d05c4","name":"Kitchen: slave, Office: master","info":"","x":140,"y":100,"wires":[]},{"id":"a0d3fddf.d2b38","type":"ui_switch","z":"7f5e3dd.11d05c4","name":"Kitchen party time","label":"<b>Kitchen </b>party","tooltip":"On to allow joining","group":"58dc097d.1c35f8","order":2,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":290,"y":220,"wires":[["2be31cb5.ec8024"]]},{"id":"2be31cb5.ec8024","type":"switch","z":"7f5e3dd.11d05c4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":220,"wires":[["ec25cb9b.b8ef18"],["335c4bea.02a1e4"]]},{"id":"ec25cb9b.b8ef18","type":"change","z":"7f5e3dd.11d05c4","name":"Open","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":200,"wires":[["63d16379.ed480c"]]},{"id":"335c4bea.02a1e4","type":"change","z":"7f5e3dd.11d05c4","name":"Close","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":240,"wires":[["63d16379.ed480c","7271f093.96bc9","40f16b0c.4da3b4"]]},{"id":"63d16379.ed480c","type":"q-gate","z":"7f5e3dd.11d05c4","name":"Dash Switch","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"100","keepNewest":false,"qToggle":false,"persist":true,"x":740,"y":220,"wires":[["10162c82.264263"]]},{"id":"10162c82.264263","type":"switch","z":"7f5e3dd.11d05c4","name":"","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":890,"y":220,"wires":[["3563948e.14618c","ced5be5e.bfeb2"],["3563948e.14618c"]]},{"id":"3563948e.14618c","type":"stoptimer-varidelay","z":"7f5e3dd.11d05c4","duration":"7","durationType":"num","units":"Minute","payloadtype":"num","payloadval":"0","name":"","reporting":"none","x":1160,"y":260,"wires":[["20c7f80c.43dd68"],[],[]]},{"id":"20c7f80c.43dd68","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"e7f03a53.241ce8","compatibilityMode":false,"command":"player.leave.group","state":"","stateType":"str","name":"Kitchen","x":1340,"y":260,"wires":[["2ba1c919.c218d6"]]},{"id":"2ff0be75.79bf92","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"e7f03a53.241ce8","compatibilityMode":false,"command":"player.join.group","state":"","stateType":"str","name":"Kitchen","x":1980,"y":220,"wires":[["df5172a2.6b87c"]]},{"id":"a184e75d.c5c878","type":"change","z":"7f5e3dd.11d05c4","name":"Join Office","rules":[{"t":"set","p":"payload","pt":"msg","to":"Office","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1830,"y":220,"wires":[["2ff0be75.79bf92"]]},{"id":"df5172a2.6b87c","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"fbea6094.43c19","compatibilityMode":false,"command":"player.get.volume","state":"","stateType":"str","name":"Office","x":2130,"y":220,"wires":[["55fa2657.091fb8"]]},{"id":"55fa2657.091fb8","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"e7f03a53.241ce8","compatibilityMode":false,"command":"player.set.volume","state":"","stateType":"str","name":"Kitchen","x":2420,"y":220,"wires":[["6902f9ca.a1b088"]]},{"id":"9f01982b.b61198","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"e7f03a53.241ce8","compatibilityMode":false,"command":"player.get.role","state":"","stateType":"str","name":"Kitchen","x":1140,"y":200,"wires":[["8ac02480.ed3f18"]]},{"id":"8ac02480.ed3f18","type":"switch","z":"7f5e3dd.11d05c4","name":"Check grouped?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"joiner","vt":"str"},{"t":"eq","v":"coordinator","vt":"str"},{"t":"eq","v":"standalone","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":1320,"y":200,"wires":[["88905734.7f4b28"],[],["a184e75d.c5c878"]]},{"id":"40f16b0c.4da3b4","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"e7f03a53.241ce8","compatibilityMode":false,"command":"player.get.role","state":"","stateType":"str","name":"Kitchen","x":980,"y":340,"wires":[["7b04113a.5450e"]]},{"id":"7b04113a.5450e","type":"switch","z":"7f5e3dd.11d05c4","name":"Check grouped?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"joiner","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1160,"y":340,"wires":[["20c7f80c.43dd68"]]},{"id":"7271f093.96bc9","type":"delay","z":"7f5e3dd.11d05c4","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":955,"y":300,"wires":[["8f2e250d.2851d8"]],"l":false},{"id":"8f2e250d.2851d8","type":"change","z":"7f5e3dd.11d05c4","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1015,"y":300,"wires":[["3563948e.14618c"]],"l":false},{"id":"497b11e.1861ff","type":"switch","z":"7f5e3dd.11d05c4","name":"Check Co-ordinator","property":"payload.coordinatorName","propertyType":"msg","rules":[{"t":"neq","v":"Office","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1650,"y":180,"wires":[["a184e75d.c5c878"]]},{"id":"88905734.7f4b28","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"e7f03a53.241ce8","compatibilityMode":false,"command":"group.get.state","state":"","stateType":"str","name":"Kitchen","x":1480,"y":180,"wires":[["497b11e.1861ff"]]},{"id":"6902f9ca.a1b088","type":"change","z":"7f5e3dd.11d05c4","name":"","rules":[{"t":"set","p":"sonos_kitchen","pt":"flow","to":"joined","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2535,"y":220,"wires":[[]],"l":false},{"id":"ced5be5e.bfeb2","type":"switch","z":"7f5e3dd.11d05c4","name":"","property":"sonos_kitchen","propertyType":"flow","rules":[{"t":"neq","v":"joined","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1015,"y":200,"wires":[["9f01982b.b61198"]],"l":false,"info":"This switch is to stop the sonos speakers getting smashed by constant requests to join/check volume/check groups status, every time motion sensors change to active. "},{"id":"2ba1c919.c218d6","type":"change","z":"7f5e3dd.11d05c4","name":"","rules":[{"t":"set","p":"sonos_kitchen","pt":"flow","to":"standalone","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1475,"y":260,"wires":[[]],"l":false},{"id":"40c7c88f.02d9f8","type":"calculator","z":"7f5e3dd.11d05c4","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"sum","constant":"2","x":2270,"y":220,"wires":[[]]},{"id":"2120cd99.47cc12","type":"hubitat config","z":"","name":"Hubitat Coordinator","usetls":false,"host":"192.168.1.100","port":"80","appId":"1731","nodeRedServer":"http://192.168.1.90:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false},{"id":"b37b2cbb.28c06","type":"hubitat config","z":"","name":"Hubitat Client","usetls":false,"host":"192.168.1.217","port":"80","appId":"808","nodeRedServer":"http://192.168.1.90:1880","webhookPath":"/hubitatclient/webhook","autoRefresh":true,"useWebsocket":false},{"id":"58dc097d.1c35f8","type":"ui_group","z":"","name":"Sonos","tab":"1862e313.45ffad","order":7,"disp":true,"width":"4","collapse":false},{"id":"e7f03a53.241ce8","type":"sonos-config","z":"","name":"Sonos - Kitchen","serialnum":"B8-E9-37-2F-9C-9C:6","ipaddress":"192.168.1.47"},{"id":"fbea6094.43c19","type":"sonos-config","z":"","name":"Sonos - Office","serialnum":"B8-E9-37-2F-9C-48:7","ipaddress":"192.168.1.44"},{"id":"1862e313.45ffad","type":"ui_tab","z":"","name":"Mike","icon":"dashboard","disabled":false,"hidden":false}]

This one will check to see if the TV is already playing (my TV Sonos may already be playing TV). Also checks to see if the dash board switch Party Time TV is ON.

[{"id":"678d617a.02213","type":"comment","z":"7f5e3dd.11d05c4","name":"TV: slave, Office: master","info":"","x":130,"y":500,"wires":[]},{"id":"5c2b5e94.79a69","type":"switch","z":"7f5e3dd.11d05c4","name":"","property":"bool","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":710,"y":580,"wires":[["da871b7.79190e8"],["50f4b803.9e8b08","eda4af02.f9c27"]]},{"id":"da871b7.79190e8","type":"change","z":"7f5e3dd.11d05c4","name":"Open","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":560,"wires":[["ffaeca6.3c1c638"]]},{"id":"50f4b803.9e8b08","type":"change","z":"7f5e3dd.11d05c4","name":"Close","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":600,"wires":[["ffaeca6.3c1c638"]]},{"id":"ffaeca6.3c1c638","type":"q-gate","z":"7f5e3dd.11d05c4","name":"Dash Switch","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"100","keepNewest":false,"qToggle":false,"persist":true,"x":1160,"y":560,"wires":[["4ffd9a22.97c464"]]},{"id":"4ffd9a22.97c464","type":"switch","z":"7f5e3dd.11d05c4","name":"","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":1300,"y":580,"wires":[["636faa47.6e89f4","4cda6840.280148"],["636faa47.6e89f4"]]},{"id":"636faa47.6e89f4","type":"stoptimer-varidelay","z":"7f5e3dd.11d05c4","duration":"7","durationType":"num","units":"Minute","payloadtype":"num","payloadval":"0","name":"","reporting":"none","x":1490,"y":620,"wires":[["a40dc311.9bbc8"],[],[]]},{"id":"a40dc311.9bbc8","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"b677af92.bb012","compatibilityMode":false,"command":"player.leave.group","state":"","stateType":"str","name":"TV","x":1660,"y":620,"wires":[["4b3c73b3.66141c"]]},{"id":"9676d8a2.932df8","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"b677af92.bb012","compatibilityMode":false,"command":"player.join.group","state":"","stateType":"str","name":"TV","x":2310,"y":560,"wires":[["79ce6f8c.f20b6"]]},{"id":"298d0438.c2802c","type":"change","z":"7f5e3dd.11d05c4","name":"Join Office","rules":[{"t":"set","p":"payload","pt":"msg","to":"Office","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2170,"y":560,"wires":[["9676d8a2.932df8"]]},{"id":"79ce6f8c.f20b6","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"fbea6094.43c19","compatibilityMode":false,"command":"player.get.volume","state":"","stateType":"str","name":"Office","x":2490,"y":560,"wires":[["b9a03206.ec086"]]},{"id":"d96b8512.782198","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"b677af92.bb012","compatibilityMode":false,"command":"player.set.volume","state":"","stateType":"str","name":"TV","x":2910,"y":560,"wires":[["cd7d3c50.44f6"]]},{"id":"e7631e8f.a5e5c","type":"ui_switch","z":"7f5e3dd.11d05c4","name":"TV party time","label":"<b>TV</b> party","tooltip":"ON to allow joining","group":"58dc097d.1c35f8","order":1,"width":4,"height":1,"passthru":false,"decouple":"false","topic":"TV Party Time","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":290,"y":580,"wires":[["5423c672.997e78"]]},{"id":"ff836d83.184ed","type":"hubitat device","z":"7f5e3dd.11d05c4","name":"MD - TV Room 2","server":"2120cd99.47cc12","deviceId":"21","attribute":"motion","sendEvent":true,"x":990,"y":500,"wires":[["ffaeca6.3c1c638"]]},{"id":"a2ff4f74.9b611","type":"hubitat device","z":"7f5e3dd.11d05c4","name":"MDChild -  TV","server":"b37b2cbb.28c06","deviceId":"17","attribute":"motion","sendEvent":true,"x":1010,"y":440,"wires":[["ffaeca6.3c1c638"]]},{"id":"22e8e500.06e84c","type":"hubitat device","z":"7f5e3dd.11d05c4","name":"TV - Downstairs TV","server":"b37b2cbb.28c06","deviceId":"96","attribute":"switch","sendEvent":true,"x":290,"y":640,"wires":[["5423c672.997e78"]]},{"id":"5421cda9.182a74","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"b677af92.bb012","compatibilityMode":false,"command":"player.get.role","state":"","stateType":"str","name":"TV","x":1330,"y":680,"wires":[["38f4ec9d.430884"]]},{"id":"38f4ec9d.430884","type":"switch","z":"7f5e3dd.11d05c4","name":"Check grouped?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"joiner","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1500,"y":680,"wires":[["a40dc311.9bbc8"]]},{"id":"5423c672.997e78","type":"and-gate","z":"7f5e3dd.11d05c4","name":"TV OFF and Switch ON","rules":[{"t":"eq","v":"on","vt":"str","propertyType":"msg","property":"payload","topic":"TV Party Time"},{"t":"eq","v":"off","vt":"str","propertyType":"msg","property":"payload.value","topic":"TV - Downstairs TV"}],"outputTopic":"Control","gateType":"and","emitOnlyIfTrue":false,"x":510,"y":580,"wires":[["5c2b5e94.79a69"]]},{"id":"eda4af02.f9c27","type":"link out","z":"7f5e3dd.11d05c4","name":"","links":["ab2d2025.a8fe3"],"x":815,"y":660,"wires":[]},{"id":"ab2d2025.a8fe3","type":"link in","z":"7f5e3dd.11d05c4","name":"","links":["eda4af02.f9c27"],"x":1215,"y":660,"wires":[["5421cda9.182a74","6f27d6af.09fdf8"]]},{"id":"6f27d6af.09fdf8","type":"delay","z":"7f5e3dd.11d05c4","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1295,"y":640,"wires":[["7cf6f91a.b3b078"]],"l":false},{"id":"7cf6f91a.b3b078","type":"change","z":"7f5e3dd.11d05c4","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1355,"y":640,"wires":[["636faa47.6e89f4"]],"l":false},{"id":"76a1a8cb.6a7b68","type":"calculator","z":"7f5e3dd.11d05c4","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"sub","constant":"4","x":2760,"y":540,"wires":[["d96b8512.782198"]]},{"id":"cd7d3c50.44f6","type":"change","z":"7f5e3dd.11d05c4","name":"","rules":[{"t":"set","p":"sonos_tv","pt":"flow","to":"joined","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3015,"y":560,"wires":[[]],"l":false},{"id":"ec3b4015.e350c","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"b677af92.bb012","compatibilityMode":false,"command":"player.get.role","state":"","stateType":"str","name":"TV","x":1490,"y":520,"wires":[["211bcc01.9a25e4"]]},{"id":"211bcc01.9a25e4","type":"switch","z":"7f5e3dd.11d05c4","name":"Check grouped?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"joiner","vt":"str"},{"t":"eq","v":"coordinator","vt":"str"},{"t":"eq","v":"standalone","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":1680,"y":520,"wires":[["debefae5.18ad48"],[],["298d0438.c2802c"]]},{"id":"8dded682.6e9938","type":"switch","z":"7f5e3dd.11d05c4","name":"Check Co-ordinator","property":"payload.coordinatorName","propertyType":"msg","rules":[{"t":"neq","v":"Office","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2010,"y":500,"wires":[["298d0438.c2802c"]]},{"id":"debefae5.18ad48","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"b677af92.bb012","compatibilityMode":false,"command":"group.get.state","state":"","stateType":"str","name":"TV","x":1830,"y":500,"wires":[["8dded682.6e9938"]]},{"id":"4cda6840.280148","type":"switch","z":"7f5e3dd.11d05c4","name":"","property":"sonos_tv","propertyType":"flow","rules":[{"t":"neq","v":"joined","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1395,"y":520,"wires":[["ec3b4015.e350c"]],"l":false,"info":"This switch is to stop the sonos speakers getting smashed by constant requests to join/check volume/check groups status, every time motion sensors change to active. "},{"id":"4b3c73b3.66141c","type":"change","z":"7f5e3dd.11d05c4","name":"","rules":[{"t":"set","p":"sonos_tv","pt":"flow","to":"standalone","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1775,"y":620,"wires":[[]],"l":false},{"id":"b9a03206.ec086","type":"delay","z":"7f5e3dd.11d05c4","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2575,"y":560,"wires":[["aa7e8213.75447"]],"l":false},{"id":"aa7e8213.75447","type":"switch","z":"7f5e3dd.11d05c4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"7","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":2635,"y":560,"wires":[["76a1a8cb.6a7b68"],["d96b8512.782198"]],"l":false},{"id":"e28e1f43.efadd","type":"inject","z":"7f5e3dd.11d05c4","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":135,"y":620,"wires":[["e7631e8f.a5e5c","22e8e500.06e84c"]],"l":false},{"id":"b677af92.bb012","type":"sonos-config","z":"","name":"Sonos - TV","serialnum":"5c:aa:fd:1e:30:cd","ipaddress":"192.168.1.36"},{"id":"fbea6094.43c19","type":"sonos-config","z":"","name":"Sonos - Office","serialnum":"B8-E9-37-2F-9C-48:7","ipaddress":"192.168.1.44"},{"id":"58dc097d.1c35f8","type":"ui_group","z":"","name":"Sonos","tab":"1862e313.45ffad","order":7,"disp":true,"width":"4","collapse":false},{"id":"2120cd99.47cc12","type":"hubitat config","z":"","name":"Hubitat Coordinator","usetls":false,"host":"192.168.1.100","port":"80","appId":"1731","nodeRedServer":"http://192.168.1.90:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false},{"id":"b37b2cbb.28c06","type":"hubitat config","z":"","name":"Hubitat Client","usetls":false,"host":"192.168.1.217","port":"80","appId":"808","nodeRedServer":"http://192.168.1.90:1880","webhookPath":"/hubitatclient/webhook","autoRefresh":true,"useWebsocket":false},{"id":"1862e313.45ffad","type":"ui_tab","z":"","name":"Mike","icon":"dashboard","disabled":false,"hidden":false}]

This one has no motion sensors, just a switch in the dash, for my Sonos Move, which moves in and out of rooms. So, just a dash switch for activation.

[{"id":"d53a5f18.dc60b","type":"ui_switch","z":"7f5e3dd.11d05c4","name":"MOVE party time","label":"<b>Move</b> party","tooltip":"On to allow joining","group":"58dc097d.1c35f8","order":3,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":350,"y":1120,"wires":[["ed2358b0.a737e8"]]},{"id":"65d54dbe.fa5b64","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"c5ce9036.67dea","compatibilityMode":false,"command":"player.leave.group","state":"","stateType":"str","name":"Move","x":690,"y":1140,"wires":[[]]},{"id":"ed2358b0.a737e8","type":"switch","z":"7f5e3dd.11d05c4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":1120,"wires":[["c25dd54f.b26878"],["65d54dbe.fa5b64"]]},{"id":"88c4dc00.dc55b","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"c5ce9036.67dea","compatibilityMode":false,"command":"player.join.group","state":"","stateType":"str","name":"Move","x":870,"y":1100,"wires":[["55bf743e.f6f09c"]]},{"id":"c25dd54f.b26878","type":"change","z":"7f5e3dd.11d05c4","name":"Join Office","rules":[{"t":"set","p":"payload","pt":"msg","to":"Office","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":1100,"wires":[["88c4dc00.dc55b"]]},{"id":"55bf743e.f6f09c","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"fbea6094.43c19","compatibilityMode":false,"command":"group.get.volume","state":"","stateType":"str","name":"Office","x":1010,"y":1100,"wires":[["ab529a79.b58f38"]]},{"id":"ab529a79.b58f38","type":"sonos-universal","z":"7f5e3dd.11d05c4","confignode":"c5ce9036.67dea","compatibilityMode":false,"command":"player.set.volume","state":"","stateType":"str","name":"Move","x":1170,"y":1100,"wires":[[]]},{"id":"58dc097d.1c35f8","type":"ui_group","z":"","name":"Sonos","tab":"1862e313.45ffad","order":7,"disp":true,"width":"4","collapse":false},{"id":"c5ce9036.67dea","type":"sonos-config","z":"","name":"Sonos Move","serialnum":"48:a6:b8:e0:66:90","ipaddress":"192.168.1.89"},{"id":"fbea6094.43c19","type":"sonos-config","z":"","name":"Sonos - Office","serialnum":"B8-E9-37-2F-9C-48:7","ipaddress":"192.168.1.44"},{"id":"1862e313.45ffad","type":"ui_tab","z":"","name":"Mike","icon":"dashboard","disabled":false,"hidden":false}]
4 Likes

Very cool. I like the idea of dynamic allocation of devices to a music group like this. Nice. I guess the same could be achieved for Chromecast or Google Home devices instead of Sonos. I only have a couple of Sonos but more GH devices dotted around the house.

@aaiyar hey just wanted to say thanks for the fix.

@leeonestop

One more change. Change both the 30 second delay nodes to 2 minute delay nodes. The SleepNumber cloud API is rate limited, and hitting it every 30 seconds is too quick. Even 1 minute is too fast. But 2 minutes seems to work fine.

Ok will do thanks

1 Like

For the Alexa Routine, what do I set for the "When this happens" in the routine? Do I set it as "Alexa, word/phrase"? Because if I do this then it will not work unless I say it exactly.

Yes and you are at the mercy of how particular Alexa is in deciding if what she heard is close enough to the trigger phrase in your dummy routine.