Node-Red Flow Samples/Sharing

Hour seriously? Guess I take Krispy Kreme for granted growing up near where they got started. Was interesting to watch when I lived in CA as they were opening stores and people would be carrying 2 dozen in the airport as if they were precious goods.

2 Likes

I did get two dozen. I gave one dozen to my godson's parents (mom is expecting his younger brother). I gave half-a-dozen to a medical resident that lives down the street. Not sure what happened to the last half-dozen. Couldn't be me - I'm diabetic.

3 Likes

There's a famous outlet in Japan next to our office there where I was told people used to queue down the street every day when it first opened. This practice continued for several years apparently, it was so so popular. Love 'em but they're not good for my diet (which is not really a diet at all, it's more just wishful thinking really) :rofl:

3 Likes

Donuts, too.

3 Likes

Bad donuts are hardware. KKs are definitely software.

3 Likes

Title - Randomized greeting/departure announcement

Summary - This one will take a little bit of work to convert to the HE node pallet, but somebody adventurous can give it a go (I'm looking at you @aaiyar since you've got the wait conditions with loops figured out :stuck_out_tongue: ). I have lots of fun with this one.

This is triggered by presence arrival/departure for 2 people. Checks who arrived (or both) within the past 5 minutes, chooses a randomized arrival greeting, waits for door to open and then close and speaks the random greeting on Alexa. Could easily be expanded to support more people by expanding the names in the unsafe-function node.
Picture -

Flow

