My friend has sorted it out:
It works like a charm. I have the script on my Node Red server (it is separate from my HA server) and from within NR run it every 5 mins using the script node.
What it does is the first time it runs a full scan and populates a list of all network devices (bit like the old known_devices.yaml
is suppose). Then every 5 mins it runs again and compares the output against this file and pipes out any new devices.
[{"id":"8297d552.5ccb3","type":"exec","z":"9072b774.d4ad9","command":"python /root/network-monitor/network-monitor.py","addpay":true,"append":"","useSpawn":"false","timer":"120","oldrc":false,"name":"Check Net","x":330,"y":640,"wires":[["53c115f7.d3878c","327184a0.03ae0c"],[],[]]},{"id":"819a2d52.30ea18","type":"inject","z":"9072b774.d4ad9","name":"","topic":"","payload":"","payloadType":"date","repeat":"900","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":640,"wires":[["8297d552.5ccb3"]]},{"id":"53c115f7.d3878c","type":"switch","z":"9072b774.d4ad9","name":"","property":"payload","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":490,"y":620,"wires":[["80753070.cd63e8"]]},{"id":"80753070.cd63e8","type":"function","z":"9072b774.d4ad9","name":"","func":"msgtext = msg.payload;\nmsg.payload = {\"data\": {\"title\": \"New Network Device Alert\",\"message\": msgtext,\"data\":{\"push\":{\"sound\":{\"name\":\"default\"}}}}};\nnode.status({fill:\"green\",shape:\"ring\",text:msgtext});\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":620,"wires":[["8bd96b1f.c14828"]]},{"id":"8bd96b1f.c14828","type":"api-call-service","z":"9072b774.d4ad9","name":"iOS Mark","server":"d8c83d48.4dc3f","version":1,"debugenabled":false,"service_domain":"notify","service":"ios_mark_iphone_8_plus","entityId":"","data":"{}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":840,"y":600,"wires":[[]]},{"id":"327184a0.03ae0c","type":"debug","z":"9072b774.d4ad9","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":490,"y":560,"wires":[]},{"id":"d8c83d48.4dc3f","type":"server","z":"","name":"HA","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
I hope that helps anyone - I cannot take credit for the code, and it seems to work perfectly for me in NR. I am sure the script can be as an automation in HA too.
cheers
mb