iCloud device data integration in openHAB

Works great.
Installed this latest binding and found 6 devices .:wink:

Just for anyone who’s interested, here’s a basic sitemap:

sitemap icloud  label="iCloud Data" {

        Frame label="John Doe"  {
                Default item=JohnIPhone6_BatteryStatus icon="poweroutlet_uk"
                Default item=JohnIPhone6_BatteryLevel label="Battery Level [%.0f %%]" icon="battery"
//              Default item=JohnIPhone6_Location label="Location [%s]"
                Default item=JohnIPhone6_LocationAccuracy icon="movecontrol"
                Default item=JohnIPhone6_DistanceFromHome label="Distance from Home [%.0f m]" icon="zoom"
                Default item=JohnIPhone6_Street icon="house"
                Default item=JohnIPhone6_City icon="house"
                Default item=JohnIPhone6_Country icon="house"
                Default item=JohnIPhone6_FormattedAddress
                Default item=JohnIPhone6_LastLocationUpdate label="Updated [%1$td/%1$tm/%1$ty %1$tH:%1$tM]" icon="clock"
                Switch  item=JohnIPhone6_FindMyPhone label="Find this device"
        }
}

Just replace JohnIPhone6 with your thing name.

I have “JohnIPhone6_Location” commented out as I can’t quite figure out how to display the map (it displays perfectly in PaperUI/Control:

1 Like

Found one issue while starting up the system. Both Binding are still working afterwards, the logs file instead displays:

2017-09-13 06:55:07.443 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occurred during bridge handler ('icloud:bridge:966033ce') notification about handler initialization of child 'icloud:device:966033ce:0': null
java.lang.NullPointerException
	at org.openhab.binding.icloud.handler.iCloudBridgeHandler.childHandlerInitialized(iCloudBridgeHandler.java:109)[225:org.openhab.binding.icloud:2.2.0.201709111846]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$13.run(ThingManager.java:912)[105:org.eclipse.smarthome.core.thing:0.9.0.b5]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
2017-09-13 06:55:07.533 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occurred during bridge handler ('icloud:bridge:be789ef3') notification about handler initialization of child 'icloud:device:be789ef3:0': null
java.lang.NullPointerException
	at org.openhab.binding.icloud.handler.iCloudBridgeHandler.childHandlerInitialized(iCloudBridgeHandler.java:109)[225:org.openhab.binding.icloud:2.2.0.201709111846]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$13.run(ThingManager.java:912)[105:org.eclipse.smarthome.core.thing:0.9.0.b5]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

Like your screenshot location is displayed in Paper UI, but not on the iPhone itself while showing the sitemap…sitemap on the iPhone shows always 0, no link to google maps or something.
Is there a way to get it displayed there as well?

That’s why I had that line commented out of the sitemap - I can’t get it to show on the sitemap or my phone either :frowning:

Have a look at Google Map on how to display it in basic ui.

Add

		Mapview item=JohnIPhone6_Location height=13 //height depends from your needs

to your Sitemap and the location will be displayed on a OpenStreetMap.

2 Likes

Thanks Christoph, that was a lot easier than I expected! I can’t find any documentation on “Mapview” - are there any other parameters e.g. initial zoom, etc.?

Edit 1: My impatience got the better of me :roll_eyes: In Classic UI, the map shows at maximum zoomed out until there’s an update received, then it zooms in to the correct location automatically. The maps don’t display on the sitemap in the openHAB Android app, but they do in Chrome on Android, except for the initial zoom issue also.

Is it possible to force an initial zoom, using something like “Mapview item=… zoom=80”? (I tried that but it doesn’t work…)

Edit 2: This seems to be an issue with the ClassicUI, as BasicUI shows the map correctly zoomed in on first load.

The MapView is not yet documented but an Issue exists and is waiting for a volunteer. https://github.com/openhab/openhab-docs/issues/492

I’m sorry to tell you, that the Mapview only has the height parameter, the actual map can not be influenced…

problem sorted… sorry for the pointless post

Thanks for the report; added an additional null check to the device initialization to prevent this.

Btw.: I mixed up some git stuff; might be that you´ll have problems with your fork of my repo - maybe you´ll have to create a new one :frowning: . I´ve also lost some changes but tried to reconstruct them as best as I could. I also found out how to format tables in .md (VS Code seems to be a good editor for this, as it has a better preview than eclipse).

with kind regards,
Patrik

Has anyone implemented any of the icloud items into HABpanel as a custom widget?

I have this working at home, but I’m trying to install it on another system, same hardware, same OS, but I keep getting this error:

openhab> bundle:list "iCloud Binding"
START LEVEL 100 , List Threshold: 50
 ID │ State     │ Lvl │ Version            │ Name
────┼───────────┼─────┼────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
199 │ Installed │  80 │ 2.2.0.201709111846 │ iCloud Binding
openhab> bundle:start "iCloud Binding"
Error executing command: Error executing command on bundles:
        Error starting bundle 199: Could not resolve module: org.openhab.binding.icloud [199]
  Unresolved requirement: Import-Package: org.eclipse.jdt.annotation; resolution:="optional"
  Unresolved requirement: Import-Package: org.openhab.core.library.types
openhab> bundle:diag 199
iCloud Binding (199)
--------------------
Status: Installed
Unsatisfied Requirements:
osgi.wiring.package; filter:="(osgi.wiring.package=org.eclipse.jdt.annotation)"; resolution:="optional"
osgi.wiring.package; filter:="(osgi.wiring.package=org.openhab.binding.icloud)"
osgi.wiring.package; filter:="(osgi.wiring.package=org.openhab.binding.icloud.handler)"
osgi.wiring.package; filter:="(osgi.wiring.package=org.openhab.core.library.types)"
osgi.wiring.package; filter:="(osgi.wiring.package=org.osgi.service.component.annotations)"; resolution:="optional"
Declarative Services

Any ideas?

Do you install from the market place, or from the .jar provided in this thread?

with kind regards,
Patrik

From the .jar copied to the addons folder

Can you try how the one from the market place? Is this OH 2.1 release, or 2.2 cutting edge?

Cutting edge, same as my install at home. I’ll try the marketplace version when I get back later and report back, thanks Patrik

No luck there. I removed the jar from the addons folder and tried to install from the marketplace:

2017-09-19 13:34:38.797 [thome.event.ExtensionEvent] - market:binding-3642624: Binding cannot be installed: Error occurred installing a bundle.

Sorry to hear that - I’ve currently no idea what might be the issue with the dependencies :frowning: . Especially as it works on your system, mine but not the one in question.

Maybe someone else will give us a hint where to look; at the moment I can not help. The only thing we could do is to try the very latest build from
https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/binding/org.openhab.binding.icloud/2.2.0-SNAPSHOT

via addons folder

1 Like

That worked! I’m even more confused now, but thanks for the suggestion Patrik.