Hey @patrik_gfeller,
you should also mention, that the address lookup can easily be implemented in a rule for the time being. So no need to be sad about the removal of that function. The rules needed are already available in the first posting of this thread: https://community.openhab.org/t/icloud-device-data-integration-in-openhab/32329/1
Hi all,
I´m happy to report that the 1st version of the binding was merged to OH 2.2 and will be part of the release . Once more a big thank to @ThomDietrich, @Kai, @martinvw, @hmerk for their patience and help. Without them the binding would not be possible.
Also many thanks to all who tested early versions of the binding and provided valuable feedback.
I have one small request: Documenting is not my strongest part; thus if you have improvements for the readme that would be beneficial for new users please provide me feedback. Prefered in a form that I can directly use in the document to improve it .
with kind regards,
Patrik
Can you provide us the icons for the sitemap?
Is it also possible to set a standard zoom for the map? at the moment i think the view is a bit too high
Not sure if the default widget can do this; but if you use basic ui (not the apps) the following might help you to create your map of dreams:
Unfortunately that does not work in the applications for an unknown reason.
with kind regards,
Patrik
I am getting a problem calling the distanceFrom method from the PointType class.
My Rule:
rule Sophia_Home_Distance
when
Item ICloud_Sophia_Location changed
or
Item Home_Coordinates changed
or
System started
then
logInfo(Sophia_Home_Distance.name, "Current Location: {}", ICloud_Sophia_Location.state.class)
logInfo(Sophia_Home_Distance.name, "Home Location: {}", Home_Coordinates.state.class)
var DecimalType distanceType = ICloud_Sophia_Location.state.distanceFrom(Home_Coordinates.state)
var long km = distanceType.intValue / 1000
logInfo(Sophia_Home_Distance.name, "Distance: {}", km)
Sophia_Home_Distance.sendCommand(km)
end
Log Output:
2017-12-19 15:04:45.264 [INFO ] [me.model.script.Sophia_Home_Distance] - Current Location: class org.eclipse.smarthome.core.library.types.PointType
2017-12-19 15:04:10.773 [INFO ] [me.model.script.Sophia_Home_Distance] - Home Location: class org.eclipse.smarthome.core.library.types.PointType
2017-12-19 15:04:10.775 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Sophia_Home_Distance': 'distanceFrom' is not a member of 'org.eclipse.smarthome.core.library.types.PointType'; line 316, column 35, length 65
Can somebody tell me why this method should not be available? Other peoples are using them as well and in the sourcecode i can see this method.
Kind regards,
robert
Did you overlook the working rule in the first posting here? iCloud device data integration in openHAB
The problem is your use of .state
Correction: it needs an update. @patrik_gfeller are you going to do that?
Here you go:
val PointType location = iPhone_Location.state as PointType
val PointType home = new PointType(new DecimalType(48.123456), new DecimalType(11.123456))
if (location.distanceFrom(home).intValue() < 150) {
...
}
You mean this rule:
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(place).intValue()
if (distance < distance2) {
message = (String::format("%s (%dm)", placeName, distance))
} else {
message = "(unknown location)"
}
return message
]
But location and place are of PointType and not of LocationItem?
Btw this is kinda funny. Do you live in a trailer?
OK, but i used PointType already (i thought because of the log output)
When i change the code like this (with this extra ‘cast’)
var DecimalType distanceType = (ICloud_Sophia_Location.state as PointType).distanceFrom(Home_Coordinates.state as PointType)
its working
Took some time why this should be funny, but i got it
No, but i like it to have some things be configurable (not in rules) and next year i will move.
My explanation which (without checking) might be wrong: .state
will return a generic type. This generic type doesn’t offer the distanceFrom function. If that is the case you can probably leave out the second “as PointType” because it’s implicit.
OK, maybe.
Thanks for helping.
You originally used
var DecimalType distanceType = ICloud_Sophia_Location.state.distanceFrom(Home_Coordinates.state)
where Home_Coordinates is not of Type PointType, so would need to be casted to PointType.
Hello @patrik_gfeller,
until today I used an older binding from iCloud. It is a fantastic binding for my presence detection, thanks a lot for that.
But today, after updating the openHAB 2.2 from snapshot to the official release, I also wanted to switch to the official icloud binding.
I noticed that some channels were missing in the offical binding to earlier one.
Why are these channels no longer included?
Especially the channel Distance from home I missed, because I would have to rebuild this channel over a rule?
Now I downgraded to the older binding version.
I am not Patrick but might be able to answer on this.
Missing channels have been removed by intention, as those reflected not binding specific functionality, especially distance from home.
We have started discussing a more global approach.
Patrick did write something about that here:
Solution: Check out the first posting here to find rules which will give you the ability to do distance calculation and address resolution.
Sorry, I had skipped that.
I will try my luck between the Christmas holidays.
Thanks for your anwser.
hi
i am on 2.2 now but it was the same on 2.1 - i have it done all with rules and not with the new binding.
but my “Location Adress” isnt working this is my rule:
// ===========================================================
// Function to transform location coordinates to address
// ===========================================================
val Functions$Function1<GenericItem, String> locationAddress= [ Coordinates |
val geocodeURL = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + iPhone5s_Philipp_Coordinates.state.toString + "&language=german&sensor=true"
val String geocodeJson = sendHttpGetRequest(geocodeURL)
var String formattedAddress = transform("JSONPATH", "$.results[0].formatted_address", geocodeJson)
formattedAddress = formattedAddress.replace(", Germany", "")
return formattedAddress
]
my item:
Location iPhone5s_Philipp_Coordinates "Koordinaten" <suitcase> (IOS)
String iPhone5s_Philipp_Location_Address "Location Address [%s]" (IOS)
my result:
any ideas ? LogInfo of my Coordinates (iPhone5s_Philipp_Coordinates) is correct - thanks!
maybe you have exceeded the limit for the “free” use of the google API and need to use a (free) API Key ? i had the same issue, since using an API Key I dont have that anymore
thanks, how do i implement the api-key into the rule ?