Replace iCloud binding with built-in functionality of openHAB iOS app

I’ve been struggling with the iCloud binding since I started using openHAB.
There have been a good few times when Apple changed something and it broke the integration completely.
Currently the Find My Phone function is not working.
And it asks me to re-enter the 2FA code every few days or weeks (seems random). I often don’t have the time or access to update this when it happens, and my wife definitely can’t fix it without me. Which means we are endlessly asked to allow or disallow the access on our iPhones while in this state. Really annoying. And it breaks my presence detection for setting HOME and AWAY modes etc.

Can the functionality of the openHAB iOS app be expanded to do the same as the iCloud binding?
The openHAB iOS app should be the bit sending GPS data and battery level information etc. I think it works like this on Android, but I don’t use any android devices.
Surely this would remove a few of the steps that the iCloud binding needs to take to get the data into openHAB and be able to complete any authentication better?

Nope, at least not for GPS. It’s been requested a number of times but the impact to battery has always been too great.

The Android app does report next alarm time, call state, connected BT devices, battery level, charging state, WiFi name, and do not disturb mode though.

For those who want geotracking, GPSTracker - Bindings | openHAB is the recommended approach. It’s actually pretty easy to set up and works through (unlike how it used to work where you needed to expose MQTT to the Internet or the like).

I personally just use the WiFi Name to determine when one of us is home or not.

This doesn’t seem like a good reason. Every other app in the world seems to be able to do it just fine.

Smartphone integration seems lacking in OpenHAB compared to other platforms.

Really? Every other app in the world that tracks GPS location constantly with enough fidelity to be useful in home automation (i.e. every minute or so) is a big battery drain. Most apps that track location have a sample rate much slower so they have much less important on battery.

What are you trying to achieve and what is important to you? Presence detection?

There would be many ways to deal with the battery problem

  • Adjustable interval to communicate home so the user can decide how much battery to drain
  • Store/buffer location and send less often (send 10 x 1 minute updates every 10 mins)
  • Only send when stopped moving (to avoid unnecessary travel location updates)
  • Send more often when the phone is plugged into power and less often when not

There are a few reasons.

Having to re-authenticate every few days or weeks makes the iCloud binding not very usable, and in fact, it is very annoying when my iPhone continuously asks me to allow or deny until I reenter the code and I am unable to because I’m at work or busy doing something else. Also, other people in my family are unable to do this them selves.

It would also be useful as a form of user management. See the Home Assistant app

Presence detection is more complicated than just using a wifi connection to the home network. There are many reasons one could lose wifi without being away from home. Dead battery, flakey connection when going into the garden etc. At my previous house, I created a complicated system of GPS detection and WiFi connection to figure out if I have actually left, and to know if there are other people at the house (including guests).

While we’re at it, I would also like to be able to access more than one OpenHAB instance from the app. I have a main system at my office, plus a fallback raspberry pi. And I have another two at home (one main and one fallback). That’s four instances I would like to switch between.
This would mean that the integration with iOS Shortcuts would need to be more complicated to allow for this. But this is one of the most powerful features of using an iOS mobile device. Being able to make automations originate from the phone allows for better personal automations.

I am a pretty basic user of OpenHAB but do leverage Apple’s backend for presence detection of leaving/arriving home for e.g. opening my driveway gate when arriving home. I avoided the iCloud binding because of the 2FA annoyance (by the way this is at Apple’s end and under their control so unless there is an alternative way to access it is out of the developer’s control).

I and some others do the following:

  • create a virtual presence switch for each person’s phone
  • expose it via the HomeKit binding
  • have HomeKit turn it on and off when you leave/arrive

I have found it to work really well and it is a very simple setup but I have not tried the other methods and it may depend on your situation, in terms of your property. The good thing is you don’t have the issue with verification requests, that you get with the iCloud binding and Apple seems to have done a lot of work with regard to battery drain etc.
It also works quite well to warn me when there is an issue with HomeKit - I have it run an automation to ask me to open my gate when I get home, if this isn’t working I know I need to check and maybe reboot my HomePod (maybe a couple of times a year).

In terms of the other things that the iCloud binding gives (battery life of devices and locations of people) I just use Apple’s “Find My” application, these are not that important to me and it would also be possible to set up a home/away card for users using the setup I use.

I am sure people much more familiar with OpenHAB can weigh in on your other points.

Yes, I have explored the option of linking a virtual presence switch to HomeKit, but it is still a clunky experience to setup and manage compared to having a good app like the Home Assistant one. There are lots of reasons I prefer OpenHAB to HA, but there are definitely things to be learned from HA.
And it still leaves me with the challenge of creating a good logic for combining GPS and phone data with WiFi connectivity for more robust presence detection.

I’m sure there are. If you have ideas, I’m sure the Android and iOS app developers would welcome a PR with this feature. For now it’s been tried all sorts of different ways and thus far no satisfactory balance between frequency of reporting and usable information to drive home automation has been found.

This is a no brainer, but it needs to be pretty frequent to be useful for home automation. It’s no good if it takes 10 minutes after you get home to recognize you are home.

See above. If all you care about is tracking your location for grins and giggles this works great. But to drive your home automation you can’t wait 10 minutes.

And if my automation is to do something when I get close to home?

The times it’s most critical to have timely GPS reporting is when one has just left or is arriving home, the times when one is least likely to have their phone plugged in.

Note that the software that works with GPS Tracker supports all of these features already IIRC.

It sounds like you’re saying that we should all just put up with things that aren’t very good and that it’s not worth it.

This one is obvious to me - The phone knows when it’s nearly home, time to send an update. Also, the wifi will connect if the GPS doesn’t get it first. And this one case doesn’t invalidate the concept.

Lots of situations when this would be perfectly fine, and it would fill in the gaps. If I leave my house at 12:00, but my GPS data doesn’t come in until 12:10, I would still know that my phone left home at 12:00, allowing me to create an automation ‘10 mins after I leave home’ that would execute at 12:10 instead of having to wait until 12:20.

Again, the phone knows when it’s nearly home, time to send an update.

Not necessarily true. I drive with my phone plugged in. And I know quite a few people that use battery banks in their bags on the go. Lots of automations would be fine waiting for this to catch up, and it would help all of the other times that it is plugged in. It would make it more clear that the phone has left the house. If WiFi is lost, check GPS if the phone is gone. Presence detection should be a combination of tactics.

I don’t want another app and login to deal with (plus wife and kids phones). If GPS Tracker can do it, so can OH. This is a janky solution.

All I know is that I’ve seen and experienced many apps that don’t seem to have the shortcomings that OH does.

Well, it’s been asked for more than once. It’s been implemented at least once on the Android side and had to be removed. Continuing to demand more is just complaining. “Nerd harder maintainers! I wants it!”

My point is GPS Tracker does all of this and there is still too much battery drain.

You seem to have all the answers on how this is supposed to work so step up and submit a PR. Maybe you do in fact know better than the maintainers and developers who have already tried.