Skip to content

Instantly share code, notes, and snippets.

@hgavert
Created March 26, 2021 11:27
Show Gist options
  • Save hgavert/45c4e6d65702cbfec83689e32a549482 to your computer and use it in GitHub Desktop.
Save hgavert/45c4e6d65702cbfec83689e32a549482 to your computer and use it in GitHub Desktop.
Node-RED RuuviTag scanning sub-flow
[{"id":"6480da.d93d7f28","type":"subflow","name":"RuuviTag scanning","info":"","category":"","in":[],"out":[{"x":1480,"y":180,"wires":[{"id":"c9ba8525.266648","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"9a6ad327.1492f8","type":"function","z":"6480da.d93d7f28","name":"Stop scanning","func":"msg.payload.scan=false;\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":100,"wires":[["ddf1ec6f.5dcf"]]},{"id":"43844f9d.dc98c","type":"inject","z":"6480da.d93d7f28","name":"Start scanning (interval)","topic":"","payload":"{\"scan\": true}","payloadType":"json","repeat":"60","crontab":"","once":true,"onceDelay":"1.0","x":150,"y":200,"wires":[["9a6ad327.1492f8","ca0944a3.c6315","b3655771.475a28"]]},{"id":"ddf1ec6f.5dcf","type":"delay","z":"6480da.d93d7f28","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":580,"y":100,"wires":[["ca0944a3.c6315","b3655771.475a28"]]},{"id":"ca0944a3.c6315","type":"debug","z":"6480da.d93d7f28","name":"Debug: start and stop of scanning","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":880,"y":120,"wires":[]},{"id":"b3655771.475a28","type":"scan ble","z":"6480da.d93d7f28","uuids":"","duplicates":false,"name":"","x":810,"y":200,"wires":[["510e8b85.8050a4"]]},{"id":"5ab980ab.82c3a","type":"debug","z":"6480da.d93d7f28","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1510,"y":80,"wires":[]},{"id":"d4461b9b.d35718","type":"ruuvitag","z":"6480da.d93d7f28","name":"","x":1160,"y":180,"wires":[["c9ba8525.266648"]]},{"id":"510e8b85.8050a4","type":"function","z":"6480da.d93d7f28","name":"Filter RUUVI","func":"//msg1 = {};\n//msg2 = {};\n\nif(!msg.advertisement || !msg.advertisement.manufacturerData) {\n return [null, null];\n} else {\n data = msg.advertisement.manufacturerData;\n alfa = data[0] + data[1] * 256;\n if( alfa == 0x499) { // Ruuvi\n //msg1.payload = msg;\n return [msg, null];\n } else {\n return [null, msg];\n }\n}\n","outputs":2,"noerr":0,"x":990,"y":200,"wires":[["d4461b9b.d35718"],["9eb412be.8f10e"]]},{"id":"9eb412be.8f10e","type":"debug","z":"6480da.d93d7f28","name":"Others than RuuviTag","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1220,"y":240,"wires":[]},{"id":"c9ba8525.266648","type":"function","z":"6480da.d93d7f28","name":"Ruuvi to JSON","func":"\nnewMsg = msg;\n\nnewMsg.payload = JSON.parse(msg.payload);\n\nreturn newMsg;","outputs":1,"noerr":0,"x":1320,"y":180,"wires":[["5ab980ab.82c3a"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment