iCloud device data integration in openHAB

@hmerk
Hello Hans,

fortunately I was able to figure out most of the stuff; discovery, parsing & thing handling works in the prototype. But I´ve no idea how far I´m from best practices (e.g. if such code has a chance ever to see the OH2 repo). Thus I would appreciate some feedback prior to going to the work of declaring all the channels.

2017-09-03 19_33_44-Paper UI

with kind regards,
Patrik

1 Like

@patrik_gfeller
Hi Patrick,
if you can update your fork with your latest results, I can do a first review later this evening.
You can even create a PR an mark it as [WIP]…
We can then directly comment on your code.

From What I see in your screenshot, this lokks excellent and is a good result in such a short time.

Best
Hans-Jörg

Hi Hans,

the fork is up-to-date … curious if it is useable; as I´m not working with java and those frameworks usually.
Depending on your feedback we´ll see how to continue best.

with kind regards,
Patrik

We will see later on… :wink:

Hey,
great work!
Is ist possible to start the signal sound to find the iPhone ?
Best regards Dennis

Hey, not with this method.

Check out this thread:

Is it ok to create a WIP PR even if a binding is still in prototype state?

Sure, that is totally OK.
By a signing it Work in progress you are telling the maintainers that there is no need to review the code already. However by having it posted as a PR others could help you.

2 Likes

A early alpha version for OH2 of the binding is available at
https://marketplace.eclipse.org/content/icloud-binding

feedback appreciated :slight_smile:

There you´ll find the source code and you can add comments & report problems with the code.
Cutting edge build with formatted address channel:

Supported channels:

  • Battery Status
  • Battery Level
  • Find My Phone
  • Location
  • Location Accuracy
  • Distance from home
  • Last Update
  • Address Street
  • Address City
  • Address Country
  • Formatted Address

Please let me know if it works, or fails with your device - I´ll compile a list of supported devices & try to fix those that do not work.

with kind regards,
Patrik

4 Likes

Yep - I´ve integrated this feature into the latest prototype as well.

2 Likes

Copied jar file into addon directory and restarted OH2, but can’t get the binding online. (ID and password applied of course)

Note: just copied the file using samba, do I need to run chmod / chown on the jar file ?

Question 1:
As for now I am on OH 2.1 stable, do I need to upgrade to 2.2 snapshot or should the binding run on the stable version as well?
Error message:

2017-09-11 12:16:15.771 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occurred while calling thing handler factory 'org.openhab.binding.icloud.internal.iCloudBridgeHandlerFactory@16db7f5': For input string: "d7a65448"
java.lang.NumberFormatException: For input string: "d7a65448"

Second: (original number exchanged against 1234567890123)

2017-09-11 12:31:22.829 [ERROR] [g.icloud.handler.iCloudBridgeHandler] - java.lang.NumberFormatException: Expected an int but was 1234567890123 at line 1 column 858 path $.serverContext.prefsUpdateTime

Question 2:
While the script was running well I wonder if I may use the items listed in the first post as well? Is there a need to create additional items or things (as for the “owner” for instance)?

Question 3:
I want to setup binding for two different accounts, could you please give me a hint how that needs to be configured?

Thanks for putting this into a binding @patrik_gfeller! Would it be possible to add another channel that gives the distance from any arbitrary location point (instead of just from Home)? This would then make it easy to test for whether the device is at specific places, such as work/schools etc.

Hi,

that would be possible - but how many locations should the binding support. This can be achieved quite easily with a rule (distance calculations) … thus I propose to do additional distances there. Let me know if you need help with how to do this in a rule.

btw.: do you use the binding already?

with kind regards,
Patrik

Kind off, at least I try … see my posting above

This kind of logic should not be part of a binding. It was discussed more than once, that a binding should provide data and allow interaction but higher evaluation logic should happen in a rule. @smar a rule to check the distance between two locations can be found in the first posting of this thread :wink:

1 Like

Thanks - I see that we have a distanceFrom built in into the location type, which of course removes the need for adding this sort of functionality to the binding. Ignore my earlier post… :slight_smile:

1 Like

@alkaline
Hi Marcus,

those are most likely bugs in the binding - as said; early alpha stage :slight_smile: … can you send me the logs of the binding in the area where it fails; I’ll have a look into it to fix it. Thanks for acting as a tester :wink:

with kind regards,
Patrik

1 Like

Just installed it out of curiosity as well, unfortunately the bridge is already failing.

Searched for thing, chosen bridge ant entered iCloud credentials.

Log shows:

2017-09-11 15:55:56.498 [hingStatusInfoChangedEvent] - 'icloud:bridge:fb612d65' changed from UNINITIALIZED to INITIALIZING
2017-09-11 15:55:56.511 [hingStatusInfoChangedEvent] - 'icloud:bridge:fb612d65' changed from INITIALIZING to ONLINE
2017-09-11 15:55:57.931 [hingStatusInfoChangedEvent] - 'icloud:bridge:fb612d65' changed from ONLINE to OFFLINE

And remains in offline state.

@bezibaerchen

The bridge has a status code (you’ll need to bind an item to it); what does it show?

After activating the Binding I went to Inbox and searched for things via iCloud Binding. I was able to choose between bridge and actual device. I’ve chosen bridge with the above result.
I now bound an item to owner channel of bridge but it remains empty as bridge stays offline.