Tesla Fleet Integration - Key pairing issue?

I have been setting up a clean Tesla Fleet integration as per documentation.
My public key is hosted on a local webserver behind a Nginx Proxy Manager where I copied the file in /.well-known/appspecific/com.tesla.3p.public-key.pem and https://subdomain.mydomain.ext is accessible from outside world (just a plain index.html page in the folder)
Setup worked fine, my two cars are in the home assistant and sensors are correctly updated.

But sending commands doesn’t work despite a succesful installation of the keys through https://tesla.com/_ak/subdomain.mydomain.ext on my Android app. (notification of key addition received, key on subdomain.mydomain.ext is displayed among the keys in vehicle).

I get two error messages:

  • Command failed: Vehicle did not recognize the key used to authorize command. Make sure your key is paired with the vehicle after restarting home assistant
  • Failure of button/press action. 'Session' object has no attribute 'epoch' when I try again afterwards.

Anyone has any idea of what I am doing wrong?

3 Likes

Same here.
On postman,co , I had to post with “OAuth 2.0” with the token generated in order to get 200 code response => a post with “inherit auth from parent” send a 401 code Unauthorized response :
{
“response”: null,
“error”: “No authorization token received”,
“error_description”: “”,
“txid”: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
}
I don’t know if it could be one reason.
I followed [Intégration Tesla dans Home Assistant 2025.1 - Entraide Home Assistant - Home Assistant Communauté Francophone]

Log doesn’t help me much:

2025-02-23 08:50:20.455 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139830656345296] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/tesla_fleet/helpers.py", line 39, in handle_command
    result = await command
             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tesla_fleet_api/vehiclesigned.py", line 453, in charge_start
    return await self._sendInfotainment(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/tesla_fleet_api/vehiclesigned.py", line 233, in _sendInfotainment
    return await self._sign(DOMAIN_INFOTAINMENT, command.SerializeToString())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tesla_fleet_api/vehiclesigned.py", line 241, in _sign
    session = await self._handshake(domain)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tesla_fleet_api/vehiclesigned.py", line 223, in _handshake
    await self._send(msg)
  File "/usr/local/lib/python3.13/site-packages/tesla_fleet_api/vehiclesigned.py", line 205, in _send
    raise MESSAGE_FAULTS[resp_msg.signedMessageStatus.signed_message_fault]
tesla_fleet_api.exceptions.TeslaFleetMessageFaultUnknownKeyId: Vehicle did not recognize the key used to authorize command. Make sure your key is paired with the vehicle

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2794, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2837, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
        hass, entity, func, data, call.context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tesla_fleet/switch.py", line 162, in async_turn_on
    await handle_vehicle_command(self.entity_description.on_func(self.api))
  File "/usr/src/homeassistant/homeassistant/components/tesla_fleet/helpers.py", line 52, in handle_vehicle_command
    result = await handle_command(command)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tesla_fleet/helpers.py", line 41, in handle_command
    raise HomeAssistantError(
    ...<3 lines>...
    ) from e
homeassistant.exceptions.HomeAssistantError: Command failed: Vehicle did not recognize the key used to authorize command. Make sure your key is paired with the vehicle
2025-02-23 08:50:26.397 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [13xxx296] Error handling message: Unknown error (unknown_error) MyName from 192.168.xx.xx (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 537, in handle_manifest_list
    raise int_or_exc

Same problem here. I checked all configuration steps and I can see als sensors, but I can’t send commands to the car.

Yep, exactly the same thing, can see all sensors, unable to send commands.

Same here.

Same. I’m fairly certain I followed all of the instructions correctly too. :cry:

I had this issue this morning. I noticed that the HA patch update (2025.2.5) had some Tesla API changes so I rolled back to 2025.2.4 and it seems to be working better for me now

in my case, 2025.2.4 had same issue too :smiling_face_with_tear:

same here, I had to upgrade because of another (known) issue in 2025.2.4
As I am not alone, I have opened an issue on git hub: Tesla Fleet Integration - Key pairing issue? · Issue #139165 · home-assistant/core · GitHub

3 Likes

First issue suggests the public key you have installed and the private key you have in your Home Assistant config directory do not match.

Second issue is known, was fixed, but then caused another issue. I will be trying to get a fix into 2025.3

1 Like

In my case, the issue was that the public key wasn’t registered to the vehicle.

Go to https://tesla.com/_ak/YOUR.DOMAIN(where your public key is hosted), and you’ll see a QR code. Scan this QR code with a smartphone that has the Tesla app installed, and a dialog will appear in the Tesla app asking to register a virtual key.

After completing this registration, reload the Tesla Fleet entry in Home Assistant, and the actions should start working correctly.

My issue is different I am afraid

I Have the same issue too.

I can read all the data from the car, but as soon as I try to change something (temperature, Sentry mode, locks, max charge etc.) I get the error:

Actie climate/set_temperature kon niet worden uitgevoerd. ‘Session’ object has no attribute ‘epoch’

(partly dutch)

Same issue here.

I have the same issue :frowning:

Anyone has a solution ?

Thanks

I’m having the same issue, not seeing an issue with the key.

I’m so glad other people are having this issue :relieved:. I thought it was just me being an idiot…

I noticed the same errors. Both from HA and in Node-Red. Node Red is easier to view all failing output.

The first call - results in the complaint about the key.
All subsequent calls with Session Key.

Restarting HA or the integration - will cause the key message to display again.
After that its back to the session message.

'Session' object has no attribute 'counter' or 'epoch'

Interesting that I can still wake the car, but I can’t set the charge percent. If the wake command is working, surely the key is ok?

I even asked me mate Mr. KnowItAll GPT if I set up the key correctly.
ha: /config/tesla_fleet.key
External Public Access of pem file at correct domain
Tesla application setup with domain
register the key with correct domain in car - verified

Surprisingly he didn’t tell me it was all wrong.

I tried the downgrade to 2025.02.04 - but no luck same Issue.

Looking forward to the update…

– Update
It seems maybe we’ve done something to mee up out HA installed key file. After comparing the HA file with the key file that I saved when I generated it - they were different. After I copied my original key file back to the correct location in the docker container - everything started working (2025.2.4)

What I can’t understand is how the contents of that file changed. I only ever ran the commands to generate the pair once (at least that I remember). So it is possible that deleting and reinstalling the integration resulted in a new key file somehow. I simply don’t know how that could be. Or one of the many auth commands I ran… I can’t say how it became different.

I suggest check the output of your private key in HA (tesla_fleet.key) with the original private-key file that you generated. If you don’t have that file anymore, create a new pair and put them the private key in HA and the public key at the location Tesla can access.

I suspect your problems will evaporate like mine.
Happy Command Issuing…

1 Like

Update to 2025.3 seems to have solved my issue

2 Likes

I was having the same issue. Even after the update to 2025.3, it didnt work for me. I went to config folder and updated the private key in the file named “tesla_fleet.key” to match with what was created in step 1 and everything is working for me now. so happy :slight_smile:

1 Like