[{"id":"fe22ec90.1f7b4","type":"ha-get-entities","z":"43efc72.aa76338","server":"94fdcfdf.a00b","name":"","rules":[{"property":"entity_id","logic":"includes","value":"switch.mike_presence, switch.ashley_presence","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"},{"property":"timeSinceChangedMs","logic":"lt","value":"300000","valueType":"num"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":130,"y":460,"wires":[["dce1b1d1.9a685"]]},{"id":"dce1b1d1.9a685","type":"template","z":"43efc72.aa76338","name":"Format Names","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.attributes.friendly_name}}","output":"str","x":300,"y":460,"wires":[["c675d5c9.a6bdd8"]]},{"id":"c675d5c9.a6bdd8","type":"join","z":"43efc72.aa76338","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":", ","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":450,"y":460,"wires":[["eef7b7e8.d8c558"]]},{"id":"eef7b7e8.d8c558","type":"unsafe-function","z":"43efc72.aa76338","name":"Random Message","func":"var device=msg.payload\nmsg.payload = {};\nmsg.payload.domain = {};\nmsg.payload.service = {};\nmsg.payload.data = {};\nmsg.payload.data.data = {};\nmsg.payload.data.data.type = {};\nmsg.payload.data.message = {};\n\nif (device == 'Mike - Presence') {\n var name = 'Mike';\n var isAre = 'is';\n} else if (device === 'OTHER - Presence') {\n var name = 'OTHER';\n var isAre = 'is';\n} else if (device == 'Mike - Presence, OTHER - Presence' || device == 'OTHER - Presence, Mike - Presence') {\n var name ='Mike and OTHER';\n var isAre = 'are';\n}\n\nvar messageOpening = [\n "Welcome Home",\n "How you doing",\n "What's up",\n "Long time no see",\n "Hey",\n "Nice to see you",\n "Look who's home, it's",\n "Nice to have you back",\n "Howdy do",\n "What's going on",\n "How is everything",\n "It's feels like ages since I've seen you",\n "Where have you been hiding",\n "How's it hanging",\n "What's cookin",\n "What's shakin",\n "Greetings and salutations",\n "How goes it",\n "What's happening",\n "How goes it",\n "Roll out the red carpet for"\n];\n\nvar messageClosing = [\n "in the house! Ooo oooo",\n "here.",\n "home.",\n "joining the party",\n "crashing the party",\n "gracing us with their presence",\n "dropping anchor",\n "dropping in",\n "making the scene",\n "barging in",\n "showing up",\n "blowing in",\n "appearing",\n "breezing in",\n "rolling in",\n "popping in",\n "finally home"\n];\n\n\nvar randomOpening = messageOpening[Math.floor(Math.random()*messageOpening.length)];\nvar randomClosing = messageClosing[Math.floor(Math.random()*messageClosing.length)];\nvar message = randomOpening + " " + name + "." + " " + name + " " + isAre + " " + randomClosing\n\nmsg.payload.domain = "notify"\nmsg.payload.service = "alexa_media_front_entrance_echo_dot"\nmsg.payload.data.data.type = "announce"\nmsg.payload.data.message = message\n\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":460,"wires":[["b4e71139.15e7b"]]},{"id":"b4e71139.15e7b","type":"ha-wait-until","z":"43efc72.aa76338","name":"Door Opens","server":"94fdcfdf.a00b","outputs":2,"entityId":"binary_sensor.garage_door","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"5","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":790,"y":460,"wires":[["e9446d66.c088b"],[]]},{"id":"e9446d66.c088b","type":"ha-wait-until","z":"43efc72.aa76338","name":"Door Closes","server":"94fdcfdf.a00b","outputs":2,"entityId":"binary_sensor.garage_door","entityIdFilterType":"exact","property":"state","comparator":"is","value":"off","valueType":"str","timeout":"5","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":950,"y":460,"wires":[["9a733390.064f4"],[]]},{"id":"9a733390.064f4","type":"api-call-service","z":"43efc72.aa76338","name":"Speak Message","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media_front_entrance_echo_dot","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1120,"y":460,"wires":[[]]},{"id":"b1e2d385.f986d","type":"ha-get-entities","z":"43efc72.aa76338","server":"94fdcfdf.a00b","name":"","rules":[{"property":"entity_id","logic":"includes","value":"switch.mike_presence, switch.ashley_presence","valueType":"str"},{"property":"state","logic":"is","value":"off","valueType":"str"},{"property":"timeSinceChangedMs","logic":"lt","value":"300000","valueType":"num"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":130,"y":560,"wires":[["c069c1d8.2ffeb"]]},{"id":"c069c1d8.2ffeb","type":"template","z":"43efc72.aa76338","name":"Format Names","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.attributes.friendly_name}}","output":"str","x":300,"y":560,"wires":[["b1e03b81.244208"]]},{"id":"b1e03b81.244208","type":"join","z":"43efc72.aa76338","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":", ","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":450,"y":560,"wires":[["ee858f3e.2a157"]]},{"id":"ee858f3e.2a157","type":"unsafe-function","z":"43efc72.aa76338","name":"Random Message","func":"var device=msg.payload\nmsg.payload = {};\nmsg.payload.domain = {};\nmsg.payload.service = {};\nmsg.payload.data = {};\nmsg.payload.data.data = {};\nmsg.payload.data.data.type = {};\nmsg.payload.data.message = {};\n\nif (device == 'Mike - Presence') {\n var name = 'Mike';\n var hasHave = 'has';\n} else if (device === 'OTHER - Presence') {\n var name = 'OTHER';\n var hasHave = 'has';\n} else if (device == 'Mike - Presence, OTHER - Presence' || device == 'OTHER - Presence, Mike - Presence') {\n var name ='Mike and OTHER';\n var hasHave = 'have';\n}\n\nvar messageOpening = [\n "Goodbye",\n "See you later",\n "Bye",\n "Live long and prosper",\n "Farewell",\n "Hope you have a great time",\n "Take care",\n "Smell you later",\n "Adios",\n "Caio",\n "Au revoir",\n "Sayonara",\n "Ta Ta for now",\n "Catch you later",\n "To-da-loo",\n "See you in the funny papers",\n "Toodles",\n "Godspeed",\n "So long",\n "Cheerio",\n "Arrivederci"\n];\n\nvar messageClosing = [\n "left the building",\n "gone out",\n "popped out",\n "left",\n "buggered off",\n "departed",\n "split",\n "vamoosed",\n "high tailed it",\n "escaped",\n "eight-six'd it",\n "bid farewell",\n "flaked off",\n "took a hike",\n "withdrawn",\n "exited",\n "vanished",\n "disappeared",\n "evacuated",\n "retreated",\n "taken their leave"\n];\n\n\nvar randomOpening = messageOpening[Math.floor(Math.random()*messageOpening.length)];\nvar randomClosing = messageClosing[Math.floor(Math.random()*messageClosing.length)];\nvar message = randomOpening + " " + name + "." + " " + name + " " + hasHave + " " + randomClosing\n\nmsg.payload.domain = "notify"\nmsg.payload.service = "alexa_media_front_entrance_echo_dot"\nmsg.payload.data.data.type = "announce"\nmsg.payload.data.message = message\n\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":560,"wires":[["904ffb9e.c47158"]]},{"id":"904ffb9e.c47158","type":"delay","z":"43efc72.aa76338","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":780,"y":560,"wires":[["8cf021e4.e7e3e"]]},{"id":"8cf021e4.e7e3e","type":"api-call-service","z":"43efc72.aa76338","name":"Speak Message","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media_front_entrance_echo_dot","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":940,"y":560,"wires":[[]]},{"id":"893c5b2b.7de1f8","type":"comment","z":"43efc72.aa76338","name":"Announce departue","info":"","x":150,"y":520,"wires":[]},{"id":"46989487.63407c","type":"comment","z":"43efc72.aa76338","name":"Announce arrival","info":"","x":140,"y":420,"wires":[]},{"id":"94fdcfdf.a00b","type":"server","z":"","name":"Home Assistant","addon":true}]

2 Likes

I tried to import your flow because, for one, it's cool. But I keep getting this error
image
When I look at it, the code looks consistent to me, but I know about enough to be dangerous. Why the error? How do you fix it? Like, what's wrong? I'm sorry to be so curious. Helps me learn.

1 Like

interesting we had the same kind of issue with @aaiyar network monitoring code

1 Like

Yeah - it has a link out. When I’m back from my walk, I’ll fix it .... my bad

Just shared a flow with someone else and got a syntax error and he actually tried to copy and paste the flow back in to his node red and got the same error on something that's already created in HIS node red. Could this be a bug?

I suspect that something is being changed by posting it

maybe try using
code tags

test
more test

the error I am getting
at position 2060
font color="cyan">{{msg.

C in Cyan being highlighted

@pat.richards @TechMedX

Would you mind importing it again? It should work now. I removed the link out/in nodes and tested importing it. The modified flow is in my original response (further up this thread).

Sorry about the hassle.

1 Like

same error same place

1 Like

It imports fine for me and is in a code block. So was the original ... very puzzling.

version of nodered? I am on 1.1.2

1 Like

1.1.0

Try this - without hide details turned on. Still in a code-block.

[{"id":"f11a13be.36e21","type":"simpletime","z":"641677fe.7efb8","name":"","x":410,"y":660,"wires":[["c48f441a.c64868","12bb40d7.cee35f"]]},{"id":"c48f441a.c64868","type":"template","z":"641677fe.7efb8","name":"time","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{mydate}} {{mytimes}}","output":"str","x":650,"y":620,"wires":[["ef753891.93342"]]},{"id":"12bb40d7.cee35f","type":"switch","z":"641677fe.7efb8","name":"down < 100","property":"payload.speeds.download","propertyType":"msg","rules":[{"t":"lt","v":"100","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":820,"wires":[["ff368af4.ae96d"]]},{"id":"9e3f58fe.e530e","type":"speedtest","z":"641677fe.7efb8","name":"Speedtest","serverId":"","maxTime":"120000","x":410,"y":600,"wires":[["aa623598.74eb98","b2a90ab2.32421","dbc3c3e7.20861","6755d730.02674","a012c307.cb4028","f11a13be.36e21"]]},{"id":"ef753891.93342","type":"ui_text","z":"641677fe.7efb8","group":"2a046f7e.21973","order":6,"width":0,"height":0,"name":"Last Speedtest","label":"Last Speedtest","format":"<font color=\"cyan\">{{msg.payload}}</font>","layout":"col-center","x":920,"y":620,"wires":[]},{"id":"ff368af4.ae96d","type":"change","z":"641677fe.7efb8","name":"Speed Test","rules":[{"t":"set","p":"topic","pt":"msg","to":"Speed Test","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":820,"wires":[["aa219933.4c2e6"]]},{"id":"aa623598.74eb98","type":"change","z":"641677fe.7efb8","name":"download","rules":[{"t":"set","p":"topic","pt":"msg","to":"Download","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"payload.speeds.download","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":540,"wires":[["b61f1f5e.41d8b8","288318fc.e25458"]]},{"id":"b2a90ab2.32421","type":"change","z":"641677fe.7efb8","name":"upload","rules":[{"t":"set","p":"topic","pt":"msg","to":"Upload","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"payload.speeds.upload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":580,"wires":[["bd35f52c.df077","288318fc.e25458"]]},{"id":"dbc3c3e7.20861","type":"change","z":"641677fe.7efb8","name":"ping","rules":[{"t":"set","p":"topic","pt":"msg","to":"Ping","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"payload.server.ping","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":660,"wires":[["8b605dac.f72bd","1ee5385b.d78bb"]]},{"id":"6755d730.02674","type":"change","z":"641677fe.7efb8","name":"distance","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.server.distanceMi","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Distance","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":700,"wires":[["4402db66.176ac4","1ee5385b.d78bb"]]},{"id":"a012c307.cb4028","type":"change","z":"641677fe.7efb8","name":"ISP","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.server.sponsor","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":740,"wires":[["ce98fa70.5faaa"]]},{"id":"9015ffc1.ef6a1","type":"ui_button","z":"641677fe.7efb8","name":"","group":"2a046f7e.21973","order":3,"width":0,"height":0,"label":"SpeedTest Now!","color":"","icon":"","payload":"","payloadType":"date","topic":"","x":190,"y":560,"wires":[["9e3f58fe.e530e"]]},{"id":"5493692d.1d584","type":"cronplus","z":"641677fe.7efb8","name":"5 minutes past the hour","outputField":"payload","timeZone":"","outputs":1,"options":[{"topic":"5 past every hour","payload":"start","type":"str","expression":"5 * * * *","name":"5 past every hour"}],"x":170,"y":640,"wires":[["9e3f58fe.e530e"]]},{"id":"aa219933.4c2e6","type":"template","z":"641677fe.7efb8","name":"SMS","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Internet speed was {{payload.speeds.download}}/{{payload.speeds.upload}} (down/up Mbits/s) at {{mytimes}} on {{mymonthn}}/{{mydom}}. Speedtest server was {{payload.server.sponsor}}.","output":"str","x":1010,"y":820,"wires":[["5b712b3b.4d3b0c"]]},{"id":"b61f1f5e.41d8b8","type":"ui_gauge","z":"641677fe.7efb8","name":"","group":"2a046f7e.21973","order":7,"width":0,"height":0,"gtype":"gage","title":"Download Speed","label":"Download Mbits","format":"{{value}}","min":0,"max":"150","colors":["#ff002d","#e4b400","#03f81f"],"seg1":"50","seg2":"100","x":930,"y":540,"wires":[]},{"id":"288318fc.e25458","type":"ui_chart","z":"641677fe.7efb8","name":"Performance Chart","group":"6dbda234.52c8cc","order":2,"width":12,"height":6,"label":"Performance Chart","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"86400","cutout":"","useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"x":930,"y":340,"wires":[["4860da2.4f503a4"]]},{"id":"bd35f52c.df077","type":"ui_gauge","z":"641677fe.7efb8","name":"","group":"2a046f7e.21973","order":8,"width":0,"height":0,"gtype":"gage","title":"Upload Speed","label":"Upload MBits","format":"{{value}}","min":0,"max":"15","colors":["#ff002d","#ffed36","#03f81f"],"seg1":"2","seg2":"8","x":920,"y":580,"wires":[]},{"id":"8b605dac.f72bd","type":"ui_text","z":"641677fe.7efb8","group":"2a046f7e.21973","order":4,"width":0,"height":0,"name":"","label":"Ping Time","format":"<font color=\"cyan\">{{msg.payload}}</font>","layout":"col-center","x":910,"y":660,"wires":[]},{"id":"1ee5385b.d78bb","type":"ui_chart","z":"641677fe.7efb8","name":"Latency Chart","group":"6dbda234.52c8cc","order":4,"width":12,"height":6,"label":"Latency Chart","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"86400","cutout":"","useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"x":920,"y":460,"wires":[["84fc2070.d9275"]]},{"id":"4402db66.176ac4","type":"ui_text","z":"641677fe.7efb8","group":"2a046f7e.21973","order":5,"width":0,"height":0,"name":"","label":"Distance","format":"<font color=\"cyan\">{{msg.payload}} mi</font>","layout":"col-center","x":900,"y":700,"wires":[]},{"id":"ce98fa70.5faaa","type":"ui_text","z":"641677fe.7efb8","group":"2a046f7e.21973","order":2,"width":0,"height":0,"name":"","label":"Hosted By","format":"<font color=\"cyan\">{{msg.payload}}</font>","layout":"col-center","x":910,"y":740,"wires":[]},{"id":"5b712b3b.4d3b0c","type":"e-mail","z":"641677fe.7efb8","server":"localhost","port":"25","secure":false,"tls":false,"name":"5042727138@msg.fi.google.com","dname":"SMS Notification","x":1190,"y":820,"wires":[]},{"id":"4860da2.4f503a4","type":"file","z":"641677fe.7efb8","name":"Speed Test Data Save","filename":"/home/odroid/.node-red/data/speedtest/speedtestData.json","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":1180,"y":340,"wires":[[]]},{"id":"976aad37.93366","type":"json","z":"641677fe.7efb8","name":"","x":1150,"y":280,"wires":[["288318fc.e25458"]]},{"id":"84fc2070.d9275","type":"file","z":"641677fe.7efb8","name":"Speed Test Data Save","filename":"/home/odroid/.node-red/data/speedtest/speedtestDataPD.json","appendNewline":false,"createDir":false,"overwriteFile":"true","x":1180,"y":420,"wires":[[]]},{"id":"1b6007eb.95fd98","type":"json","z":"641677fe.7efb8","name":"","x":1150,"y":520,"wires":[["1ee5385b.d78bb"]]},{"id":"559e7829.3d7fb","type":"file in","z":"641677fe.7efb8","name":"Speed Test Data Restore","filename":"/home/odroid/.node-red/data/speedtest/speedtestData.json","format":"utf8","x":1190,"y":380,"wires":[["976aad37.93366"]]},{"id":"1d72d587.de0bd2","type":"file in","z":"641677fe.7efb8","name":"Speed Test Data Restore","filename":"/home/odroid/.node-red/data/speedtest/speedtestDataPD.json","format":"utf8","x":1190,"y":460,"wires":[["1b6007eb.95fd98"]]},{"id":"e65149c6.542d","type":"inject","z":"641677fe.7efb8","name":"","repeat":"","crontab":"","once":true,"topic":"","payload":"restore","payloadType":"str","x":920,"y":400,"wires":[["559e7829.3d7fb","1d72d587.de0bd2"]]},{"id":"2a046f7e.21973","type":"ui_group","z":"","name":"Graphs","tab":"929d3236.90d2","order":1,"disp":false,"width":"6","collapse":false},{"id":"6dbda234.52c8cc","type":"ui_group","z":"","name":"Charts","tab":"929d3236.90d2","order":2,"disp":false,"width":"12","collapse":false},{"id":"929d3236.90d2","type":"ui_tab","z":"","name":"Internet Speed","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
2 Likes

that worked!

2 Likes

I'm trying to pipe HE's logs into NR logging using NR socket listener. I had seen a previous, non NR posting, on setup; of course cant it now...
TIA

Found it: ws://hubip/logsocket

2 Likes