thanks, how do i implement the api-key into the rule ?
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.
Hi,
i´ve a problem with this part of the rule:
iPhone_Location.postUpdate(locationDistance.apply(iPhone_Coordinates, home, "Home", 200))
it generates this error message:
[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).
Seems to be a bug.
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
Thanks for that but it’s not what I am looking for.
I am looking to persist the data in InfluxDB so I can plot it overtime in Grafana, which doesn’t seems to work.
Pretty much like persisting a temperature value, the coordinates doesn’t seems to
since OH 2.2 i have problems with my rules - i didnt use the binding now.
the first rule for my phone works, the second one for my watch is broken now and i get this:
[ERROR] [ore.transform.actions.Transformation] - Error executing the transformation 'JSONPATH': Invalid path '$.content[1].location.positionType' in '{"userInfo":{"accountFormatter":0,"firstName":.......
any ideas ? or should i switch to the binding ?
Why not give the binding a try
Hello,
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:
Thanks, Armin
Code 401 -> Unauthorized
Wrong Password ? You must use the Password for Login into icloud.com website … application based password don’t work
Hello, Thanks for the information, but what is the difference? i can login with this account to icloud.com. Thanks, Armin
Hello, i tried to use both, but both not working.
Armin
There must be an @icloud or if its older an @me / @mac Adress for an complete iCloud Account …
Are your devices in FindMyIphone in the @gmail account?
Yes all devices are visible under this account in the FindMyPhone area.
How can i get such an icloud account?
Thanks, Armin
Thanks for the Information, its working now.
Hi,
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.
iPhone7_Location.postUpdate(locationDistance.apply(iPhone7_Coordinates, home, "Home" 200))
But if i have 4 places, do i need 4 rules with different iPhone7_Location Items?
THX
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.
Hi,
thanks for your fast reply.
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