Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
10k_giveaway_node-red_flow
[{"id":"1d5440f5.6d729f","type":"tab","label":"10k giveaway","disabled":false,"info":""},{"id":"867aa0be.203158","type":"inject","z":"1d5440f5.6d729f","name":"start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":40,"wires":[["c058f7a7.1cf59"]]},{"id":"9cdae97a.a6ed98","type":"csv","z":"1d5440f5.6d729f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":110,"y":140,"wires":[["60a8653c.c99764"]]},{"id":"c058f7a7.1cf59","type":"template","z":"1d5440f5.6d729f","name":"IDs, Names, Comments ","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"id,name,comment\n1,Alex Vanhecke,Im the first\n2,jaga vj,Is there any innervation use of AirTag in HA.....?\n3,Knax,My AirTag should come in a view days... I think I put it on my Bike...Thanks for the nice Video :)\n4,Stanislav Stoynov,Thank you for the cool video\n5,DJAX,Use NFC Tags to do the same for much cheaper\n6,Chris Pinnington,Ca’t wait for my AirTags to arrive thanks for the tips\n7,Jason Guest,Nice channel. Thank you for taking the time to share.\n8,Mathieu Lacroix,I love your videos long live Thursdays to see the new ones. Continue like that because they are quality videos and not HARD :)\n9,M M, I hope there will be a home Assistant support for AirTag\n10,Martin de Bernardo,That is a neat trick using an AirTag for a shortcut trigger.\n11,Dave Garaffa,Great video as always my brother!\n12,Jesse G.,The content you choose is what makes all my automation and devices \"home smart but not hard\" - Great video KP.\n13,MEtfan,Great Video!\n14,Harun van Maurik,Great video keep up the good work! Congrats with the 10k subscribers and till next Wednesday!\n15,Street Freaks Racing Videos,Pretty cool and congrats on the 10000. I saw someone did a similar automation except it send their wife the eta corrected for current traffic conditions! But I can't remember who made that video.\n16,Ron M,Congratulations on the 10K Kiril and thank you. \n17,Kim Vognsen,Love Denmark\n18,Hamad Almarri,Cool\n19,Mathieu Sibilla,As usual excellent video KP!\n","output":"str","x":310,"y":40,"wires":[["9cdae97a.a6ed98"]]},{"id":"b30d1a94.4190f8","type":"debug","z":"1d5440f5.6d729f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":140,"wires":[]},{"id":"60a8653c.c99764","type":"join","z":"1d5440f5.6d729f","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":230,"y":140,"wires":[["9a0aa17a.347e78"]]},{"id":"9a0aa17a.347e78","type":"function","z":"1d5440f5.6d729f","name":"","func":"var arr = [];\nvar participants = 19;\nvar winners = 10;\nwhile (arr.length < winners) {\n var randomNum = Math.floor(Math.random() * participants);\n if(arr.indexOf(randomNum) === -1) {\n arr.push(randomNum);\n var newMsg = {};\n newMsg.payload = msg.payload[randomNum];\n node.send(newMsg);\n }\n}\n\n// return only one row/winner\n/*\nrandomNum = Math.floor(Math.random() * 19);\nmsg.payload = \"ID: \" + msg.payload[randomNum].id +\n \", NAME: \" + msg.payload[randomNum].name +\n \", COMMENT: \" + msg.payload[randomNum].comment;\nreturn msg; \n\n}*/","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":140,"wires":[["b30d1a94.4190f8"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment