Has anyone built an automation to track the presence of your cars?
Assuming that there is constant power on the OBD2 port, I’m considering the use of bluetooth OBD2 scanners in my vehicles in conjunction with a bluetooth enabled Pi deployed in my garage to establish a connection with the vehicles.
Short term, I’d be looking to trigger automations based on departure or arrival. Only really looking for binary home/away style presence tracking.
Long term, I’d love to be able to track vehicle data such as fuel level, water temperature (has the vehicle warmed up), and mileage for tracking maintenance activities.
This article on Instructables seems to be extremely relevant:
If you only want to know whether the car is or is not in the garage, I would build something with a NodeMCU and an ultrasonic sensor. Assuming you have wi-fi available in the garage, that whole setup would be about $10-15 worth of parts and some time writing code.
If you want to know your car is arriving - so you could open the garage door as it approaches automatically - then you could use an iBeacon like this one:
With a Pi (or something) running a beacon scanner.
However, I tried this beacon route and was not satisfied (I used the first USB-powered one). It turns out the scan interval / broadcast interval of beacons is something like every 4s or more and the range had through the garage door. I was using it opposite, however, which was I had the beacon in the garage and was using the iOS HA app to detect it.
When I have some time and motivation, I might try it the other way around with the beacon in the car and the detector in the garage.
Another option, which I have admittedly not tried myself, is the Traccar add-on & component combined with an OBD2 based GPS tracker or any of the other 12v car based GPS trackers. Traccar has a list of supported devices, so one of those plus a data SIM might do what you want for $25-$50 (depending on tracker).
I have a similar setup… I just want to know if the car is at home or not. I have a ESP32 with openmqttgateway firmware at the garage and bluetooth beacon on the car. I also track the car keys :-).
I attempted to use the MQTTCarPresence project for a more generic vehicle tracker (sticking to just home and not_home states). My thought was to use an ESP8266 to connect to Wi-Fi, publish messages to an MQTT broker, and use those interactions to influence a sensor that could pretend to be a device tracker.
The problem arose for me when I couldn’t determine whether the car was coming home or going away. Think about the flows:
Coming Home
ESP8266 is disconnected from Wi-Fi.
ESP8266 connects to Wi-Fi when you reach your house.
ESP8266 disconnects from Wi-Fi when you turn off your car.
Leaving Home
ESP8266 is disconnected from Wi-Fi.
ESP8266 connects to Wi-Fi when you turn on your car.
ESP8266 disconnects from Wi-Fi when the car drives away.
There’s no way to distinguish which sequence is the “coming home” sequence or the “leaving home” sequence. This is okay in the case of opening/closing a garage door, but when it comes to pseudo-presence detection, there’s a problem. In both cases, the following happens:
When the ESP8266 connects to Wi-Fi, it registers a LWT (Last Will and Testament) message with the MQTT broker.
When the ESP8266 disconnects from Wi-Fi, the LWT payload is published to the appropriate MQTT topic.
There’s no differentiation (that I can see).
I couldn’t figure out the appropriate mechanism to switch from the binary sensor equivalent of not_home to home (and vice versa) and retain that state until the next sequence; at best, I’d see the sensor be offline, come online for about a minute, then go offline again – doesn’t work for a device tracker.
I would love to find a solution, but my brain is mush on this one. Hoping someone has something more clever.
It’s a little crude, but do all of the drivers have location trackers themselves? Or are you actually trying to use this as a device tracker for “yourself?”
If the drivers do have device trackers, you could tie the state of the car to the state of the most recently changed device tracker after the lwt is published.
If you could somehow include the car’s on/off status in the payloads that could help too.
Alternatively, if your parking spot is consistent you could setup an ip cam with opencv or something to just see if your license plate is in the frame.
Edit: here’s an idea I actually like! choose some period of time that is slightly shorter than your typical shortest drive. After that time period, have the esp sketch change the payload from “leaving” to “arriving.” That way when your first fire up your car it will be indicating that you’re leaving, but by the time you return home on a drive it will indicate that as well.
I like that thinking. The blocker, I think, is that the LWT (the payload that gets sent when the device ungracefully disconnects from the MQTT broker) has to be set before the device connects to the broker (meaning it can’t be changed during runtime).
Not the most affordable solution, but I use Automatic PRO AUT-350 Connected Car OBD II Adapters in my cars. No monthly fee, 3G connectivity, and very accurate. Many more perks in addition to Vehicle Presence.
You’re right on the money: an Automatic Pro is the ideal solution. My wife actually has one and loves it; I was hoping to build an ESP8266-based thing so that I could save $115.
No problem! Instead of using the library as is, just have your esp publish the state every one second or something, with the state being leaving for the first few minutes, and arriving after that (or home/not home). Ignore the LWT stuff!
I use a iBeacon in each of our cars so at least the house knows when the cars are home; or not.
Using the iOS app I then set our phones to know if they are in a car; and that then assigns the iOS devices position to the car so zones and stuff works.
The challenge is the iOS app is pretty slow to update position.
I’m so grateful that you’re working this problem with me – thank you. I really like that idea: dump the LWT altogether and have the ESP regularly publish its status (again, changing that status based on how long it’s been online).
I’ll go back to tinkering and see if I can’t whip something up!
Another easy approach is to get something like this:
Set it up in infrastructure mode and connect to your WiFi AP. In my case I use Unifi APs and using the HA component I can track when a device is connected to my APs.
I use that approach for my grown kids to detect their presence. If they connect to WiFi, they are home.
If they choose to not turn WiFi on, I restrict access to my Wine/Beer/Liquor