iCloud Binding Communication Error

I’m going to give this a try - it sounds like it might work well. Do you know at what distance Homekit decides people are home or away and how often it poles?

I can confirm this - that’s my experience as well.

And actually I used a similar approach for presence like you (without homekit), which works well even though iCloud is not working:
Whenever one of our three phones are detected in the wifi (using Fritzbox TR064), the location will be set artificially to the home GPS location for presence ON.
If the phone hasn’t been seen for a while (or location changed to be out of the home zone - which is of course currently not working), the presence for this phone goes off.

That’s ok (temporary) - even without homekit.
Depending on the time frame for a fix, I might consider homekit though.

You should probably run all 3 checks - Homekit Location automation, iCloud location and checking wifi. Depending on your application you could use first past post or 2 of 3 to detect presence. In my experience, HomeKit automation is quick to detect arrival, slower to detect leaving. Occasionally, HomeKit drops and I don’t realise until I reset everything. iCloud location is good but lags. Wifi is good but status flaps a lot i.e. poor wifi in a room can mean presence is off.

Mine stopped as well. Jumping in hoping for a solution…

Bump

iCloud Account

iCloud Account

The account Thing, more precisely the account Bridge, represents one Apple iCloud account. You may create multiple account Things for multiple accounts.

Status: OFFLINE - COMMUNICATION_ERROR iCloud response invalid: null

Hi,

i provided a version with a fix for the communication error.
Please test the fix and give a feedback, thanks.

“<= 3.1.0 M3” → (removed)

“>= 3.1.0 M4” → (removed)

“<= 2.5.?” → (removed)

br,

Trinitus01

8 Likes

The fix works for me OH 3.0.2.

Great work

1 Like

Thanks for the fix.
Worked for me too.
OH 3.1 M4

1 Like

I can’t get the fix working. I’m on OH 3.1.M4 running on a Mac. It appeared to work at first, when I added the iCloud bridge thing it initialised and then showed as online for a few minutes, then a bunch of my devices turned up in the inbox so I added one of them. Then that device couldn’t initialise and I noticed the bridge had gone offline, with a new error message:

Status:

OFFLINE

**COMMUNICATION_ERROR**

iCloud response invalid: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

I’ve not installed a snapshot of a binding before so not 100% sure I did it right. I uninstalled the iCloud binding, shut down OH, then copied the 3.1.x jar from the link above into the add-ons folder, then restarted OH and then finally when through the normal route to add the iCloud binding again from the bindings menu in Main UI. Is that how you’re meant to do it?

Hi,

you added the iCloud binding again from the bindings menu in additional to the jar in the add-ons folder, right?
It is not possible to use a binding installed via ui and the same one in the add-ons folder parallel. So you should uninstall the one installed by ui.

After the fix is merged to openHAB and they release the new version 3.1.x you can install it via ui again. But for now, you can only use the jar in the add-ons folder to fix the problem.

br,

Trinitus01

Fantastic! Thanks a lot!
Works with 3.0.2 again.

1 Like

Aha, thank you. Got it working now.

1 Like

Hi,
thanks for the fix.

The 3.1 binding does NOT work in my 3.1.M3
The 3.0 binding does WORK in my 3.1.M3

it’s a kind of magic ?

ralph

Spoke too soon. Again it worked briefly then the bridge device went offline again, this time with new error:

2021-05-17 20:11:51.551 [WARN ] [l.handler.ICloudAccountBridgeHandler] - Unable to refresh device data
java.io.IOException: java.util.concurrent.TimeoutException: Total timeout 15000 ms elapsed
	at org.openhab.core.io.net.http.HttpUtil.executeUrlAndGetReponse(HttpUtil.java:260) ~[?:?]
	at org.openhab.core.io.net.http.HttpUtil.executeUrl(HttpUtil.java:155) ~[?:?]
	at org.openhab.core.io.net.http.HttpUtil.executeUrl(HttpUtil.java:130) ~[?:?]
	at org.openhab.core.io.net.http.HttpRequestBuilder.getContentAsString(HttpRequestBuilder.java:135) ~[?:?]
	at org.openhab.binding.icloud.internal.ICloudConnection.callApi(ICloudConnection.java:90) ~[?:?]
	at org.openhab.binding.icloud.internal.ICloudConnection.requestDeviceStatusJSON(ICloudConnection.java:71) ~[?:?]
	at org.openhab.binding.icloud.internal.handler.ICloudAccountBridgeHandler.lambda$0(ICloudAccountBridgeHandler.java:94) ~[?:?]
	at org.openhab.core.cache.ExpiringCache.refreshValue(ExpiringCache.java:101) [bundleFile:?]
	at org.openhab.core.cache.ExpiringCache.getValue(ExpiringCache.java:72) [bundleFile:?]
	at org.openhab.binding.icloud.internal.handler.ICloudAccountBridgeHandler.refreshData(ICloudAccountBridgeHandler.java:161) [bundleFile:?]
	at org.openhab.binding.icloud.internal.handler.ICloudDeviceHandler.refreshData(ICloudDeviceHandler.java:112) [bundleFile:?]
	at org.openhab.binding.icloud.internal.handler.ICloudDeviceHandler.initialize(ICloudDeviceHandler.java:103) [bundleFile:?]
	at jdk.internal.reflect.GeneratedMethodAccessor57.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?]
	at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.util.concurrent.TimeoutException: Total timeout 15000 ms elapsed
	at org.eclipse.jetty.client.TimeoutCompleteListener.onTimeoutExpired(TimeoutCompleteListener.java:51) ~[?:?]
	at org.eclipse.jetty.io.CyclicTimeout$Wakeup.run(CyclicTimeout.java:282) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
	... 3 more
==> /Users/Server/openhab-3/userdata/logs/events.log <==
2021-05-17 20:11:51.561 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'icloud:account:d926c10baf' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): java.util.concurrent.TimeoutException: Total timeout 15000 ms elapsed

Hi,

that’s strange yes.
I was not able to test the 3.1.x because i don’t have an openHAB on this version.
But the fix is the same and both bindings are based on the current git-version.
This is why i ask for feedback.

br,

Trinitus01

It seems there was a connection problem because it timed out.
I don’t think this depends on the binding but maybe a network problem?

br

It seemed to retry by itself a few mins later and then it’s now online again. I will keep an eye on it for a bit. Thanks for the fix - seems like it’s working now.

Same for me, fix not work with 3.1.0.M3

 2021-05-17 21:14:00.465 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/openhab/addons/org.openhab.binding.icloud-3.1.0-SNAPSHOT.jar
 org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.icloud [208]
 Unresolved requirement: Import-Package: org.osgi.framework; version=[1.9.0,2.0.0)

at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

2021-05-17 21:14:10.102 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/openhab/addons/org.openhab.binding.icloud-3.1.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.icloud [208]
 Unresolved requirement: Import-Package: org.osgi.framework; version=[1.9.0,2.0.0)

at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]"

Hi,

for me, this is the exception which appears if 3.1.x is used on an openHAB 3.0.x
So i think they changed something in 3.1.0 M4 compared to 3.1.0 M3.
You should be fine using the 3.0.x jar file.

I will change this in the description of my post for the fix.

br,

Trinitus01

Great, works for me with 3.0.x jar on 3.1.0.M3

1 Like