iCloud Binding - DeviceID

I´m using the iCloud Binding to find/monitor my various iCloud connected devices. I´ve configured the appleID username/password and I´m able to discover things. However, I am not able to define the things myselves in a .things file. The reason is probably that I do not have the right DeviceID. I´ve looked at the binding documentation, but it does not state what this DeviceID is. I´ve tried to use the UDID number, but it does not seem to be correct.

Does anyone know what the DeviceID defined in the binding doc is?

Thanks,

1 Like

I’m confused by this too - the binding documentation is a bit lacking. Also a bit of a mystery what “World” means in the Things definition:

Bridge icloud:account:myaccount [appleId="abc@xyz.tld", password="secure", refreshTimeInMinutes=5]
{
    Thing device myiPhone8 "iPhone 8" @ "World" [deviceId="VIRG9FsrvXfE90ewVBA1H5swtwEQePdXVjHq3Si6pdJY2Cjro8QlreHYVGSUzuWV"]
}

@dan12345 „World“ is only the name of the „room“ in PaperUI that you can change how you like or delete it.

@MartinKo I also do not understand how I can get the device id. It is not the id from the device that is recognized by search.

1 Like

I got it from Paper auto discovery after I added my account, I then used that info to manually create my .things.

2 Likes

I found the ID from the Paper as well and added it to me .items file. However, I cannot get the binding to work. Configuring the binding in Paper and adding the items in the .items file kind of works, but as soon as I define a thing in the .things file (using the ID retrieved from the Paper UI), the binding seams to fail. Have you got it working using the .things / .items files only?

Yes, I am 100% config based.

Bridge icloud:account:nathan [appleId="nathan@robotics.net", password="password", refreshTimeInMinutes=5]
{
    Thing device Nathan_iPhone "Nathan's iPhone 8" [deviceId="7Bs9+Y4kspTJs4LCmg+pB95KcIJoUW/+KI3dhMKdfNVg0llmcDHxlOHYVNSUzmWV"]
    Thing device Beth_iPhone "Beth's iPhone 8" [deviceId="rNAgCKFCWlR2dPqUbA7gwHC9DaDXy420Fb5+LFmU7+NpN9JJhUXcj/UFXY7I5aeSKc1mUl3dRiXdY6Nb4ELBSkUT3WMyJQU4qEZGgfuC3Q5Bd189SJ5sOw=="]
    Thing device Joshua_iPhone "Joshua's iPhone 8" [deviceId="LXyrMhIaN4Pbb9WzW9MqgzECadbTR2kG6xbecm/hO0UGniFDsL++xEY0fPMu7ZuYFNcDnKD5TAzdY6Nb4ELBSqnpzNnptwc/jDMVGAAKsaVBd189SJ5sOw=="]
    Thing device Emma_iPhone "Emma's iPhone 8" [deviceId="FkE2RSVeezI+FbOPEc8n973E6yBIxcO1fHKGYGg0CQzYpDVj1HG7nAKBQ9YzYFo4n6AMT1YkKFfdY6Nb4ELBSqnpzNnptwc/2sDI3TQIB1BBd189SJ5sOw=="]
}

Then items:

Group     iCloud_Group

