Phone and weather bot

Connect your iPhone with location services on to the cloud. Get the latitude and longitude and the location of the phone. Get weather for that location.

[{"id":"c631ed57.8bbff","type":"inject","z":"509f464f.a27698","name":"Check weather","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":168.33334350585938,"y":315.8571472167969,"wires":[["e0aee73e.e0ab68"]]},{"id":"e0aee73e.e0ab68","type":"find-my-iphone","z":"509f464f.a27698","x":167.33328247070312,"y":393.333251953125,"wires":[["29c855dc.20404a","c1a3b077.edc04"]]},{"id":"29c855dc.20404a","type":"debug","z":"509f464f.a27698","name":"","active":false,"console":"false","complete":"payload","x":173.21429443359375,"y":494.1428527832031,"wires":[]},{"id":"c1a3b077.edc04","type":"function","z":"509f464f.a27698","name":"Weather API URL","func":"if (msg.payload.modelDisplayName.valueOf() === \"iPhone\".valueOf())\n{\n    var url = \"https://api.weather.com/v3/location/point?geocode=\"+msg.payload.location.latitude+\",\"+msg.payload.location.longitude+\"&language=en-US&format=json&apiKey=a45d4b384dc84ac2708475fdb1df2e65\";\n    msg.url = url;\n    return msg;\n}","outputs":1,"noerr":0,"x":393.4285583496094,"y":395.7142639160156,"wires":[["62eb1995.ac1cb","5c506e99.ee7d38"]]},{"id":"7772a3f4.00580c","type":"debug","z":"509f464f.a27698","name":"","active":false,"console":"false","complete":"false","x":835.21435546875,"y":339.5714111328125,"wires":[]},{"id":"62eb1995.ac1cb","type":"http request","z":"509f464f.a27698","name":"Get Current Geo","method":"GET","ret":"obj","url":"","tls":"","x":612.7144165039062,"y":408.85711669921875,"wires":[["7772a3f4.00580c","e655653b.223308"]]},{"id":"5c506e99.ee7d38","type":"debug","z":"509f464f.a27698","name":"","active":false,"console":"false","complete":"url","x":602.4998779296875,"y":349.47613525390625,"wires":[]},{"id":"e655653b.223308","type":"function","z":"509f464f.a27698","name":"Get City and State","func":"var city = msg.payload.location.city;\nvar state = msg.payload.location.adminDistrictCode;\nvar user = \"dummyuser\";\n\nconsole.log(\"City is \" + city + \"State is \" +state);\nvar payload = { \"input\" : {\"text\": city + \", \" + state},\"user\":user};\nmsg.payload = payload;\nmsg.header = msg.headers = {\n        \"Content-type\" : \"application/json\", \"Accept\": \"application/json\"   };\nconsole.log(msg)\nreturn msg;\n\n","outputs":1,"noerr":0,"x":850.21435546875,"y":406.80950927734375,"wires":[["ef05564e.6d89e8","68dec4f0.95312c"]]},{"id":"ef05564e.6d89e8","type":"http request","z":"509f464f.a27698","name":"Call Weather Bot","method":"POST","ret":"txt","url":"http://text-bot.mybluemix.net/api/message","tls":"","x":581.9207153320312,"y":496.8079833984375,"wires":[["34a300f.6eb77"]]},{"id":"34a300f.6eb77","type":"debug","z":"509f464f.a27698","name":"","active":true,"console":"false","complete":"payload","x":780.9287109375,"y":495.71429443359375,"wires":[]},{"id":"68dec4f0.95312c","type":"debug","z":"509f464f.a27698","name":"","active":false,"console":"false","complete":"payload","x":1071.4998779296875,"y":404.4285888671875,"wires":[]}]
gmagie

Flow Info

created 9 months, 3 weeks ago

Node Types

Core
  • debug (x5)
  • function (x2)
  • http request (x2)
  • inject (x1)
Other
  • find-my-iphone (x1)

Tags

Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option