iCloud device data integration in openHAB

Hi Partik,

ah - thanks for the hint on the location settings. That fixed it.

Great you found the root cause of the Error I had!
For me the lookup is a key feature of your binding - Personally, I’d not need it to be optional.
Giving this freedom to other users of course could be a feature.

Kurt

Hi Kurt,

a new Version of the binding is available that supports google API key:
https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/binding/org.openhab.binding.icloud/2.2.0-SNAPSHOT/

The new config key is called “googleAPIKey”; can you give it a try & let me know if it solves the issue. A free API key will provide you 2500 requests per day …

Note: The HEAD build contains breaking changes (e.g. renamed channels); it is recommended to re-condifure. See https://github.com/pgfeller/openhab2-addons/blob/master/addons/binding/org.openhab.binding.icloud/README.md for current documentation.

with kind regards,
Patrik

Hi Kurt,

I do some refactoring to the binding to process code review feedback … please have a look into the readme and the history of the pulll request; as e.g. also some config parameters were renamed (to lower camel case). It is not drop-in compatible with earlier configurations.

Let me know if you encounter problems or need more details.

with kind regards,
Patrik

Hi Patrik!

Thanks for the lighting fast update - with the API Key loaded the errors disappeared! Great work!

I noticed, that the lower camel case format is not yet available in the snapshot version above.
i.e. GoogleAPIKey worked for me, googleAPIKey didn’t.

Kurt

Hi there. I’m trying to show the location in HABPanel based on a Google Maps frame.

The following rule creates the Google Maps URL with coordinates:

rule "Update Google Maps Coordinates"
	when
		Item loc_icloud_RoSteLiMiMa_Location changed
	then
		 var coordinates = loc_icloud_RoSteLiMiMa_Location.state
		 str_icloud_RoSteLiMiMa_GMap_URL.postUpdate("http://maps.google.com/maps?q=" + coordinates)
end

This rule works without any issues and updates the string item str_icloud_RoSteLiMiMa_GMap_URL with a working URL: e.g. “http://maps.google.com/maps?q=40.7589626,-73.9893574

I tried to use the frame widget with “openHAB String Item” as URL source. Unfortunately the widget does now show any content.

image

Has anyone an idea why this does not work as expected?

I’m pretty sure you need to obtain a Google API key then enable Google Maps Embed API. It didn’t work for me until I did it. By default the Embed API is not enabled, but it is listed under Libraries when you go to the manage API keys area.

With the API key you can then make a minor change to your rule to generate a valid URL.

My set up has icloud_device_icloud1_0_Location as the item name for the phone location. I also have “String ericsiphone_GMap_URL” defined in items.

rule "Update Google Maps Coordinates"
        when
                Item icloud_device_icloud1_0_Location changed
        then
                var coordinates = icloud_device_icloud1_0_Location.state
                ericsiphone_GMap_URL.postUpdate("https://www.google.com/maps/embed/v1/place?q=" + coordinates + "&key=YOUR_API_KEY")
end

Can someone tell me how to set my home location to rule .

val PointType home = new PointType(new DecimalType(xx.xx…), new DecimalType(xx.xx…))
I didi this. and now?
Through icloud binding?
because by default as I see there are Coordinates and every 5 mins that the binding run shows me a distance that is not true(home to my phone)
thnx

sorry to interrupt: but is this also possible for Android devices? does someone know?
my whole family uses Android, not iOS. :stuck_out_tongue_winking_eye:

Check the first posting. I’ve added a rule to do exactly this, it is called “Function to calculate distance from location”.

@binderth Technically yes but I don’t know of any available API. Would you do the google search or ask in a google forum? The alternative is ownTracks of course.

The binding takes the home location from the openhab reginal settings property page & calculates the distance from there.

Have a look at the Owntracks binding - http://docs.openhab.org/addons/bindings/mqttitude1/readme.html

yes, I know about this. But it needs a seperate App (using battery power, needs to maintained…). Same reason I would jump on this iCloud integration rather than Owntracks for iOS! :wink:
plus, the meta info comes in handy (battery status, moving, …)

Ok I saw it but I don’t know how to use it . Sorry if I wasted your time , I feel stupid anyway

No worries. Good luck! let us know if you need help.

I have added the thing using paperui
set apple id, password, refresh 10, and added google api key
the binging stays showing as intializing not online.
can you advise how I go about troubleshooting?

Thanks

Paul

@idkpmiller
Hi Paul,

what version of OH do you use?
Do you see any log messages; especially if you run OH in debug mode?

with kind regards,
Patrik

@patrik_gfeller, I’m late to switch from the items/rules files that started this thread over to your binding, but am just getting set up. Firstly, thanks so much for your hard work. This integration is going to be one of my favorites.

I do have a feature request - since this is a great way to manage presence, how about a channel for presence that is switch on when the device is near home, and switches off when it leaves? I can (and will) do this in a rule, but it would be more elegant if it were wrapped up in the binding, and I suspect it might be a widely used feature.

I’m happy to open a feature request issue on GitHub if you’re in favor of adding this feature and that’d be helpful.

Again, thanks!

1 Like

Hi Patrik,
I came home today from work and found that my apperui inbox conatined new
apple devices discovered, sao it would appear it started to work at some
stage.
One interesting thing is prior to configuring the icloud binding I jumped
onto the icloud web site and cleared out an old devices by removing it from
my account. That old device was discovered by the binding. perhaps there is
a cache somewhere between the web site and the API being used.

Regards

Paul

1 Like

Thank you for building this binding! I’ve setup my Apple Watch S3 w/ LTE, and it seems to be the perfect presence tracker combined with this binding.

ok I did it and run the distance rule every 5 min. now I want to set this function in my rule . Could you tell me how

to call it inside my rule ?

// Function called to calculate location distance
	val Functions$Function4<GenericItem, PointType, String, Number, String> locationDistance= [ Coordinates, place, placeName, distance2 |
	  val PointType location = Coordinates.state as PointType
	  var int distance
	  var String message
	  
	  // my home location
	  distance = location.distanceFrom(home).intValue()
	  if (distance < 200) {
	    message = (String::format("%s (%dm)", "Home", distance))
	    logInfo(filename,message)
	  } else {
	    message = "(unknown location)"
	    logInfo(filename,message)
	    }
	  return message
	  
	]