Welcome to HomeKitLab · a home lab that leans toward Apple Home · everyone is welcome, whatever you run at home · Ring cameras, go2rtc, and Home Assistant · best viewed in Netscape Navigator 4.0 at 800×600 ·

How to Show Your Tesla's Battery Level in Apple Home (Tesla Fleet, Home Assistant, and a Humidity Sensor Trick)

NEW!

Apple Home has no tile for "how charged is the car". The Tesla app knows, Home Assistant knows, and with one small trick Apple Home knows too. Each car shows up as a percent reading in the Home app, and flips to Low Battery when it drops under 20%.

The trick: HomeKit has no plain battery accessory, and Home Assistant's HomeKit Bridge does not publish a battery sensor on its own. It does publish humidity sensors, which are a percentage. So a template sensor copies each car's charge into a humidity sensor, and the bridge links the real battery level to it for the Low Battery status.

The page is dressed like a 1998 personal site. The YAML is current. It only reads the cars. Nothing here sends a command or wakes a car.

What you need
  • Home Assistant, and a Tesla account with a verified email.
  • A web domain with HTTPS where you can host one public key file.
  • The Tesla app on your phone, to install the virtual key on each car.
  • An Apple home hub, a HomePod or an Apple TV.

1 Connect the cars with Tesla Fleet

Tesla Fleet is the built-in Home Assistant integration for the official Tesla Fleet API. Setup has more parts than most, and the Home Assistant docs walk through each one:

  1. Create a developer application at developer.tesla.com/request. Grant type Authorization Code and Machine-to-Machine, your domain as the allowed origin, and https://my.home-assistant.io/redirect/oauth as the redirect URI. Tick Vehicle Information at least.
  2. In Home Assistant, Add Integration, Tesla Fleet. Enter the Client ID and Client Secret, sign in to Tesla, and choose Select All, then Allow.
  3. Enter your domain. Upload the public key Home Assistant shows to https://your-domain/.well-known/appspecific/com.tesla.3p.public-key.pem.
  4. Scan the QR code with your phone to add the virtual key to each car in the Tesla app.

The private half of that key pair stays in your Home Assistant config folder. Keep it, the client secret, and the Tesla token out of git and screenshots.

A Tesla Fleet setup window with a masked client id and secret, the domain example.com hosting the public key, and checks for the virtual key installed on Model Y and Model 3.
The Fleet API needs a developer app, a public key on your domain, and the key on each car.

2 Find each car's battery level sensor

Each car becomes a device with a long list of entities. The one you want is Battery level, a battery class sensor in percent. In this guide they are sensor.model_y_battery_level and sensor.model_3_battery_level. Yours take their names from what each car is called in the Tesla app.

Only add the cars you want in Apple Home. This house has a third Tesla that stays out of HomeKit, and that is just a matter of not listing it below.

A device window for a Model Y listing Battery level 78 percent, Battery range, Charging, and Climate, with Battery level highlighted.
Battery level is the one you want.

3 Mirror the level as a percent sensor HomeKit can show

Home Assistant's HomeKit docs list the sensors it can publish. A sensor with device_class: humidity and unit % becomes a HomeKit humidity sensor. A battery sensor is not on that list by itself. So make a template sensor that copies the battery level into that shape.

packages/tesla_batteries.yaml
template:
  - sensor:
      - name: "Model Y Battery"
        unique_id: hk_model_y_battery
        default_entity_id: sensor.model_y_battery
        device_class: humidity
        unit_of_measurement: "%"
        availability: "{{ is_number(states('sensor.model_y_battery_level')) }}"
        state: "{{ states('sensor.model_y_battery_level') | float(default=none) }}"
      - name: "Model 3 Battery"
        unique_id: hk_model_3_battery
        default_entity_id: sensor.model_3_battery
        device_class: humidity
        unit_of_measurement: "%"
        availability: "{{ is_number(states('sensor.model_3_battery_level')) }}"
        state: "{{ states('sensor.model_3_battery_level') | float(default=none) }}"

The availability line matters. When the Fleet sensor is unavailable or not a number, the mirror goes unavailable too, instead of reporting 0%. Leave these mirrors off your dashboards. They exist only for the HomeKit layout.

A flow diagram: sensor.model_y_battery_level, device class battery, which HomeKit skips; then a template sensor with device_class humidity and unit percent; then a HomeKit humidity sensor that reads 78 percent.
HomeKit skips battery sensors on their own. A percent humidity sensor is the closest tile.

4 A HomeKit Bridge for the cars

Put the bridge in the same package file. linked_battery_sensor adds a battery service to each accessory from the real battery level, and low_battery_threshold: 20 sets Status Low Battery under 20%. That is also the default.

packages/tesla_batteries.yaml
homekit:
  - name: Tesla Batteries
    port: 21080
    advertise_ip: 192.168.1.50   # your server's LAN IP
    filter:
      include_entities:
        - sensor.model_y_battery
        - sensor.model_3_battery
    entity_config:
      sensor.model_y_battery:
        name: Tesla Y
        linked_battery_sensor: sensor.model_y_battery_level
        low_battery_threshold: 20
      sensor.model_3_battery:
        name: Tesla 3
        linked_battery_sensor: sensor.model_3_battery_level
        low_battery_threshold: 20

A separate bridge keeps the cars away from the lights and the fans, and its own port keeps it apart on the network. Check the configuration under Developer tools, YAML, then restart Home Assistant.

A HomeKit Bridge window named Tesla Batteries: port 21080, advertise_ip 192.168.1.50, names Tesla Y and Tesla 3, linked battery sensor set, low battery threshold 20.
Each car is one sensor, with its own battery linked for the Low Battery status. The IP is a placeholder.

5 Pair it in the Apple Home app

Scan the QR code from the Home Assistant notification in the Home app, choose Add Anyway, and put both cars in a room such as Garage.

pairing.txt
Open the Apple Home app
Add Accessory
Scan the QR code from the Home Assistant notification
Add Anyway (uncertified accessory)
Room: Garage
Done

Each car is a humidity sensor named Tesla Y or Tesla 3, reading the charge as a percent. The Home app lists it with the other climate sensors, so the label says humidity. That is the trade for having the number in Home at all. Siri can read it out: "What's the humidity of Tesla Y?"

An Apple Home style window with a placeholder pairing code XXX-XX-XXX, a Tesla Y tile at 78 percent, and a Tesla 3 tile at 18 percent marked Low Battery.
Illustration, not a screenshot. Numbers are examples.

6 Troubleshooting

The number looks stale

Tesla Fleet polls each car every 10 minutes while it is awake, to stay inside Tesla's monthly API credit. A sleeping car keeps its last reading. Do not add an automation that wakes the car just to refresh the tile.

A car shows No Response

The mirror sensor goes unavailable when the battery level is not a number, which is on purpose. Check the car's Battery level sensor in Home Assistant, and the Tesla Fleet integration's status.

There is no Low Battery status

HomeKit caches an accessory's services. If you added linked_battery_sensor after pairing, reset the accessory so it comes back with the battery service.

Developer tools > Actions
action: homekit.reset_accessory
target:
  entity_id:
    - sensor.model_y_battery
    - sensor.model_3_battery
A troubleshooting window with three rows: stale number, Fleet polls every 10 minutes while awake; No Response, the level is unavailable; no low battery, reset the accessory.
The three things that come up most.

Back to the guides Home

Comments

Loading comments…