Presence sensing sporadic and unreliable; Fixed w/Hubitat App V2; Thank-you Hubitat!

One of my jobs is as an iOS engineer, and it sometimes involves tracking location and using geofencing. There are a few things to know, if you want to understand why it doesn't always "just work".

  • Using the GPS sensor is EXPENSIVE. In energy usage. If an app tried to track GPS 100% of the time, the battery would be depleted at an outrageously fast rate.
  • Because of this, iOS and Android only allow app developers to use GPS, and run code in the background as a result, in very specific conditions. And only very limited times. And if you "misbehave", they just kill your app and you get zero processing time.
  • Okay, so why not just do that? Follow the documentation and do the allowed GPS and background processing? Well... neither Apple nor Google like to document exactly what their "rules" are. Because if they do, malicious actors will take advantage of it. So the rules are left undocumented, and only companies who are willing to make the long-term investment to discover the rules, follow them, and then update their usage as the rules silently change... only those companies will be able to track location reliably.

Based on my experience working on similar apps, it looks like Hubitat's app doesn't 100% follow the undocumented rules, and is thus not being granted enough background processing time by iOS. It works when you open up the app, because apps in the foreground are given all the processing time they want.

Honestly, I understand why Hubitat hasn't fixed this. It would be a large ongoing investment. I'd personally prefer that they prioritize other things. And I've prioritized other things by using other methods for tracking my presence.

Important: I have no knowledge of the internal business of Hubitat. Everything I've said is my guesses based on my experience, and the conclusions are only my own preferences.

Edit: Oh, one more thing. Part of why this is so expensive to engineer. It's not just an undocumented process. It's that testing is expensive. It takes a lot of time. You have to actually go driving and see if the geofences get hit. And just because it gets hit once, doesn't mean it will every time. You might find that it works fine for a couple days, but a couple days later, iOS decides that you're using too much battery and stops giving you geofence events. It is DIFFICULT to test.

15 Likes