Companion app Android Auto sensor

When using the companion app, there is an Android Auto sensor that can say whether or not a specific mobile device is connected to a car. But is there any way to be able to tell which car? I was recently driving my in-laws car, which also has Android Auto, and I plugged in my phone, and some automations related specifically to my phone and my car were triggered. If I’m not driving my car, I don’t want this to happen. Is there a “car UID” or something that can be exposed in the sensor’s attributes?

Any android auto devevelopers here?

Enable the car sensor for the car name, same place you enabled the other sensor

Yes, I have the sensor enabled. I can tell when my device is connected, but maybe I missed something…is there any “car ID” value? I’m not connected right now to check it.

Try the Bluetooth sensor the Mac address will be unique per vehicle

I had thought about this, but my car requires a cable for Android Auto, and I wasn’t sure if a BT connection would always be present. I guess that’s the best that is currently possible? I’m tryingt to implement this generically (using templates) so that it also works for my wife’s phone.

For anyone else who’s interested, here’s what I have so far:

A template sensor for all mobile_app devices connected to Android Auto:

{{ integration_entities('mobile_app')
  | select('contains','_android_auto') <--- gets only the android auto sensor entity
  | select('is_state','on')            <--- only if that sensor is 'on'
  | map('device_id')                   <--- Get the device ID so we can later
  | list                                    retrieve the bluetooth sensor
}}

This is what I set my automation trigger to monitor:

trigger: template
value_template: '{{ states('sensor.android_auto_connected_devices') | length > 0 }}'
for:
  seconds: 30

Then, in my automation, I set up some variables to map the devices to their bluetooth sensors:

variables:
  connected_device_bluetooth_sensors: >-
    {% set connected_device_sensor_groups = states('sensor.android_auto_connected_devices')
      | map('device_entities') -%}
    {# flatten the list, because 'sensor_groups' is actually a list of lists #}
    {% set var = namespace(flat = []) -%}
    {% for sublist in connected_device_sensor_groups -%}
      {% set var.flat = var.flat
          + sublist | select('contains', '_bluetooth_connection') | list
      -%}
    {% endfor -%}
    {{ var.connected_device_bluetooth | unique | list }}

  vehicle_mentions: >-
    {{ connected_device_bluetooth_sensors
      | select('contains', 'connected_') <--- Look for the 'connected' attributes
      | map('state_attr')                <--- Get the value of those attributes
      | default([], true)                <--- Empty list if they are not present
      | select('contains', CAR_MAC)      <--- If they contain my car's BT MAC addr.
      | list }}

Then finally, a condition to ensure that the Android Auto-connected devices are ALSO connected to the car’s bluetooth

          - condition: template
            value_template: "{{ vehicle_mentions | length > 0 }}"

I was just hoping for a simpler method like
{{ state_attr('sensor.android_auto', 'car_id') | contains("MY CAR") }} :smiley:

the car name sensor will work as long as you dont have 2 cars with teh same make and model is that not enough for you? the sensor updates when connected to the car and teh app is launched

https://companion.home-assistant.io/docs/core/sensors#car-sensors

includes the manufacturer, make and year so for me the state is ascent and attributes for Subaru and 2023 as the manufacturer and year

Holy crap, I have never noticed all these car sensors in here before! This is my first car with Android Auto, and I only had the binary_sensor on. I was relying on sensors from a custom integration for my car brand. This will make things so much easier!

Thanks!

1 Like

Finally got in my car and none of those “_car” sensors have moved from the “unavailable” state, even after 10 minutes of my phone being connected.

You need to start the app each time

1 Like

I read your posts in other threads about these sensors. Kia’s implementation of them sucks. Out of all those sensors, they only report the car name and the speed :frowning:

There is a Kia custom integration, but the frequency of updates is very unpredictable. It seems the car, even when it’s running, doesn’t report its status very often to their cloud service. There are many days when I’m only making several short trips where, as far as the sensors are concerned, the odometer reading keeps going up, but the the engine never turns on :expressionless: And the device_tracker entity never leaves the driveway.

I know this isn’t the app’s fault, but the whole car experience is kind of underwhelming.

Thanks for all your help, though.

i have the same experience in my Subaru. Only name and speed work. The subaru integration has a custom one that lets me do custom polling and works well and provides all the other data I need.