iCloud device data integration in openHAB

Yes, I did following these instruction: https://github.com/pgfeller/openhab2-addons/blob/master/addons/binding/org.openhab.binding.icloud/README.md#thing-configuration

A typo maybe?

@patrik_gfeller I agree that there should be an error in the log.

@moov

Hi Aleksey,
what version of OH do you use? Did you manually configure the binding, or using paper UI?

If you use textual configuration, can you give it a try using UI config? If you use a snapshot version of OH as well, do you have the possibility to try it on OH 2.1 release? For me it sounds like the initialization method of the binding is not even called - which is rather strange.

with kind regards,
Patrik

Hi Patrik, thanks for the help more. Everything worked, I installed OH2.1 and org.openhab.binding.icloud_2.2.0.201709111846.jar. Thanks again.

Hi,
I was a bit too quick to call the green flag on my configuration issue. I get the below errors in openhab.log:

2017-10-21 17:45:21.321 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@13fbc32
2017-10-21 17:45:21.498 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@1b4a55e
2017-10-21 17:45:22.916 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@11b438e

I’ve followed the guidange given by @ThomDietrich above to configer my thing file (2 accounts).
and it looks like this:

Bridge icloud:bridge:account1 [AppleId="xxx, Password="yyy", RefreshTimeInMinutes=4]
Bridge icloud:bridge:account2 [AppleId="xxx", Password="yyy", RefreshTimeInMinutes=4]

After the above Errors happen, one of my devices changes status to UNDEF.

What am I doing wrong?

Kurt

Hi Kurt,

can you try to change the refresh time to 5 minutes. Do you still see the problem then; if yes - do you get a stack trace in your log that you cold provide to analyze.

with kind regards,
Patrik

HI Patrik,

Yes, when I’m changing the refresh time back to 5min, I still get those errors:

2017-10-22 15:45:55.293 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@1483ec6
2017-10-22 15:45:55.388 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@34ccfc

Kurt

Hi Kurt,

do you see some more details in the log files; or is that all that is shown? Can you check if other message from the binding in the log prior to the error (to help me determine what operation has failed).

with kind regards,
Patrik

@patrik_gfeller Thanks for developing this, looks incredibly useful!

I’m wondering if anyone has tried this with a separate apple-id and family sharing turned on? Instead of using my apple-id I’d create a separate one, turn family sharing on and share the location of my (and my gf’s) devices.

You’d only need one binding to track devices across different apple-ids and, more important, you wouldn’t have to expose very sensible information in the config…

1 Like

Hi Patrik,

I’m afraid the only info shown in the logs are the errors below:

2017-10-23 17:37:39.798 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@3a85c
2017-10-23 17:38:58.898 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@190728f
2017-10-23 17:44:00.692 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@3e6996
2017-10-23 17:44:00.775 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@145f57f
2017-10-23 17:49:03.165 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@194f3e7
2017-10-23 17:49:03.250 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@2aa484
2017-10-23 17:49:03.336 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@1c9a497

Kurt

Hi Kurt,

ok - can you post me the .things configuration file (without passwords and account id of course). If we can not find the error I’ll add more logging to the binding to narrow down the issue.

with kind regards,
Patrik

Hi Kurt,

I still wonder what the problem might be … did you already try to configure the accounts via UI - not textual configuration? As I do not use textual configuration (the binding inherited this capability from the framework) it is difficult to analyze this; but it might be related to device discovery and mismatch to the .things file. That´s why I would like to know if it works if we go automatic (manual .items configuration shold still be possible).

If UI is no option you will have to configure the devices in the .things file as well. Here an example from @ThomDietrich:

Bridge icloud:bridge:account1 [AppleId="abc@xyz.tld", Password="secure", RefreshTimeInMinutes=10]
{
    Thing device 0 "My iPhone 7" @ "World"
    Thing device 1 "My iWatch 2" @ "World"
}

Note that the device id must match the index in the JSON response from the apple server.

with kind regards,
Patrik

1 Like

Hi Kurt,

another idea: Do you get more log info, if you start openHAB in debug mode?

with kind regards,
Patrik

Hi Patrik,

These were my steps used (thanks again for the help guys!)

I did configure the accounts in the textual thing file:

Bridge icloud:bridge:account1 [AppleId="xx@zz.com", Password="zzz", RefreshTimeInMinutes=5]
Bridge icloud:bridge:account2 [AppleId="xx@szz.com", Password="zzz", RefreshTimeInMinutes=5]

I did not configure the Things itself in the textfile and used the PaperUI for discovery
I added them in PaperUI and mapped the channels to my items (I configured those manually in the items file).

Kurt

Hi Kurt,

thanks - can you give the latest binding a try in debug mode to see if we get some more information:
https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/binding/org.openhab.binding.icloud/2.2.0-SNAPSHOT/

thanks & kind regards,
Patrik

Hi Patrik,
It doesn’t seem to deliver more info:

2017-10-26 09:02:49.334 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud bridge refreshing data ...
2017-10-26 09:02:51.322 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@1ed63ff
2017-10-26 09:02:51.488 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [idevice1]
2017-10-26 09:02:51.491 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [idevice2]
2017-10-26 09:02:51.495 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [idevice3]
2017-10-26 09:02:51.498 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [idevice4]
2017-10-26 09:02:51.501 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [idevice5]
2017-10-26 09:02:51.508 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [idevice6]
2017-10-26 09:02:51.510 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [idevice7]
2017-10-26 09:02:51.513 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [idevice8]
2017-10-26 09:02:51.517 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud bridge data refresh complete.

Since you provided the new version of the binding, I noticed that the Adress items don’t change to UNDEF after the error occurs.
Also, the error appears much less, than I’ve seen it in the logs before.
I’ll keep on monitoring and provide more info.
What doesn’t work for me at all is the “distance to home” - the field seems not to be updated.

Thanks again for your help!
Kurt

Hi Kurt,

thank you for the update - this contains some useful info. I’ll have a look into the code and add more logging. I’ll get back to you as soon as I’m ready (will take a few days).

with kind regards,
Patrik

1 Like

Hi,
thanks a lot Patrik! Maybe this helps as well:

2017-10-26 11:15:13.517 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@1441256
==> /var/log/openhab2/events.log <==
2017-10-26 11:15:13.532 [vent.ItemStateChangedEvent] - Iphone_BatteryLevel changed from 80.0000011920929 to 79.00000214576721
2017-10-26 11:15:13.543 [vent.ItemStateChangedEvent] - Iphone_LastLocationUpdate changed from 2017-10-26T11:05:55.000+0200 to 2017-10-26T11:11:43.000+0200
2017-10-26 11:15:13.666 [vent.ItemStateChangedEvent] - Iphone2_LastLocationUpdate changed from 2017-10-26T11:08:59.000+0200 to 2017-10-26T11:14:02.000+0200
2017-10-26 11:15:13.670 [vent.ItemStateChangedEvent] - Iphone2_Location changed from long,lat to long,lat
2017-10-26 11:15:13.698 [vent.ItemStateChangedEvent] - Iphone_FormattedAddress changed from _ADRESS_ to _ADRESS_
2017-10-26 11:15:13.721 [vent.ItemStateChangedEvent] - Iwatch_LastLocationUpdate changed from 2017-10-26T11:06:00.000+0200 to 2017-10-26T11:11:46.000+0200
==> /var/log/openhab2/openhab.log <==
2017-10-26 11:15:13.783 [ERROR] [binding.icloud.handler.BridgeHandler] - Index: 0, Size: 0
[Ljava.lang.StackTraceElement;@b65f51
==> /var/log/openhab2/events.log <==
2017-10-26 11:15:13.810 [vent.ItemStateChangedEvent] - Iwatch_FormattedAddress changed from _ADRESS_ to UNDEF
2017-10-26 11:15:13.846 [vent.ItemStateChangedEvent] - Iphone2_FormattedAddress changed from _ADRESS_ to _ADRESS_
==> /var/log/openhab2/openhab.log <==
2017-10-26 11:15:13.849 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:13.855 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:13.857 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:13.871 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:13.874 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:13.914 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:13.916 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:13.928 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:13.930 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud bridge data refresh complete.
2017-10-26 11:15:14.048 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:14.051 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:14.053 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:14.055 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud device discovery for [iDevice]
2017-10-26 11:15:14.058 [DEBUG] [binding.icloud.handler.BridgeHandler] - iCloud bridge data refresh complete.

Kurt

For this to work your home location needs to be defined in the openHAB regional settings. Do you have this set?

with kind regards,
Patrik

1 Like

Hi Kurt,

I´ve probably found the reason for the error … but will add better logging anyhow: if the google API is used without API key, as the binding does, the reverse geo-lookup for the address only support a limited number of requests per day:

"{   "error_message" : "You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console: https://console.developers.google.com/apis/credentials?project=_",   "results" : [],   "status" : "OVER_QUERY_LIMIT"}"

I´ll add a configuration option to set a Google-API key to avoid this … I wonder if I should add a config option to enable/disable the lookup as well.

with kind regards,
Patrik