String    Nathan_BatteryStatus              "Battery Status [%s]"                                       <battery>   (iCloud_Group)                          {channel="icloud:device:nathan:Nathan_
iPhone:batteryStatus"}
Number    Nathan_BatteryLevel               "Battery Level [%.0f]"                                      <battery>   (iCloud_Group)                          {channel="icloud:device:nathan:Nathan_
iPhone:batteryLevel"}
Switch    Nathan_FindMyPhone                "Find My iPhone"                                            <find>      (iCloud_Group)                          {channel="icloud:device:nathan:Nathan_
iPhone:findMyPhone"}
Location  Nathan_Location                   "Coordinates"                                                           (iCloud_Group)                          {channel="icloud:device:nathan:Nathan_
iPhone:location"}
Number    Nathan_LocationAccuracy           "Coordinates Accuracy [%.0f m]"                             <find>      (iCloud_Group)                          {channel="icloud:device:nathan:Nathan_
iPhone:locationAccuracy"}
DateTime  Nathan_LocationLastUpdate         "Last Update [%1$tY.%1$tm.%1$td %1$tH:%1$tM]"                           (iCloud_Group)                          {channel="icloud:device:nathan:Nathan_
iPhone:locationLastUpdate"}

String    Beth_BatteryStatus                "Battery Status [%s]"                                       <battery>   (iCloud_Group)                          {channel="icloud:device:nathan:Beth_iP
hone:batteryStatus"}
Number    Beth_BatteryLevel                 "Battery Level [%.0f]"                                      <battery>   (iCloud_Group)                          {channel="icloud:device:nathan:Beth_iP
hone:batteryLevel"}
Switch    Beth_FindMyPhone                  "Find My iPhone"                                            <find>      (iCloud_Group)                          {channel="icloud:device:nathan:Beth_iP
hone:findMyPhone"}
Location  Beth_Location                     "Coordinates"                                                           (iCloud_Group)                          {channel="icloud:device:nathan:Beth_iP
hone:location"}
Number    Beth_LocationAccuracy             "Coordinates Accuracy [%.0f m]"                             <find>      (iCloud_Group)                          {channel="icloud:device:nathan:Beth_iP
hone:locationAccuracy"}
DateTime  Beth_LocationLastUpdate           "Last Update [%1$tY.%1$tm.%1$td %1$tH:%1$tM]"                           (iCloud_Group)                          {channel="icloud:device:nathan:Beth_iP
hone:locationLastUpdate"}

String    Joshua_BatteryStatus              "Battery Status [%s]"                                       <battery>   (iCloud_Group)                          {channel="icloud:device:nathan:Joshua_
iPhone:batteryStatus"}
Number    Joshua_BatteryLevel               "Battery Level [%.0f]"                                      <battery>   (iCloud_Group)                          {channel="icloud:device:nathan:Joshua_
iPhone:batteryLevel"}
Switch    Joshua_FindMyPhone                "Find My iPhone"                                            <find>      (iCloud_Group)                          {channel="icloud:device:nathan:Joshua_
iPhone:findMyPhone"}
Location  Joshua_Location                   "Coordinates"                                                           (iCloud_Group)                          {channel="icloud:device:nathan:Joshua_
iPhone:location"}
Number    Joshua_LocationAccuracy           "Coordinates Accuracy [%.0f m]"                             <find>      (iCloud_Group)                          {channel="icloud:device:nathan:Joshua_
iPhone:locationAccuracy"}
DateTime  Joshua_LocationLastUpdate         "Last Update [%1$tY.%1$tm.%1$td %1$tH:%1$tM]"                           (iCloud_Group)                          {channel="icloud:device:nathan:Joshua_
iPhone:locationLastUpdate"}

String    Emma_BatteryStatus                "Battery Status [%s]"                                       <battery>   (iCloud_Group)                          {channel="icloud:device:nathan:Emma_iP
hone:batteryStatus"}
Number    Emma_BatteryLevel                 "Battery Level [%.0f]"                                      <battery>   (iCloud_Group)                          {channel="icloud:device:nathan:Emma_iP
hone:batteryLevel"}
Switch    Emma_FindMyPhone                  "Find My iPhone"                                            <find>      (iCloud_Group)                          {channel="icloud:device:nathan:Emma_iP
hone:findMyPhone"}
Location  Emma_Location                     "Coordinates"                                                           (iCloud_Group)                          {channel="icloud:device:nathan:Emma_iP
hone:location"}
Number    Emma_LocationAccuracy             "Coordinates Accuracy [%.0f m]"                             <find>      (iCloud_Group)                          {channel="icloud:device:nathan:Emma_iP
hone:locationAccuracy"}
DateTime  Emma_LocationLastUpdate           "Last Update [%1$tY.%1$tm.%1$td %1$tH:%1$tM]"                           (iCloud_Group)                          {channel="icloud:device:nathan:Emma_iP
hone:locationLastUpdate"}
1 Like

Arrrrggghhhhh… I´m a total idiot! :confounded: Thanks to your post I had a closer look at my .things file and found a missing bracket at the end of the device configuration. Changed that and Bob´s your uncle…

Now it works, except for the “locationLastUpdate” item. Have you this working as well ?

Thanks for helping :smile:

Thank you all. Yes, all I needed to do was add my account, and autodiscovery did the rest.

Dan

Yes make sure your item is like mine and not original.

Hi all,

unfortunately documentation is not my strong point; especially as I do not use textual configuration myself. If you have improvements that I can include in the readme please feel free to provide feedback. A appreciate if you are as specific as possible, or even provide fragments I can directly use :slight_smile:.

with kind regards,
Patrik

Patrik, overall I think the documentation is for the most part quite informative, but I will have a read through and see if I can come up with some suggestions or additions to the docs.

I still cannot get the locationLastUpdate item to work. I´ve looked in the logs and find the following in the openhab.log.

2017-12-25 10:53:49.704 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.thingUpdated()' on 'org.openhab.binding.icloud.handler.ICloudDeviceHandler@c39140': 2017-12-25T10:48:47CET is not in a valid format.
java.lang.IllegalArgumentException: 2017-12-25T10:48:47CET is not in a valid format.
	at org.eclipse.smarthome.core.library.types.DateTimeType.<init>(DateTimeType.java:96) ~[?:?]
	at org.openhab.binding.icloud.handler.ICloudDeviceHandler.getLastLocationUpdateDateTimeState(ICloudDeviceHandler.java:172) ~[?:?]
	at org.openhab.binding.icloud.handler.ICloudDeviceHandler.updateLocationRelatedStates(ICloudDeviceHandler.java:123) ~[?:?]
	at org.openhab.binding.icloud.handler.ICloudDeviceHandler.deviceInformationUpdate(ICloudDeviceHandler.java:74) ~[?:?]
	at org.openhab.binding.icloud.handler.ICloudAccountBridgeHandler.lambda$2(ICloudAccountBridgeHandler.java:155) ~[?:?]
	at java.util.ArrayList.forEach(ArrayList.java:1249) [?:?]
	at java.util.Collections$SynchronizedCollection.forEach(Collections.java:2062) [?:?]
	at org.openhab.binding.icloud.handler.ICloudAccountBridgeHandler.informDeviceInformationListeners(ICloudAccountBridgeHandler.java:155) [218:org.openhab.binding.icloud:2.2.0]
	at org.openhab.binding.icloud.handler.ICloudAccountBridgeHandler.refreshData(ICloudAccountBridgeHandler.java:144) [218:org.openhab.binding.icloud:2.2.0]
	at org.openhab.binding.icloud.handler.ICloudDeviceHandler.initializeThing(ICloudDeviceHandler.java:137) [218:org.openhab.binding.icloud:2.2.0]
	at org.openhab.binding.icloud.handler.ICloudDeviceHandler.initialize(ICloudDeviceHandler.java:84) [218:org.openhab.binding.icloud:2.2.0]
	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.thingUpdated(BaseThingHandler.java:228) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[?:?]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]
Caused by: java.time.format.DateTimeParseException: Text '2017-12-25T10:48:47CET' could not be parsed, unparsed text found at index 19
	at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1952) ~[?:?]
	at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851) ~[?:?]
	at java.time.LocalDateTime.parse(LocalDateTime.java:492) ~[?:?]
	at org.eclipse.smarthome.core.library.types.DateTimeType.<init>(DateTimeType.java:89) ~[?:?]
	... 21 more

Any suggestions to what could be the reason for this ?

@MartinKo
Hi Martin,

that looks like a bug in the binding; it can not parse the date format your server response produces. I´ll have a look into that and let you know once I´ve an updated version.

with kind regards,
Patrik

@MartinKo
Hi Martin,

can you try if you still have the problem with this version:

did some changes in the way the timestamp is processed.

with kind regards,
Patrik

I am running the stable version. Would it simply be a matter of renaming the file, changing the permissions and dropping it into /var/lib/openhab2/tmp/mvn/org/openhab/binding/org.openhab.binding.icloud/2.2.0 ?

… and restarting the service ?

on karaf console stop the binding 1st

$ list
$ stop xxx

xxx is the number of the binding, then copy the new jar to the addon folder; check with list that it did load and start as expected.

I find…

218 │ Resolved │ 80 │ 2.2.0 │ iCloud Binding
and
256 │ Installed │ 80 │ 2.2.0.201712251133 │ iCloud Binding

I am able to start/stop 218, but when I try to start 256, I get an error message

openhab> stop 218
openhab> start 256
Error executing command: Error executing command on bundles:
	Error starting bundle 256: Could not resolve module: org.openhab.binding.icloud [256]
  Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="2.2.0"; osgi.identity="org.openhab.binding.icloud"; singleton:="true"

I will try a fresh install tomorrow and let you know how it went.

@MartinKo

Just uninstalling 218 should do;

$ uninstall 218

with kind regards,
Patrik

@patrik_gfeller

Your latest snapshot is now running

257 │ Active   │  80 │ 2.2.0.201712251133     │ iCloud Binding

and the item locationLastUpdate is now being updated as it should.

2017-12-25 20:25:15.218 [vent.ItemStateChangedEvent] - Martin_LocationLastUpdate changed from 2017-12-25T20:20:19.187+0100 to 2017-12-25T20:20:23.648+0100

Thanks for fixing and for hints on how to get the snapshot running. I´ve had it running for approximately 1 hour with refreshTimeInMinutes=5 with no exceptions. There is a slight delay detecting location change (I took a walk to test if the service updated location and locationLastUpdate to where I actually was at various times), but I think this due to how icloud updates information and not the binding.

Best regards,

Martin

@Michael_Marinkovits
Hi Martin,

thanks for the feedback :slight_smile:.

with kind regards,
Patrik

@sipvoip @MartinKo
I see new things in auto discovery but they are formattet like:

“icloud:device:myaccount:1e97b374:batteryStatus”

so I assumed that device ID is “1e97b374” but with this there is no connection possible.
You all had longer device IDs. You really just looked in the auto discovery in the things?