alandtse / tesla

Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.
Apache License 2.0
582 stars 100 forks source link

Tesla command REST-API shutdown in 2024 #743

Closed jofleck closed 6 months ago

jofleck commented 11 months ago

Is your feature request related to a problem? Please describe. Starting 2024 Tesla will shutdown the existing vehicle command REST-API and requires end to end signed commands through a new API

https://developer.tesla.com/docs/fleet-api#2023-10-09-rest-api-vehicle-commands-endpoint-deprecation-warning

Describe the solution you'd like Maybe a possible migration strategy should be discussed. It may will be more difficult for end users with no IT experience to install this integration, because Tesla requires a public accessible domain with a hosted public certificate for each application.

Describe alternatives you've considered To be discussed.

top-gun commented 8 months ago

Oh. I bought my M3, but in Germany, many Teslas are leased, so that's going to be a challenge for many owners. Thanks for mentioning it, I didn't know about that.

There is a ticket about that : teslamotors/vehicle-command#45 For sure, given the number of companies that are leasing the cars for their employes, tesla will have to be more flexible on that if they want to sell their fleet services (unless they want the leasing companies to sell that service for the cars they provide... ? but for sure that will reduce the market potential)

Just so I get it right: There is no issue for private leasing? Here, Tesla is big in consumers leasing the cars, not so much in business leasing. From what I hear, fleet managers find it harder to lease a Tesla than i.e. a Volkswagen, Audi or BMW. The traditional companies have very favourable conditions and processes for fleet leasing, Tesla not.

purcell-lab commented 8 months ago

More news from Tesla, the FleetAPI now supports Powerwall and other energy products, which is the other half of the Tesla Custom Integration.

https://twitter.com/teslaenergy/status/1743010788070277579?t=D5NWqMTQmbN_8q6nKFA_Zg&s=19

Bre77 commented 8 months ago

Author of the Home Assistant Tessie integration here. Glad it's helping bridge the gap for many of you, because that's 100% why I spent most of my Christmas holidays working on it.

Two things of interest to this issue:

zadigre commented 8 months ago

@Bre77 is this already usable now? If yes, how do we pair it to home assistant?

Bre77 commented 8 months ago

@Bre77 is this already usable now? If yes, how do we pair it to home assistant?

I'm still working on the Home Assistant integration. The plan is to use Fleet Telemetry to stream update into Home Assistant rather than polling. Unfortunately Tesla hasn't signed my CSR yet so I can't test it.

baylanger commented 8 months ago

Author of the Home Assistant Tessie integration here. Glad it's helping bridge the gap for many of you, because that's 100% why I spent most of my Christmas holidays working on it.

I’m curious if you should consider contributing your code to this project? Not sure if it all makes sense but if it does, wouldn’t it be much easier for everyone to onboard using your service without having to change everything?

I’m not the best person to know what makes sense or not :)

purcell-lab commented 8 months ago

@Bre77 is this already usable now? If yes, how do we pair it to home assistant?

I'm still working on the Home Assistant integration. The plan is to use Fleet Telemetry to stream update into Home Assistant rather than polling. Unfortunately Tesla hasn't signed my CSR yet so I can't test it.

Your experience and knowledge with FleetAPI and Telemetry is very welcome, I have signed into/ up for your new teslemetry service and happy to assist with testing.

I do a lot of advanced energy management stuff in other parts of HA (EMHASS), including charging and discharging Tesla battery and vehicles. I have two vehicles, two gen3 wall connectors and Powerwall gateway that I can control via the legacy API, so happy to help migration rather than loose control.

lotharbach commented 8 months ago

I would like to offer another solution to send commands. I've researched and documented what the Tesla App is doing to send commands via Teslas "hermes" backend, and you can find a rough description and a link to demo code here: https://github.com/timdorr/tesla-api/discussions/769

I used that information to extend the official tesla-http-proxy with two modes:

You can find that project here: https://github.com/lotharbach/tesla-command-proxy/tree/owner-proxy

