I’m using this rule, it seems you don’t need this “sensor” and “language” stuff you are using. somewhere here is a message about how to register for the API key in case you don’t have one yet
rule "MacBook Dad formatted address"
when
Item MacBookDadLocation changed
then
val _url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + MacBookDadLocation.state.toString + "&key=abcdef"
val _geocodeJSON = sendHttpGetRequest(_url)
val _address = transform("JSONPATH", "$.results[0].formatted_address", _geocodeJSON)
MacBookDadLocationString.postUpdate(_address)
end
Can someone help me to create an rule when my distance is less then 5000m from home, open the garage door?
Maybe someone have a rule like this already and can post this for me
This would be great.
[ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Standortbestimmung: iPhone': Number of arguments did not match. Expected: 4 but was: 2
When the rule file is loaded then i get this mesages:
[INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'icloud.rules', using it anyway:
Incorrect number of arguments for type Function2<P1, P2, Result>; it cannot be parameterized with arguments <GenericItem, PointType, String, Number, String>
THX
UPDATE
I found the error. I made a mistake in the Lambda function. I used type Function2 but i need type Function4.
Can anyone confirm that on OH2.2 and latest version of the binding, you can persist the location of a device? It doesn’t seems to log it, not even attempt to do it (when looking at influxDB logs).
I do not have exactly what you are looking for, but I´ve made an example rule that calculates the distance from home. Maybe you can use part of it…
/***********************************************************************************
Rule - Distance from home
This rule is triggered by an updated location item (Martin_Location). The location
item holds the coordinates to my iPhone and is updated by the Bridge/Thing in an
iCloud binding. The rule updates an item (Distance_From_Home) by calculating the
differene between two locations (a static HOME location and Martin_Location)
*************************************************************************************
Pre-requisites
***************************************************
1. An .items file with the following content
Location Home_Location
Number Distance_From_Home
2. A configured Bridge/Thing using the iCloud binding with a location item (in this case Martin_Location)
*****************************************************/
rule "Distance from home"
when
Item Martin_Location changed
then
// ***************************************************************************
// Set the location for HOME (tip - use google maps to find the coordinates).
// ***************************************************************************
// The Norwegian Royal Palace (Lat, Lon)...
Home_Location.state = new PointType(new DecimalType(59.916940), new DecimalType(10.726740))
// ******************************************************************************
// Calculate the distance from HOME (Home_Location) and iCloud (Martin_Location)
// ******************************************************************************
Distance_From_Home.postUpdate(Home_Location.distanceFrom(Martin_Location))
// Optional logging to /var/log/openhab2/openhab2.log
logInfo("Distance from home : ", Distance_From_Home.state.toString())
end
I tried now with several different steps to get the icloud binding running, but the PaperUI allways shows offline.
Does someone have an idea what i can do?
I tried to use my normal icloud password and later i tried an application-specific password, generated in my icloud account, but both ending in the following error:
could somebody explain how to call the function with different “places”. The function itself is clear to me. Call the function with one place…also fine.
No, as your phone has just one location which is passed to the function as coordinates.
What you need is several places (home, work, school, etc.) which will be compared to your actual location.
Ok, i have several places as you mentioned. So now when the rule is fired it will pass this to the function (iPhone7_Coordinates, home, "Home" 200))
and compares actual location against “home”.
Should i now add 4 line to the rule like iPhone7_Location.postUpdate(locationDistance.apply(iPhone7_Coordinates, office, "Office" 200)) iPhone7_Location.postUpdate(locationDistance.apply(iPhone7_Coordinates, home, "Home" 200)) iPhone7_Location.postUpdate(locationDistance.apply(iPhone7_Coordinates, school, "School" 200))
Sorry, i´m confused