·

Move fast, break things

Introducing the next-gen API and more flexible Fleet Telemetry

In preparation for the launch of command credits on February 1st, the Teslemetry API has been rewritten to provide a more consistent and predictable experience for users, while also enabling new functionality more easily. Unfortunately this hasn't been a perfectly smooth experience, however with the limited notice Tesla provided, Teslemetry is moving fast to ensure we remain a viable and useful service for all our customers.

Fully self documented and validated API

One of the biggest features is that the API is now fully self-documented, which means the documentation directly reflects the implementation of the API. While much of this documentation was copied from the Tesla Fleet API documentation, the Teslemetry API includes additional undocumented features, and reflects how the APIs actually work based on our experience. A good example of this is the Powerwall operation mode, which only has two documented modes, but there is actually a third "backup" mode you will find in the Teslemetry API documentation.

The other big change is that the API now validates input before forwarding the request, which is important since Tesla charges for vehicle commands even if their input is invalid. The documentation will clearly show what fields are allowed and which are required, and pre-emptively throw a status 401 if these are incorrect. I am sure this will evolve over time, so please share your experiences on Discord so we can improve the API for everyone.

Managed wake and credit header

Waking vehicles is the most expensive action to run on the Fleet API, so the API server has been designed to only wake your vehicle when it's required, and it is sure it is asleep. Since commands are charged whether the vehicle is awake or not, the API server will now also manage the process of waking your vehicle up for you. It's important to note that if Tesla is going to charge Teslemetry for a command, it will consume your command credits.

To help keep track of your balance, you will receive a x-credits and x-cost response header with the commands cost and your command credit balance whenever credits have been charged. You can also track your credits history on the Teslemetry console, and a sensor entity will be added to Home Assistant in the near future.

Under the hood

Teslemetry is now using Fastify for our API platform, a modern, high-performance web framework for Node.js, that delivers about 2x better performance than Express which we were using previously. The modular "plugin" design easily allows for new features to be added, or for certain features to split back out into microservices.

One of these features I am most excited about is adding support for native command signing without the Tesla Command Proxy. This will provide significantly more useful errors when a command fails, fix support for commands like remote boombox, and enable entirely new commands that are not available in the Fleet API directly. Unfortunately until this is implemented, some of the command endpoints are providing worse error handling than before.

New Fleet Telemetry options

Tesla has also announced new features for Fleet Telemetry that lets you set a resend_interval_seconds for each field, and minimum_delta for each numerical field. These behave as you would expect, with the resend_interval_seconds setting how often the field is resent even if its value hasn't changed, and the minimum_delta setting how much the field must change before it is sent. All this functionality will only take effect on vehicles running firmware 2024.44.32 or later, and requires prefer_typed to be enabled, which is going to be the default moving forward.

The new API server did make implementing these new features easier, and you can find the full list of field parameters here, but since the API is now self documenting, you can also browse the fields and their parameters directly in the API documentation.

The Teslemetry console has also been updated with an "Advanced mode" that lets you configure these new options directly, however I expected that the default settings will be suitable for the majority of users.

Move fast, break things

I am excited about what the new API server will enable Teslemetry to deliver. However to get there, Teslemetry is going to need to move fast and occasionally, break things.