So the next step for me is to propose a setting so this integration can talk to the proxy instead, and test that combination.

I'm also absolutely confident generating the signed command messages and sending them via hermes or BLE or to the fleet API directly in python is possible and would be much nicer in the context of an HA integraiton than having to run a separate proxy software.

bkr1969 commented 7 months ago

Do we have to pay to get the Tessie API Key? That's lame.

Bre77 commented 7 months ago

Do we have to pay to get the Tessie API Key? That's lame.

It's not free to operate a service like Tessie, and we expect Tesla is going to start charging Tessie for their API access. The only free path moving forward appears to be signing up as a developer yourself and self hosting everything.

ve6rah commented 7 months ago

The only free path moving forward appears to be signing up as a developer yourself and self hosting everything.

Considering that we are already self-hosting home assistant, I suspect that most people don't have too much of an issue with self-hosting. However not all of us are developers, so what I'd like to see is a pre-built package for self-hosting with good home assistant integration (ideally built as an add-on so we can deploy it on HAOS), and a quick how-to on signing up as a developer to get it working.

top-gun commented 7 months ago

The only free path moving forward appears to be signing up as a developer yourself and self hosting everything.

Considering that we are already self-hosting home assistant, I suspect that most people don't have too much of an issue with self-hosting. However not all of us are developers, so what I'd like to see is a pre-built package for self-hosting with good home assistant integration (ideally built as an add-on so we can deploy it on HAOS), and a quick how-to on signing up as a developer to get it working.

Exactly, however atm nobody seems to be willing to step forward and create a new plugin that will work with the new API. My personal solution atm is to stick to the current Tesla integration from alandtse which keeps pulling data in, and to have an extra pi in my garage which uses Tesla's go-based utilities to send Bluetooth-commands to the car. MQTT works as a connection between HA and that Pi. It was a bit of an effort, but it works well enough for me to control my car's charging from PV or cheap grid energy at night.

And no, I'm not competent enough to adapt the current integration to the new command API. All I do is patchwork-programming :)

ve6rah commented 7 months ago

I'm also not entirely sure how my car will be affected anyway. Much of the stuff I see about the new API talks about it only applying to new cars, so I'm really not sure what's happening with my 2014

top-gun commented 7 months ago

I'm also not entirely sure how my car will be affected anyway. Much of the stuff I see about the new API talks about it only applying to new cars, so I'm really not sure what's happening with my 2014

That was settled during the last days - most or all cars that were controllable via the old API are no longer accessible that way. Yours truly owns an M3 built in 05/23, and the old command API was blocked about two weeks ago.

ve6rah commented 7 months ago

I'm also not entirely sure how my car will be affected anyway. Much of the stuff I see about the new API talks about it only applying to new cars, so I'm really not sure what's happening with my 2014

That was settled during the last days - most or all cars that were controllable via the old API are no longer accessible that way. Yours truly owns an M3 built in 05/23, and the old command API was blocked about two weeks ago.

Well I can tell you that the existing integration is working for me for all controls still on my 2014 Model S, The only thing I can't do is force a data update with the button. everything else continues to work. Your M3 is a very new car, from what I've seen announced, only newer cars are being forced to the new API, older cars remain on the old API (and may not work with the new one) But I'm not 100% on this.

scoop643 commented 7 months ago

I'm also not entirely sure how my car will be affected anyway. Much of the stuff I see about the new API talks about it only applying to new cars, so I'm really not sure what's happening with my 2014

That was settled during the last days - most or all cars that were controllable via the old API are no longer accessible that way. Yours truly owns an M3 built in 05/23, and the old command API was blocked about two weeks ago.

Well I can tell you that the existing integration is working for me for all controls still on my 2014 Model S, The only thing I can't do is force a data update with the button. everything else continues to work. Your M3 is a very new car, from what I've seen announced, only newer cars are being forced to the new API, older cars remain on the old API (and may not work with the new one) But I'm not 100% on this.

My 2024 Model Y LR also still works and only the data update and steering wheel heater doesn't work anymore.

top-gun commented 7 months ago

I'm also not entirely sure how my car will be affected anyway. Much of the stuff I see about the new API talks about it only applying to new cars, so I'm really not sure what's happening with my 2014

That was settled during the last days - most or all cars that were controllable via the old API are no longer accessible that way. Yours truly owns an M3 built in 05/23, and the old command API was blocked about two weeks ago.

Well I can tell you that the existing integration is working for me for all controls still on my 2014 Model S, The only thing I can't do is force a data update with the button. everything else continues to work. Your M3 is a very new car, from what I've seen announced, only newer cars are being forced to the new API, older cars remain on the old API (and may not work with the new one) But I'm not 100% on this.

My 2024 Model Y LR also still works and only the data update and steering wheel heater doesn't work anymore.

Is there anything else you can still control, like opening the charging port? In November 2023, Tesla staff announced that all new cars would not be accessible through the old control API anymore.

Some very old Model S and X are excempt as they did not get upgraded to use the new API.

scoop643 commented 7 months ago

Yes i can control the charging rate, unlock doors, flash light, seat heaters, etc. It is the same with the 2019 Model 3, only data update doesn't work (and heated steering wheel at the Model Y).

ve6rah commented 7 months ago

You're missing the point I was trying to make. Per Tesla themsleves:

January 2024 All vehicles* will require Tesla Vehicle Command protocol. The REST API will be fully deprecated *Fleet accounts are excluded from these changes until further notice. Pre-2021 Model S/X are excluded from these changes.

Which states that anything before 2021 is not affected. So my worry is that if a new add-on or integration is created, it may not even work for my 2014, and it seems that the current answer to any bugs on this one is "it doesn't matter because it's going away" (see the bugs that were raised for the data update button, which were closed referencing this bug rather than fixed using the fixes included in the bug reports.

So if the new integration isn't going to work for me, and this integration is being abandoned because the new one is coming, where does that leave us pre-2021 owners?

ve6rah commented 7 months ago

Some very old Model S and X are excempt as they did not get upgraded to use the new API.

I take a bit of offence to your definition of "very old". The average age of a car on the road in the US is 12 years. Tesla are exempting everything over 3 old. That means that a HUGE number of cars are still trying to use the existing integration.

skipishere commented 7 months ago

This integration isn't being potentially abandoned, PRs are still welcome to fix things. In terms for cars built 2021 and later there are questions around if they will be easy to get working again. I for one would love the integration to keep working for cars (I have a Model 3 2023, which for now still works) and my Powerwall.

top-gun commented 7 months ago

January 2024 All vehicles* will require Tesla Vehicle Command protocol. The REST API will be fully deprecated *Fleet accounts are excluded from these changes until further notice. Pre-2021 Model S/X are excluded from these changes.

Which states that anything before 2021 is not affected. So my worry is that if a new add-on or integration is created, it may not even work for my 2014, and it seems that the current answer to any bugs on this one is "it doesn't matter because it's going away" (see the bugs that were raised for the data update button, which were closed referencing this bug rather than fixed using the fixes included in the bug reports.

So if the new integration isn't going to work for me, and this integration is being abandoned because the new one is coming, where does that leave us pre-2021 owners?

Actually, only Model S and X before 2021 are excempt. Model 3 and Y before 2021 are or will be affected. Sorry about my mistake about only "very old" cars being excempt. No, 2020 isn't old. I drove my old 350Z for 14.5 years, too. Still, based on what staff wrote, all Model 3 and Y are or will soon be affected, and that means all volume models are affected regardless of their model year. Yes, S and X can still be in their prime time and not be affected, but that's a small percentage of the cars out there.

top-gun commented 7 months ago

This integration isn't being potentially abandoned, PRs are still welcome to fix things. In terms for cars built 2021 and later there are questions around if they will be easy to get working again. I for one would love the integration to keep working for cars (I have a Model 3 2023, which for now still works) and my Powerwall.

Again, Tesla says only Model S and X before 2021 are excempt. Your car will be affected soon. Are you just logging data, or are you actively controlling functions of the car?

skipishere commented 7 months ago

This integration isn't being potentially abandoned, PRs are still welcome to fix things. In terms for cars built 2021 and later there are questions around if they will be easy to get working again. I for one would love the integration to keep working for cars (I have a Model 3 2023, which for now still works) and my Powerwall.

Again, Tesla says only Model S and X before 2021 are excempt. Your car will be affected soon. Are you just logging data, or are you actively controlling functions of the car?

Hence the "for now" part, we have seen over the last month more people affected by the API change, I am expecting to lose control at some point soon

ve6rah commented 7 months ago

Yes, S and X can still be in their prime time and not be affected, but that's a small percentage of the cars out there.

And it's comments like this that REALLY make me worry about whether I'm going to be abandoned here, If I can't use the new API, and so many people here are dismissing all older S/X cars, it really makes me question if I'm going to be able to keep using any integration going forward.

top-gun commented 7 months ago

Yes, S and X can still be in their prime time and not be affected, but that's a small percentage of the cars out there.

And it's comments like this that REALLY make me worry about whether I'm going to be abandoned here, If I can't use the new API, and so many people here are dismissing all older S/X cars, it really makes me question if I'm going to be able to keep using any integration going forward.

Well, you car is one of those which can keep using the Tesla-integration with all functionality. The glass is half-full :)

ve6rah commented 7 months ago

Well, you car is one of those which can keep using the Tesla-integration with all functionality. The glass is half-full :)

Yes and no, people are avoiding fixing the existing integration because they dismiss the number of cars it's relevant for (and it is currently at least partly broken). And as everything else gets re-written to work with Tesla's new system, it makes it sound like we may get tossed out with the bathwater. I'm just trying to raise awareness that we're out here, and we still want this integration maintained, and we want any future fixes to not jettison compatibility with our cars.

purcell-lab commented 7 months ago

The FleetAPU framework is very similar to the legacy framework as used by this integration, so large components can be reused.

There are already solutions emerging that allow monitoring and control via the FleetAPI; Tessie, NetZero and Teslemetry to name a few.

alandtse commented 7 months ago

Yes and no, people are avoiding fixing the existing integration because they dismiss the number of cars it's relevant for (and it is currently at least partly broken). And as everything else gets re-written to work with Tesla's new system, it makes it sound like we may get tossed out with the bathwater.

The thing about open source is it's driven by people who have the issue and have the skill/motivation to fix it. Less people means it's less likely you'll meet those conditions. It's also a bit disingenuous to expect people without the problem or the $100K vehicle to spend their free time fixing your problem. So implying they somehow have a responsibility to fix it is not only unrealistic but off putting. To be frank, every time I feel like looking at this issue again to consider workarounds, I see people with this attitude and I decide to just ignore it since it's ultimately not my problem.

The existence of this project is because random people decided to share what they could do for everyone else to use and it happened to cover your use case. We didn't take your money. We don't owe you anything. If anything, that's Tesla. We also didn't break the API, that's Tesla. Direct your frustration appropriately.

darek-margas commented 7 months ago

The existence of this project is because random people decided to share what they could do for everyone else to use and it happened to cover your use case. We didn't take your money. We don't owe you anything. If anything, that's Tesla. We also didn't break the API, that's Tesla. Direct your frustration appropriately.

I would say if anyone "must have it fixed", can go and pay Tessie which for inexpensive fee will do it.

lits101 commented 7 months ago

Yes and no, people are avoiding fixing the existing integration because they dismiss the number of cars it's relevant for (and it is currently at least partly broken). And as everything else gets re-written to work with Tesla's new system, it makes it sound like we may get tossed out with the bathwater.

The thing about open source is it's driven by people who have the issue and have the skill/motivation to fix it. Less people means it's less likely you'll meet those conditions. It's also a bit disingenuous to expect people without the problem or the $100K vehicle to spend their free time fixing your problem. So implying they somehow have a responsibility to fix it is not only unrealistic but off putting. To be frank, every time I feel like looking at this issue again to consider workarounds, I see people with this attitude and I decide to just ignore it since it's ultimately not my problem.

The existence of this project is because random people decided to share what they could do for everyone else to use and it happened to cover your use case. We didn't take your money. We don't owe you anything. If anything, that's Tesla. We also didn't break the API, that's Tesla. Direct your frustration appropriately.

It's disappointing that you have to put up with this sense of entitlement from people.

This has been a great integration and it's still working for me, despite the same deprecated API no longer working for evcc (go figure?). I've managed to cobble together an "evcc emulation" automation in HA to continue solar charging for as long as the old Tesla API continues to accept connections from my host.

I'll be sad to see it stop working due to no fault of your own. You've done great work and it's appreciated here!

Bre77 commented 7 months ago

If the owner API has stopped for you and you need a refuge, Teslemetry is free for now (but will have to charge something eventually), and I have a fairly feature complete HACS integration with both vehicles and energy APIs. https://github.com/Teslemetry/hacs-teslemetry

I don't want this to take away anything from this integration though, as it's been a huge inspiration and what I used daily until 2024.1.

feu77 commented 7 months ago

Hi, I own a Model Y since almost 2 years having it perfectly integrated in HA. I use a zigbee2mqtt button glued to the charging cable to unlock the cable to get it out. Everything works fine. Now I got a second Model Y last week. It appeared automatically in HA through the Tesla integration. I get infos (SOC, temps etc...), but sending commands isn't working.

Is the above discussion about REST API sutting down in 2024 the reason?

EDIT: ok, nevermind, as I read further, that's teh reason...sadly...waiting for Tela Fleet API integration then...

darek-margas commented 7 months ago

I use a zigbee2mqtt button glued to the charging cable to unlock the cable to get it out.

Just get RF button to open, it will work forever.

feu77 commented 7 months ago

I use a zigbee2mqtt button glued to the charging cable to unlock the cable to get it out.

Just get RF button to open, it will work forever.

Ah ok, can you give me a hint how to? Thanks

darek-margas commented 7 months ago

Ah ok, can you give me a hint how to? Thanks

https://pl.aliexpress.com/item/1005006241142149.html

feu77 commented 7 months ago

Ah ok, can you give me a hint how to? Thanks

https://pl.aliexpress.com/item/1005006241142149.html

ok, thanks. But if I get it right, both of my cars will unlock. Seems it's a viable way, the car not used will close, relock the cable after some time and hopefully resume charging if it got interrupted...) I've seen there's another way via ios shortcut/HA... let's see..

Anyway, thanks!!

darek-margas commented 7 months ago

But if I get it right, both of my cars will unlock

If you go to some public parking all Teslas will open. This is what Tesla puts on own chargers.

llamafilm commented 7 months ago

I built an add-on that runs the official HTTP Proxy using your own personal Tesla auth and key. It handles the initial authorization flow in a temporary Flask app. So maybe this integration could be modified to add a custom endpoint for the add-on

https://github.com/llamafilm/tesla-http-proxy-addon

floqqi commented 7 months ago

Ah ok, can you give me a hint how to? Thanks

https://pl.aliexpress.com/item/1005006241142149.html

Does this button really unlock the cable if it is plugged in? What I always read is that it only opens the carge port cover, but it can not stop charging and unlock the cable.

ve6rah commented 7 months ago

I'm unsure on your use case. The button on the cable should release it if the vehicle is unlocked, with no need for this. This button is useful for opening charge port doors in older cars that didn't have the ability to push the port itself to open. Especially useful when paired with non-Tesla chargers as the tesla ones have this button built into r charge handle.

purcell-lab commented 5 months ago

https://developer.tesla.com/docs/fleet-api#2024-03-26-shutting-down-legacy-vehicle-api-endpoints

2024-03-26: Shutting down Legacy vehicle API endpoints Fleet API is Tesla's official 3rd party API and the only supported API for vehicle interactions. The list of available endpoints can be found at Endpoints and Regional Requirements. Starting April 2024, any vehicle APIs not part of this list will be phased out. Per the Fleet API policies, continued usage of unsupported APIs will result in the revocation of Fleet API access privileges.

thuesen commented 5 months ago

Does this plugin still use any of the old unsupported API’s?

It sounds like if one continues to use them, one will be banned from using the new Fleet API?

MrBLJ commented 5 months ago

Guess it's time to start using the Tesla HTTP Proxy.

The installation process is beyond my knowledge for now, would anyone have a step by step guide on the prerequisites parts, using HA addons ?

From what I've read in the documentation, I'm hoping that we can use DuckDns and Nginx add-ons to reach the first goal : "You must have a domain name (FQDN) with a valid SSL certificate to host your public key on standard port 443."

If anyone can confirm this is indeed a way to go, I can start messing around and I'll write a tutorial for users like me with 0 knowledge about this.

edit : found somewhere to start

top-gun commented 5 months ago

Guess it's time to start using the Tesla HTTP Proxy.

The installation process is beyond my knowledge for now, would anyone have a step by step guide on the prerequisites parts, using HA addons ?

From what I've read in the documentation, I'm hoping that we can use DuckDns and Nginx add-ons to reach the first goal : "You must have a domain name (FQDN) with a valid SSL certificate to host your public key on standard port 443."

If anyone can confirm this is indeed a way to go, I can start messing around and I'll write a tutorial for users like me with 0 knowledge about this.

edit : found somewhere to start

I wrote a huide, but it‘s in German:

https://docs.google.com/document/d/10D-VPjKn9KXTtsnZQC3umNz8oIp5v5CXTXWOE7OeUhU/edit

MrBLJ commented 5 months ago

Guess it's time to start using the Tesla HTTP Proxy. The installation process is beyond my knowledge for now, would anyone have a step by step guide on the prerequisites parts, using HA addons ? From what I've read in the documentation, I'm hoping that we can use DuckDns and Nginx add-ons to reach the first goal : "You must have a domain name (FQDN) with a valid SSL certificate to host your public key on standard port 443." If anyone can confirm this is indeed a way to go, I can start messing around and I'll write a tutorial for users like me with 0 knowledge about this. edit : found somewhere to start

I wrote a huide, but it‘s in German:

https://docs.google.com/document/d/10D-VPjKn9KXTtsnZQC3umNz8oIp5v5CXTXWOE7OeUhU/edit

That's a great start thanks a lot ! I'll have to adapt like the Myfritz setup, but this is definitely useful !

mp3guy commented 5 months ago

Am I being naive or does the Tesla Fleet API Proxy nonsense not completely kill the ease of integration? So you have to either use Home Assistant OS to use an add-on, or manually mess around with running the docker yourself. This is significantly more difficult than it was before. The simple process of reading your car's battery charge % is now behind a huge wall of complexity. Or am I mistaken?

Bre77 commented 5 months ago

The simple process of reading your car's battery charge % is now behind a huge wall of complexity. Or am I mistaken?

Well it can be easy if your willing to pay someone to do all the hard stuff for you. But yes, self hosting is now hard for Tesla vehicles.

MrBLJ commented 5 months ago

It's not that complicated .... once you've figured out how to do it ^^. This was my case because I don't have knowledge in this field, like at all.

I've written a procedure that covers the full process of getting the proxy to work. @alandtse, do you think it's a good idea to post it on this repo ?

alandtse commented 5 months ago

I've written a procedure that covers the full process of getting the proxy to work. @alandtse, do you think it's a good idea to post it on this repo ?

@MrBLJ The wiki is open to anyone who wants to help out.