This flow detects if hosts are presence in the network based on MAC adres. It does this by using a program called arp-scan. Arp-scan can be installed via: "sudo apt-get install arp-scan"
-
-
Save Fab85/280e9b116d7fea84ade5 to your computer and use it in GitHub Desktop.
[{"id":"4eee93b4.b1116c","type":"function","z":"1b72c880.e48d38","name":"Detect Presence","func":"const triggers = 10;\nconst MAC = \"00:00:00:00:00:00\";\nvar count = context.count||0;\n\nif(msg.payload.indexOf(MAC)>0){\n if(count < 1){\n msg.payload = 1;\n count = triggers;\n context.count = count;\n return msg;\n }else count = triggers;\n \n}else{\n count -= 1;\n if(count === 0){\n msg.payload = 0;\n context.count = count;\n return msg;\n }else if(count < 0){\n count = 0; \n }\n}\ncontext.count = count;\n","outputs":1,"noerr":0,"x":522,"y":247,"wires":[["f47394e8.0b8c68"]]},{"id":"7e3bc8dd.81c438","type":"exec","z":"1b72c880.e48d38","command":"sudo arp-scan --interface=eth0 --localnet","addpay":false,"append":"","useSpawn":"","name":"Arp-Scan","x":327,"y":259.5,"wires":[["4eee93b4.b1116c"],[],[]]},{"id":"7547f391.8ab80c","type":"inject","z":"1b72c880.e48d38","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"10","crontab":"","once":true,"x":102,"y":260,"wires":[["7e3bc8dd.81c438"]]},{"id":"f47394e8.0b8c68","type":"debug","z":"1b72c880.e48d38","name":"","active":true,"console":"false","complete":"false","x":732,"y":245,"wires":[]}] |
I love this too. Had to make some timing adjustments for my network but one I determined that the mac used all lower case letters I was fine. Has anyone else noticed that a significant number of routers display them in all upper case.
I really only get output when the MAC is found and nothing when not. Looks like it is designed create a payload of zero and then send it in the else statement. Has anyone been able to get a negative msg.payload from it as written? If all else fails I will reverse the logic and see what happens. I also actually use this on my linux VM to help identify systems from MACs. (the use of MAC is not intended to represent Apple Computers or any device. document, concept or neuron pattern owned wholly or in part by Apple Computers)
I can't believe, I'm the first to comment here!
Your solution is as simple as it is genious!
THAT was exactly what I was looking for.
Thank you for publishing this! You made my day!