A2DP Sensor Commute Tracking Setup Guide

Hey everyone, I wanted to share my experience with setting up an A2DP sensor to track my daily commutes. I found this method really helpful, and I hope it can inspire others to try it out too!

My Setup

I use an A2DP sensor connected to my car’s Bluetooth system. The idea is simple: when my phone connects to the car via A2DP, the sensor detects it and starts tracking. When I arrive home and disconnect, it stops. The goal was to get a notification with the duration of my drive as soon as I disconnect.

Challenges and Solutions

At first, I wasn’t sure how to capture the duration. I considered using timers and input fields to store timestamps, but that felt a bit clunky. Then I remembered that Home Assistant already logs sensor data history! Why not leverage that?

Here’s what I did:

  1. Enable History Logging: Make sure history logging is enabled in your HA settings. This records all state changes, including when my A2DP sensor switches on and off.
  2. Create a Custom Automation: I set up an automation that triggers when the A2DP sensor changes to ‘off’. It then calculates the duration since the last ‘on’ state using the history data.
  3. Notification Integration: The automation sends a notification to my phone with the drive duration. Simple and effective!

Tips for Others

  • Test Thoroughly: I recommend testing your setup with short drives first to ensure everything works smoothly.
  • Location Integration: If you want even more precision, you can combine this with location sensors to start tracking only when you leave home.

Outcome

This setup has been a game-changer for me. Not only does it help me track my commute times, but it also gives me insights into how consistent my driving habits are. Plus, it’s a fun way to see how traffic affects my daily routine!

If anyone has questions or wants more details on the automation setup, feel free to ask! I’d love to help others set this up too. :blush: