Geofency Location

Let me start by saying I am very new to Node-Red. Please take this idea and make changes to it or recommend other ways to do this. I know it might not be the most secure way to do it. I started my journey on geolocation trying to use Owntracks on Core and Node-Red, I spent many nights changing settings and testing, and with the help of @april.brandt , @markus, and @RRodman, I was able to get it to work a bit. The problem I kept running into was my phone wouldn’t stay connected reliably. Nothing to do with Core, Just my phone didn’t work reliably with the app. A few years ago, I started using Geofency (iOS only I think) to track how long I was at locations for work. It worked well, and I started using the geolocation aspect of it to let me know when everyone in the family was out of the house, WIth that information, I was able to turn lights off and make sure the house was locked tight when everyone was gone. It worked great for years, and I missed that functionality with Node-Red so I dug into it, and with some thought steering from @april.brandt I figured out how to make it work using a few things. It requires webhooks to work, and I struggled with trying to set that up with Node-Red. I found Webhookrelay and a node for it for Node-Red. After setting that up and testing I installed the node and applied the API and Key and tested it. It worked and I could get the events I was looking for. I used a JSON node to parse the data and built the following flow.

[{"id":"5e5409bce0d1e10c","type":"webhookrelay","z":"1ab896a6bd959483","buckets":"nodered","credentials":{},"x":100,"y":1380,"wires":[["5f2db4d239aa2434"]]},{"id":"5f2db4d239aa2434","type":"json","z":"1ab896a6bd959483","name":"Convert json","property":"payload.body","action":"obj","pretty":false,"x":270,"y":1380,"wires":[["bbcdba731851b787"]]},{"id":"7a5d791ffa3bca78","type":"switch","z":"1ab896a6bd959483","name":"Home/Away","property":"payload.body.entry","propertyType":"msg","rules":[{"t":"eq","v":"Home","vt":"str"},{"t":"eq","v":"Away","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":670,"y":1380,"wires":[["2e30a88513519e12"],["2223af652dfc3419"]]},{"id":"7096fafee462771c","type":"change","z":"1ab896a6bd959483","name":"Doug location Topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"Doug Location","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":1360,"wires":[["46ab77c04f980107"]]},{"id":"46ab77c04f980107","type":"pushover","z":"1ab896a6bd959483","name":"","device":"","title":"","priority":"0","sound":"pushover","url":"","url_title":"","html":false,"x":1460,"y":1360,"wires":[]},{"id":"fc9e9cd3cf64b871","type":"template","z":"1ab896a6bd959483","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Doug is at arriving Home.","output":"str","x":1100,"y":1360,"wires":[["7096fafee462771c"]]},{"id":"bbcdba731851b787","type":"change","z":"1ab896a6bd959483","name":"Change to Home/Away","rules":[{"t":"change","p":"payload.body.entry","pt":"msg","from":"1","fromt":"num","to":"Home","tot":"str"},{"t":"change","p":"payload.body.entry","pt":"msg","from":"0","fromt":"num","to":"Away","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":1380,"wires":[["7a5d791ffa3bca78"]]},{"id":"2e30a88513519e12","type":"change","z":"1ab896a6bd959483","name":"","rules":[{"t":"set","p":"doughome","pt":"global","to":"Home","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1360,"wires":[["fc9e9cd3cf64b871"]]}]

It is working perfectly and I look forward to building this into my other flows. Hope this helps some with geolocation. I also look forward to learning how to do this differently if anyone has ideas.

7 Likes