I'm trying to automate the opening of my garage when I am driving up to the house. We walk places fairly often, so it's not quite enough to use mobile presence/arrival as a trigger.
I have a Tesla (without Homelink) and was able to connect the car to HE with the Smartthings device driver. I can get the latitude and longitude that way, and whether the car is "driving".
But, I am at a loss with respect to how to convert the coordinates into a presence sensor. Ideally, I'd like to use some app/driver/rule/combination to create a geofence, and when the car's coordinates pass into that geofence, set off my rules.
I started to look into Google's Maps API's - and that looks like it might be a viable path - but I'm hoping there's an easier way since that is definitely over my head at this stage.
I believe Hubitat has a GeoFence capability that merges with the Phone app. That may solve part of the problem. If not, you will need to keep searching.
Thanks for the reply! I am using the Hubitat app and its Geofencing - but unfortunately that gets me the location of my phone, not the car. Since we regularly go for walks here in the city, I'd like to link to the car's state and location to avoid my garage opening up when I leave and return home on foot.
Oooh very interesting -- I'm a rookie here, so forgive the stupid question. Are you proposing that I throw that formula in as a global (or maybe local?) variable and then use the result in my triggers (say, when distance < some threshold)?
No, you will have to calculate each time you get a new car location sample, the location of your home will probably not change. Will give the distance between the two. The formula above gives result in km, you would just set a desired radius. Changing the constants would give you miles, etc. See the link for details. You will need to code it in Groovy, let an app or driver (however you get Tesla to pass lat/long) do the Calc, & create a trigger value. Essentially, your โdriverโ will be a number generator (like a voltage meter) that outputs a distance, to use as a trigger.
I've thought about doing something similar with my car and others have mentioned getting a separate presence sensor, and just leaving it in the car. This way when the car enters the mesh, it'll open the garage
Considered this as well. Hoping to avoid it since I've got a car that provides lat/long data, but I think it's a pretty good fallback if I can't get @672southmain's idea turned into a solution.
OK, I think I got it working, after tinkering with syntax in both the driver and the app for a while. I'm successfully returning a distanceFromHome value based on the formula above and a user-entered home latitude and home longitude value upon instantiating the car via the app.
My only remaining question is - the driver is set to automatically refresh every 15 minutes (and the distanceFromHome calc is embedded in the code that runs on refresh). Even if I reduce that to every minute, I'm still thinking that's not frequently enough to actually open the garage door on approach. Will a subscription from rule manager monitor the distanceFromHome on more of a "push" basis, or is there something else I am missing?
That seems like a weird thing to me. A car that expensive without it? Even my plain-Jane 2003 Minivan has it.
They do seem to make a Homelink retrofit for some of these cars. If it were me, I would want it even if it were just a backup to your Hubitat, it is nice to have a manual override at times. Says it is $300. https://www.tesla.com/support/homelink-faq
Is there a function you can call from within the device to check for the distance from home? You could maybe make a rule that triggers when the car is away from home, and to poll it maybe every minute and stop once the car is back within the radius.
The only iffy thing with this is if you drive within your circle but aren't going back home, it'll open your garage door