Node-Red Flow Samples/Sharing

Yes, there is an easy way to do this. Because I lack @rakeshg's skill in turning out a neat javascript function, I rely on the built-in nodes (in this case split & join). Here's the relevant portion of a sequence that sends me an SMS when I'm at Costco (based on OwnTracks, but Life360 would work the same).

Here's the code:

[{"id":"aa794ad8.0fc3b8","type":"alexa-remote-list","z":"fc863045.38b668","name":"","account":"5b3978bd.f4d4e8","config":{"option":"getListItems","value":{"list":{"type":"str","value":"YW16bjEuYWNjb3VudC5BR0ZaNFA3SEhNM1FTVUZHQlRJVjJXQUtJMlNRLVNIT1BQSU5HX0lURU0="}}},"x":1560,"y":180,"wires":[["71f06923.371c28"]]},{"id":"71f06923.371c28","type":"split","z":"fc863045.38b668","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":1730,"y":180,"wires":[["b37a8fd4.9ad6c"]]},{"id":"b37a8fd4.9ad6c","type":"change","z":"fc863045.38b668","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1900,"y":180,"wires":[["ab9cfd91.58d428"]]},{"id":"ab9cfd91.58d428","type":"join","z":"fc863045.38b668","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":2070,"y":180,"wires":[["f55f05dd.4dec88"]]},{"id":"f55f05dd.4dec88","type":"change","z":"fc863045.38b668","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Costco shopping list","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2240,"y":180,"wires":[["79eecb90.1d6b44"]]},{"id":"5b3978bd.f4d4e8","type":"alexa-remote-account","name":"Alexa","authMethod":"proxy","proxyOwnIp":"192.168.1.4","proxyPort":"3456","cookieFile":"/home/odroid/.node-red/alexa-save","refreshInterval":"1","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.com","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

This is what the SMS message looks like:

4 Likes

That did the trick, thanks again!

1 Like

That's pretty cool. If there's ever a local-only TTS/STT device I'll do it.

I'm curious...how do you close the loop and check off just the items you purchased?

1 Like

Good question! I do that when I get home. Which reminds of something else. My actual sequence looks like this, and has a switch node after the split node:

The configuration of the switch node is:

This ensures that items I "check off" in the Alexa app are removed from the text message that is sent.

Edit: Also, I have different Alexa lists for each of the stores that I commonly go to (Costco, grocery store, hardware store).

1 Like

I see. I wonder if there might be a way to check them off as you put them in your cart :thinking: I use the Out of Milk app now and, of course, the list is local to my phone. It's not that big of a deal to do it after you get home...or is it...

2 Likes

:joy: - you have no idea of the trial and error and google searches that resulted in this!!

5 Likes

Good timing, I was trying to figure out why completed and non-completed items were getting pushed out and how to filter those. I've added in a switch node exactly as indicated, but get no output after the switch node. I've dropped a debug node in, and the split node is sending each item on the list out to the switch:
image
I've got the switch node after that, and nothing is coming from the output.

@aaiyar the IP address is that you have in the Alexa List node is that for a Alexa device or is for a PI /Computer etc. I try to use the IP for a pi and a Alexa Show but getting a error. Thanks (I got it Thanks)

Likely for the device his NR is running on (i.e. I've got mine running on a RPi and left the IP as localhost, works fine).

image

You won't specify an IP for any of your Alexa devices, just the IP of the device you run NR on so you can authenticate your account through Amazon.

1 Like

Just did it and it work. I have a senior moment now and again. Thanks

1 Like

Your switch node is configured incorrectly. It should be configured like the example I've shown (i.e. a Boolean false, not a text "false").

shucks, I forgot to switch it back. I've been messing with it for a bit to try and figure it out on my own with no luck. I've switched it back, with no luck.
image

Is it right after the split node?

You can import this and see if it works any better ....

[{"id":"be3268ab.79c57","type":"geofence","z":"d2e68e8c.6477a","name":"AtRouses","mode":"polyline","inside":"true","rad":0,"points":[{"latitude":29.97568117113383,"longitude":-90.15188913792372},{"latitude":29.974612387511083,"longitude":-90.1519213244319},{"latitude":29.974435804762187,"longitude":-90.1513097807765},{"latitude":29.974314984805783,"longitude":-90.14988284558056},{"latitude":29.975532471492357,"longitude":-90.14977555721998},{"latitude":29.97566258369083,"longitude":-90.15061240643263},{"latitude":29.975709052291826,"longitude":-90.1517067477107}],"centre":{},"x":2680,"y":320,"wires":[["abe605f8.82752"]]},{"id":"abe605f8.82752","type":"alexa-remote-list","z":"d2e68e8c.6477a","name":"Rouses List","account":"5b3978bd.f4d4e8","config":{"option":"getListItems","value":{"list":{"type":"str","value":"7b91aa1b-2e56-4cd6-af44-44475866c939"}}},"x":2850,"y":320,"wires":[["70f58b54.4ea5b4"]]},{"id":"70f58b54.4ea5b4","type":"split","z":"d2e68e8c.6477a","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":3010,"y":320,"wires":[["61aa6849.d099a"]]},{"id":"61aa6849.d099a","type":"switch","z":"d2e68e8c.6477a","name":"","property":"payload.completed","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":3150,"y":320,"wires":[["163f6897.ee476f"]]},{"id":"163f6897.ee476f","type":"change","z":"d2e68e8c.6477a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3320,"y":320,"wires":[["aa96cde3.4f61a"]]},{"id":"aa96cde3.4f61a","type":"join","z":"d2e68e8c.6477a","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":3490,"y":320,"wires":[["c2d7b0e2.be5a58"]]},{"id":"c2d7b0e2.be5a58","type":"change","z":"d2e68e8c.6477a","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Costco shopping list","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3660,"y":320,"wires":[["257f44c3.b381bc"]]},{"id":"5b3978bd.f4d4e8","type":"alexa-remote-account","name":"Alexa","authMethod":"proxy","proxyOwnIp":"192.168.1.4","proxyPort":"3456","cookieFile":"/home/odroid/.node-red/alexa-save","refreshInterval":"1","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.com","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

yep. Imported yours to try, same issue. I can drop a debug after the split, I get of course the entire list split out with all data. Drop it after the switch, nothing. Remove the switch and drop at the end, get the list in the correct format with both complete and non-complete items. I feel like I've got to be missing something simple.

[{"id":"7c25dd76.ee0164","type":"alexa-remote-list","z":"83cf4a1e.276758","name":"","account":"732a8c72.2818f4","config":{"option":"getListItems","value":{"list":{"type":"str","value":"4c575edf-d412-4751-a343-8b63888d5bc5"}}},"x":440,"y":4580,"wires":[["cf310529.571dd8"]]},{"id":"8ba0fbce.cf1398","type":"debug","z":"83cf4a1e.276758","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1320,"y":4640,"wires":[]},{"id":"8514fb97.527148","type":"inject","z":"83cf4a1e.276758","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":4680,"wires":[["7c25dd76.ee0164"]]},{"id":"cf310529.571dd8","type":"split","z":"83cf4a1e.276758","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":590,"y":4580,"wires":[["ab3e6166.6b522"]]},{"id":"ab3e6166.6b522","type":"switch","z":"83cf4a1e.276758","name":"","property":"payload.completed","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":4580,"wires":[["914bedea.f82b2"]]},{"id":"914bedea.f82b2","type":"change","z":"83cf4a1e.276758","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":4580,"wires":[["8a0cbb61.684928"]]},{"id":"8a0cbb61.684928","type":"join","z":"83cf4a1e.276758","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1070,"y":4580,"wires":[["ff46dfc8.03c2a"]]},{"id":"ff46dfc8.03c2a","type":"change","z":"83cf4a1e.276758","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Costco shopping list","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1240,"y":4580,"wires":[["8ba0fbce.cf1398"]]},{"id":"732a8c72.2818f4","type":"alexa-remote-account","z":"","name":"","authMethod":"proxy","proxyOwnIp":"10.0.0.122:1880","proxyPort":"3457","cookieFile":"fileauth","refreshInterval":"","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.com","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

That's how I've got it currently setup on my end; at the moment I've just dropped an inject on the front end and debug on the end.

I just imported your sequence and it works as intended ....

So that's just weird that it doesn't work on your NR installation ..... (fwiw, I'm on NR 1.2.6)

1 Like

That weird I also running NR 1.2.6 and I can get the message to the set msg.payload node but it doesn't go to the join node?? it just stop at the msg.payload for some reason. Is there something we can try? I did change the payload in the join node but had no luck.

hmmm...I haven't updated to 1.2.6 yet. But that narrows it down to something on my end, I'll update and see if that sorts it. thanks for checking

How does the cancelable flow work?

Screen Shot 2020-12-10 at 7.06.15 AM

When Motion ends, the message hits Active/Inactive switch and is NOT sent to Cancelable, but to the Timer, which starts the delay.

When Motion occurs, the message hits Active/Inactive switch and is sent to Cancelable, which generates a STOP to the timer. Reseting it. The message also goes to Time Range and the light(s) go the desired value.. bright if within the range, 10% if not.

This is a Flow that demonstrates the difference between message Content and simply a message at all. The Hubitat Command Node doesn't inspect the message. If a message gets that far, it sends the command to Hubitat. Thus a message Content of "Stop" will turn on/off a switch. However, the Timer node does care about the Content.. it specifically looks for "stop". All other messages, mean Start, but it looks for one specific message Content.

3 Likes

@edhall1044 I looked through our list and was surprised we did not have a good "cancel-able" example, so here ya go.

Title: Motion lighting with cancel-able delay

Summary - This sequence uses two motion sensors turning on a light if either sense motion. When motion stops a 1 minutes timer begins. Motion on either sensor will send STOP (cancel) to the timer. Once motion stops at both sensors the light will go off after 1 minute.

Sequence

[{"id":"83a88897.e4cb58","type":"group","z":"d527bfaa.c3979","name":"On/Off w/Motion","style":{"fill":"#ffff7f","label":true},"nodes":["6f219364.b4821c","efeedf23.3f0d5","f1423ee3.2923b","97f24f13.25512","fe9afb30.56d878","56c03c9c.dfbbe4","9acd7411.c18c08","19bef9ac.4def06","4c18299f.8bb308","416ab02a.572b","e812a1ca.d86b","a5044674.f5a008","aa381ed6.6d9dd","c6636192.f819a","f7f46737.666868"],"x":174,"y":1749.0000009536743,"w":1170.9999237060547,"h":209.00024318695068},{"id":"6f219364.b4821c","type":"hubitat device","z":"d527bfaa.c3979","g":"83a88897.e4cb58","name":"Office Bench Motion","server":"c0da6dea.8576a","deviceId":"2375","attribute":"motion","sendEvent":true,"x":300,"y":1820,"wires":[["f1423ee3.2923b","a5044674.f5a008"]]},{"id":"efeedf23.3f0d5","type":"hubitat command","z":"d527bfaa.c3979","g":"83a88897.e4cb58","deviceLabel":"","name":"On","server":"e03140c5.bed32","deviceId":"1431","command":"on","commandArgs":"","x":665.9999847412109,"y":1850.0000009536743,"wires":[["f7f46737.666868"]]},{"id":"f1423ee3.2923b","type":"switch","z":"d527bfaa.c3979","g":"83a88897.e4cb58","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":495.99998474121094,"y":1850.0000009536743,"wires":[["efeedf23.3f0d5"],[]]},{"id":"97f24f13.25512","type":"hubitat command","z":"d527bfaa.c3979","g":"83a88897.e4cb58","name":"Off","server":"e03140c5.bed32","deviceId":"1431","command":"off","commandArgs":"","x":1268.9999237060547,"y":1910.999451637268,"wires":[[]]},{"id":"fe9afb30.56d878","type":"hubitat device","z":"d527bfaa.c3979","g":"83a88897.e4cb58","name":"Office Desk Motion","server":"c0da6dea.8576a","deviceId":"2251","attribute":"motion","sendEvent":true,"x":310,"y":1880,"wires":[["f1423ee3.2923b","9acd7411.c18c08"]]},{"id":"56c03c9c.dfbbe4","type":"hubitat device","z":"d527bfaa.c3979","g":"83a88897.e4cb58","name":"Office Bench Motion","server":"c0da6dea.8576a","deviceId":"2375","attribute":"motion","sendEvent":false,"x":715.9999847412109,"y":1910.0000009536743,"wires":[["19bef9ac.4def06"]]},{"id":"9acd7411.c18c08","type":"switch","z":"d527bfaa.c3979","g":"83a88897.e4cb58","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":495.99998474121094,"y":1910.0000009536743,"wires":[[],["56c03c9c.dfbbe4"]]},{"id":"19bef9ac.4def06","type":"switch","z":"d527bfaa.c3979","g":"83a88897.e4cb58","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":915.9999847412109,"y":1910.0000009536743,"wires":[[],["c6636192.f819a"]]},{"id":"4c18299f.8bb308","type":"hubitat command","z":"d527bfaa.c3979","g":"83a88897.e4cb58","name":"Off","server":"e03140c5.bed32","deviceId":"1431","command":"off","commandArgs":"","x":1268.9999237060547,"y":1790.999451637268,"wires":[[]]},{"id":"416ab02a.572b","type":"hubitat device","z":"d527bfaa.c3979","g":"83a88897.e4cb58","name":"Office Desk Motion","server":"c0da6dea.8576a","deviceId":"2251","attribute":"motion","sendEvent":false,"x":705.9999847412109,"y":1790.0000009536743,"wires":[["e812a1ca.d86b"]]},{"id":"e812a1ca.d86b","type":"switch","z":"d527bfaa.c3979","g":"83a88897.e4cb58","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":915.9999847412109,"y":1790.0000009536743,"wires":[[],["aa381ed6.6d9dd"]]},{"id":"a5044674.f5a008","type":"switch","z":"d527bfaa.c3979","g":"83a88897.e4cb58","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":495.99998474121094,"y":1790.0000009536743,"wires":[[],["416ab02a.572b"]]},{"id":"aa381ed6.6d9dd","type":"stoptimer","z":"d527bfaa.c3979","g":"83a88897.e4cb58","duration":"1","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":1114.00004196167,"y":1797.000244140625,"wires":[["4c18299f.8bb308"],[]]},{"id":"c6636192.f819a","type":"stoptimer","z":"d527bfaa.c3979","g":"83a88897.e4cb58","duration":"1","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":1114.00004196167,"y":1917.000244140625,"wires":[["97f24f13.25512"],[]]},{"id":"f7f46737.666868","type":"change","z":"d527bfaa.c3979","g":"83a88897.e4cb58","name":"Send STOP","rules":[{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":905.9999847412109,"y":1850.0000009536743,"wires":[["aa381ed6.6d9dd","c6636192.f819a"]]},{"id":"c0da6dea.8576a","type":"hubitat config","name":"ZigBee Hub","usetls":false,"host":"10.13.9.11","port":"80","appId":"2532","nodeRedServer":"http://10.13.9.28:1880","webhookPath":"/hubitat/webhook__","autoRefresh":true,"useWebsocket":false},{"id":"e03140c5.bed32","type":"hubitat config","name":"Apps Hub","usetls":false,"host":"10.13.9.12","port":"80","appId":"899","nodeRedServer":"http://10.13.9.28:1880","webhookPath":"/hubitat/webhook___","autoRefresh":true,"useWebsocket":false}]

1 Like