Apple Devices on World Map
Introduction
The flow demonstrates how to retrieve the location of all apple devices and display then onto a world map.
Dependencies
The following nodes need to be installed beforehand: node-red-contrib-web-worldmap node-red-apple-find-me
Description
The apple node gets a list of the devices that are registered with the Apple-ID. The transform nodes simply splits the device lists into single location markers- The world map node creates a map which can be accessed under your node-red url as follows: http://localhost:1880/apple/
[{"id":"bfd5c876.c1b5e8","type":"worldmap","z":"5a923ee4.dc9ad","name":"Web","lat":"47.93301323574526","lon":"10.719556690177056","zoom":"16","layer":"OSM","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"true","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","path":"/apple","x":660,"y":240,"wires":[]},{"id":"c1e0927.374587","type":"apple-find-me","z":"5a923ee4.dc9ad","account":"afbe23e2.8c1a8","name":"","triggerInterval":"60000","geoAPI":"OSM","hereMapApiKey":"","googleMapsApiKey":"","places":[{"name":"Home","lat":"47.93301323574526","lon":"10.719556690177056"}],"x":230,"y":240,"wires":[["1205802e.c595b","f1202f12.f0b0f","1b19c66.108ef3a"]]},{"id":"1205802e.c595b","type":"function","z":"5a923ee4.dc9ad","name":"Transform iPhones","func":"var devices = msg.payload.iPhone;\nif(devices !== null){\n devices.forEach(function(entry) {\n if(entry.locationInfo !== null && !entry.locationInfo.isInaccurate){\n var data = {\n name : entry.displayName, \n label : entry.displayName,\n lat : entry.locationInfo.latitude, \n lon : entry.locationInfo.longitude,\n icon : \"mobile\",\n iconColor : \"darkred\",\n extrainfo : entry.modelName + \" (\" + entry.refreshTimeStamp + \")\",\n photoUrl : entry.modelImageLink\n };\n var newMsg = {\n payload : data\n };\n node.send(newMsg);\n }\n });\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":220,"wires":[["bfd5c876.c1b5e8"]]},{"id":"f1202f12.f0b0f","type":"debug","z":"5a923ee4.dc9ad","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":120,"wires":[]},{"id":"1b19c66.108ef3a","type":"function","z":"5a923ee4.dc9ad","name":"Transform iPads","func":"var devices = msg.payload.iPad;\nif(devices !== null){\n devices.forEach(function(entry) {\n if(entry.locationInfo !== null && !entry.locationInfo.isInaccurate){\n var data = {\n name : entry.displayName, \n label : entry.displayName,\n lat : entry.locationInfo.latitude, \n lon : entry.locationInfo.longitude,\n icon : \"tablet\",\n iconColor : \"darkblue\",\n extrainfo : entry.modelName + \" (\" + entry.refreshTimeStamp + \")\",\n photoUrl : entry.modelImageLink\n };\n var newMsg = {\n payload : data\n };\n node.send(newMsg);\n }\n });\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":280,"wires":[["bfd5c876.c1b5e8"]]},{"id":"afbe23e2.8c1a8","type":"apple-find-me-account","z":"","name":"","showfmly":true}]