At the moment i’m working on a Android App that sends the location of the device via API-Call to pimatic.
What do you think is the best way to implement rules on this informations?
I’m thinking of rules like turning on heat if the distance between device and home decreases abruptly.
(Driving home from work).
-
Plugin pimatic-location - Rules based on location
-
Whats about something like:
“If location of myphone is 1km from myhome then bla bla bla”
“if location of myphone is 5km and after 10 minutes location of myphone is less than 1km then bla bla bla” (“getting closer”) -
Hm… this would require to push the distance between the device and pimatic instead of the location. But i think this should be possible.
-
You could use the Traccar android app as a basis: http://www.traccar.org/source.jsp
So you just would to need to adapt the api call.
-
Getting the location or getting the distance isn’t much of a trouble.
I got an example working. Need to make it more configureable and implementing the service.
-
Had a little discussion about this kind of rules last week.
How do you see the difference in leaving home and coming home with your distance?Like my projects and help? Consider donating electroneum etnjwAKGPqF6omQWRmpp9u2BPyVDG9VuyRQjNJ1S8yfBdfR9qeUQ46kRy8KS2CNqbpNLRrsgmNW6F2TMzxmZgPrh6KctrkrYbm
-
well i guess you’ll have to check a certain time whether the distance increases or decreases.
but what if you’re within the given area (for example the above 5km) and you are moving around?pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
Nice @Oitzu !
Location check is always about distance, isn’t it?
At some point you’ll need to check the distance between two spots.
Example:
Action based on location (easy):
if myphone is at “50.020022x3939443” (allow some tolerances) then quack quackAction based on distance as described above…just check if it’s getting closer, probably implement something like:
if myphone is getting closer to “50.0000x3495r435” then quack quackSo this checks (for example) 3 times
Last location is different to location1 = true
location 2 is closer than location1 = true
location 3 is closer than location2 = true
then output true else retryBecause of the “leaving” and “coming” problem, I have the same issue with my door contact.
So I use the “if myphone is not present for 2 hours and myphone is present then quack quack”
(we need a “was” in the rules^^)
This way you avoid the action to be triggered if you leave home or you’re just out to get some cigarettes/bread -
something like:
“if distance is > 5km and athome = 1 and distance > last_distance then athome = 0 and last_distance = distance”
“if distance is > 500m and athome = 1 then athome = 0 and last_distance = distance after 2 hours”
“if distance is < 500m and athome = 0 then athome = 1 and last_distance = distance”
“if distance is > 5km and athome = 0 and distance < last_distance then athome = 1 and last_distance = distance”;Does this makes sense? Didn’t mind the correct syntax
-
I know it’s not for all platforms but I bet most of us use Android, so you could also use Tasker and Locations plugin which rely on either GPS or Google Location Services, then POST your location from the droid to pimatic and update $variable(s) this way. I am trying something like that just not sure how to go about with the math position / distance
Also do we want to use “driving” distance or haversine ?
-
This post is deleted!
-
Currently i’m getting latitude and longitude via get from the raspberry. (That’s the variables you see on the screenshot). Then calculate on the Android Phone, with the help of the Location Provider the distance between the phone and the given location and setting this to a variable in Pimatic.
Do i understand it correctly that you are working on a android app, too? -
I am unable to write any code, the best I can do is work around something with Tasker. What I have in mind is probably use something like Google Distance Matrix API to POST to Pimatic the distance between my phone and home.
I though of another approach, which rely on the location history .kml file you can download and then parse see this question on stack
I like both, the second one seem easier to implement?
-
As mentioned before i got a working example for “solution 1”.
I will publish the code and a apk as soon i got enough time to write a working prototype. -
I played around with Google-Distance, looks pretty cool. I wonder how hard would it be to integrate it to pimatic? With this approach all we need to do is periodically post our position and this will calculate the driving distance as well as the estimated time. Seems pretty interesting for building rules like:
IF $I is 10 minutes from home or within 5km and $I is getting closer THEN blablabla
-
The google direction api https://developers.google.com/maps/documentation/directions/?hl=en have a lot of features.
Well, writing a plugin for pimatic is beyond my capabilities, because i have no experiences with nodejs.
Is there maybe someone who is interested in doing the nodejs/pimatic part of this? -
I am not sure we need “directions” like in “the path to get from A to B” I think distance and “direction” as <-coming or -> leaving and estimated time of arrival are more relevant. What do you guys think?
-
https://github.com/Oitzu/pimatic-location
If anyone is interested. -
@Oitzu I would give it a try but how do you install this on Android?
-
Oh i forgot to add the apk. Done.
To use this app you need to add 3 variables to your Pimatic.- longitude - longitude of your home
- latitude - latitude of your home
- distance - You can choose the name of this variable freely and change it in the app. In this variable the distance betweend your home and your phone will be saved.
You can use this website to get your longitude and latitude.
http://www.mapcoordinates.net/en