onokje / node-red-contrib-tesla

Node red nodes to control Tesla vehicles and devices
MIT License
20 stars 11 forks source link

API deprecated, Tesla will end support per 1/2024. How to move on? #67

Open Michael-K-at-GitHub opened 8 months ago

Michael-K-at-GitHub commented 8 months ago

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

Following the release of Tesla Vehicle Command SDK support for REST API vehicle command endpoints is now reaching end of life. Starting 2024 most vehicles will require sending commands via Tesla Vehicle Command SDK.

Are there plans to revise node-red-contrib-tesla? Or do we have to assume that node-red-contrib-tesla will stop working at the beginning of 2024?

onokje commented 8 months ago

Good question. I haven't given this library much attention lately, but I am not giving up on it either. I will do some reading and let you know.

Michael-K-at-GitHub commented 7 months ago

Any update?

andrasg commented 5 months ago

I am not able to use commands, they result in 403, probably because of the deprecation of REST API's. Any plans for supporting the Tesla vehicle commands protocol?

I am assuming not much you can do, as probably the underlying TeslaJS library would need to support it...?

Michael-K-at-GitHub commented 5 months ago

I confirm that the old API has been turned off and this node no longer functions.

@onokje we need word from you, ether that you will look into this and find a solution, or that we have to move on to other solutions and abandon node-red-contrib-tesla

Lineflyer commented 5 months ago

Starting today it seems Tesla changed/deactivated the "old" API.

It stopped working and the node reports "Precondition failed". Even worse my node-red instance crashes each time I try to open the configuration node to add/change the tokens.

Any plans to work on it, any help I can provide?

onokje commented 5 months ago

Hi all, I will definitely take a look, because I still use this myself :) Unfortunately I don't have a lot of time right now, so any help is appreciated.

andrasg commented 5 months ago

TeslaJS folks are aware too, looks like they need to figure out auth first. https://github.com/mseminatore/TeslaJS/issues/353

fascenda commented 5 months ago

Sorry to read this, I don't even have my Tesla yet, and new to Node Red. At least you confirm the Precondition Failed return came from Tesla so I must have some configuration correct. (What a horrible choice of words when Precondition already has meaning for Climate and Battery, couldn't they dream of a different word for the API?)

I know it has subscription cost, but maybe node-red-contrib-tesla could use the Tessie API and shift the burden to them when Tesla changes their side. I've looked at Tessie and they expose their own API.

Lineflyer commented 5 months ago

@fascenda The "Precondition failed" is an node internal error as it cannot get a valid result authenticating to the API. Sadly this also leads to a crash of whole node-red due to a seemingly unforeseen condition.

There is IMHO no need to change to some paid third party API. There is still a Tesla API, but just the endpoint and syntax changed. There is now a fleet API endpoint for companies, and also some other possible entry ways.

fascenda commented 5 months ago

Thanks @Lineflyer I did understand THAT use of Precondition was relating to the API, okay I see now it's HTTP response 412. Up until that I was getting a variety of other failures, so I call it a success that I got the error. (Along the way, I did have some crashing or hangups in the flow editor and had to restart node-red a few times.)

I agree relying on some subscription product would be best to avoid, as a long-retired software dev, I favor open source wherever I can find it. I just installed an OpenEVSE and also EmonCMS on a Raspberry PI for collecting data. That's where I will be collecting my Tesla data. As I said I don't even have the car yet just getting electric service upgraded and learning all this great software.

Lineflyer commented 5 months ago

The API was really great. You have been able to get all relevant (and even unrelevant) information about the current state of your car. For example: You even got the currently played song title ;) I hope there will be a a way to get that back again...maybe its already possible right now, but I am not technically fit enough to implement a new API myself.

bkr1969 commented 5 months ago

I don't understand how the integration still works (all I needed to do was get a new refresh token). I can't seem to reconfigure the config node with this token though. And, unfortunately, I cannot delete it completely because even though all the nodes are deleted, it still shows "in use." Is there a way to reconfigure or can someone help me delete?

fascenda commented 5 months ago

@Lineflyer I read the Tesla "unofficial" API docs and I did see all the things you could do like see what's on the radio. I've been reading some of the updated docs, and again I don't have a Tesla (yet) so I'm only taking some of my past software experience and trying to learn/understand what I find in online documentation. It seems as if Tesla API will now only work with requests from known domains, so something like TeslaFi or Tessie (or many others) that have registered URL could gain access to it. That doesn't sound hopeful for our private servers running Node RED.

Which is what was on my mind when I said maybe going via Tessie is the solution, and I understand there is cost there. And I won't be surprised if Tesla starts charging for use of their API, which will potentially increase the cost of these middleware apps. Software has come a long way since I started my software career (40+ years ago). Subscription ($$$) is the way everything is going.

ASomerN commented 5 months ago

I've set up my system to move excess solar to the car automatically and that means having access to change amps, something I can't see how to do via tessie right now.

GaPhi commented 5 months ago

I have started this weekend a node-red mock-up that uses same messages content as this project do but using the new fleet API.

SInce now, it seems working, but there still have some work to achieve to package it for its distribution...

The job is not so huge to get it working, then something should come quite soon as a plug and play substitute of this node...

Just be a bit patient, as I never coded a new node type. Maybe someone could help a bit?

BTW, I have found some mistakes in teslamotors api documentation too, I still have to signal it to them to let them fix it.

After this fleet API working with nodered, the telemetry API would be next challenge... Or the fleet API for recent models (I have a 2019 model S) then I do not need it (yet).

Le mar. 30 janv. 2024 à 19:56, fascenda @.***> a écrit :

@Lineflyer https://github.com/Lineflyer I read the Tesla "unofficial" API docs and I did see all the things you could do like see what's on the radio. I've been reading some of the updated docs, and again I don't have a Tesla (yet) so I'm only taking some of my past software experience and trying to learn/understand what I find in online documentation. It seems as if Tesla API will now only work with requests from known domains, so something like TeslaFi or Tessie (or many others) that have registered URL could gain access to it. That doesn't sound good for our private servers running Node RED.

Which is what was on my mind when I said maybe going via Tessie is the solution, and I understand there is cost there. And I won't be surprised if Tesla starts charging for use of their API, which will potentially increase the cost of these middleware apps. Software has come a long way since I started my software career (40+ years ago). Subscription ($$$) is the way everything is going.

— Reply to this email directly, view it on GitHub https://github.com/onokje/node-red-contrib-tesla/issues/67#issuecomment-1917691759, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADUNWNJAPFM4MYWEFNYHSMTYRE65LAVCNFSM6AAAAAA6BGRZ7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJXGY4TCNZVHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Lineflyer commented 5 months ago

@GaPhi That sounds great. Pergaps you should put your work on a pull request for this repository so that @onokje can take care of the packaging into a new version of this node?

dnlschmdt commented 5 months ago

I have made a few attempts: After I changed the url from "vehicles" to "products" in line 662 in teslajs.js, the "vehicle or device" list worked again and node-red did not crash.

exports.vehicles = function vehicles(options, args, callback) {
    exports.get(options, '/api/1/products', null, callback);
}

I used @GaPhi fork of this tesla implementation. After this it was possible to set charge amps and other commands. Getting vehicle data was not possible yet, but have just started.

GaPhi commented 5 months ago

Here is my mock-up flow, working with my own other flows... but probably not enough robust or well-packaged yet, and without any explanation about how to configure it... But if you are able to follow teslamotors partner registration process, you should be able to get it work too.

If some contributors are interested, we can set a little project up to progress faster. The idea is to create 2 nodes :

Here is the file (copyright myself) flows.json

bikeymouse commented 5 months ago

I've set up my system to move excess solar to the car automatically and that means having access to change amps, something I can't see how to do via tessie right now.

Have you looked at: https://developer.tessie.com/reference/set-charging-amps ?

bikeymouse commented 5 months ago

... But if you are able to follow teslamotors partner registration process, you should be able to get it work too.

Isn’t that the main problem? Will Tesla really allow thousands of individual users register as “partner”? I think not.

bkr1969 commented 5 months ago

I have made a few attempts: After I changed the url from "vehicles" to "products" in line 662 in teslajs.js, the "vehicle or device" list worked again and node-red did not crash.

exports.vehicles = function vehicles(options, args, callback) {
    exports.get(options, '/api/1/products', null, callback);
}

I used @GaPhi fork of this tesla implementation. After this it was possible to set charge amps and other commands. Getting vehicle data was not possible yet, but have just started.

Where is this .js file located? (Using Home Assistant) I'd like to try that.

RobReus commented 5 months ago

I have made a few attempts: After I changed the url from "vehicles" to "products" in line 662 in teslajs.js, the "vehicle or device" list worked again and node-red did not crash.

exports.vehicles = function vehicles(options, args, callback) {
    exports.get(options, '/api/1/products', null, callback);
}

I used @GaPhi fork of this tesla implementation. After this it was possible to set charge amps and other commands. Getting vehicle data was not possible yet, but have just started.

Where is this .js file located? (Using Home Assistant) I'd like to try that.

I am running Node Red in a docker, and found the file at /data/node_modules/@gaphi/teslajs/teslajs.js. Check where palettes are installed and you will find it. Otherwise, just do a find -name teslajs.js in the root (/) of the filesystem and find it that way.

I just did this change and it has worked for me as well.

bkr1969 commented 5 months ago

Thanks. I started digging while waiting and found it. Giving it a try. Do I need to restart Node Red first?

RobReus commented 5 months ago

Thanks. I started digging while waiting and found it. Giving it a try. Do I need to restart Node Red first?

Perhaps. After I did the edit, I tried it which crashed my Node Red again, effectively restarting it. After that, it worked for me.

bkr1969 commented 5 months ago

Seems to have worked. I'm going to replace some spots in my flow and see how it does overall. Thanks for your help!

bkr1969 commented 5 months ago

Now, can someone tell me how to vent the windows using this API? Unfortunately I deleted all my old nodes and now I keep getting "missing command param" when I try. The climate setting works just fine.

bkr1969 commented 5 months ago

I've tested most of the other options and they seem to work . It almost seems like the specific command "windowControl" isn't working for some reason.

Lineflyer commented 5 months ago

Seems to have worked. I'm going to replace some spots in my flow and see how it does overall. Thanks for your help!

@bkr1969 Does this mean, that this simple change made the whole node-red-contrib-tesla work again for you?

bkr1969 commented 5 months ago

Everything but the windows control (that I've tested so far).

Lineflyer commented 5 months ago

Ok, are you refering only to commend sending, because I would be mostly interested in retrieving the vehicle status (such as battery_state, climate_state, etc.) rather than sending commands.

bkr1969 commented 5 months ago

Sorry. I hadn't tested info retrieval. Just did and it doesn't seem to be working. Oddly, the custom Tesla integration (Home Assistant) is working perfectly.

hitnrun30 commented 5 months ago

I have made a few attempts: After I changed the url from "vehicles" to "products" in line 662 in teslajs.js, the "vehicle or device" list worked again and node-red did not crash.

exports.vehicles = function vehicles(options, args, callback) {
    exports.get(options, '/api/1/products', null, callback);
}

I used @GaPhi fork of this tesla implementation. After this it was possible to set charge amps and other commands. Getting vehicle data was not possible yet, but have just started.

Where is this .js file located? (Using Home Assistant) I'd like to try that.

I am running Node Red in a docker, and found the file at /data/node_modules/@gaphi/teslajs/teslajs.js. Check where palettes are installed and you will find it. Otherwise, just do a find -name teslajs.js in the root (/) of the filesystem and find it that way.

I just did this change and it has worked for me as well.

At least his is step in the right direction, Node Red isn't crashing for me in Docker. I still can't get information

hitnrun30 commented 5 months ago

I have a question, has anyone updated all /api/1/vehicles to /api/1/products?

I tried but not sure all are good to change.

svwhisper commented 4 months ago

As much as I enjoyed using these nodes, I have started to migrate to using the http node and the Tessie API. Tessie isn't free, but for $4.99 USD per month, I get the Tessie app and an API based on the authorised Tesla API. It's very easy to update my flows to use Tessie. Tesla apparently hasn't confirmed how much it will charge businesses (like Tessie) to use its API, so it's possible the fee will be excessive and Tessie might cease operation or increase their price.

For now, it works. Being off-grid, it's very important my automation works to avoid running the house batteries flat.

fascenda commented 4 months ago

Tesla apparently hasn't confirmed how much it will charge businesses (like Tessie) to use its API, so it's possible the fee will be excessive and Tessie might cease operation or increase their price.

I tried the Tessie API with the http node and agree it's easy to use and I may go that route also. But I share the concern that Tessie may have to pay Tesla which will likely increase the cost.

jakepusateri commented 4 months ago

Yesterday I moved to use https://github.com/teslamotors/vehicle-command in my flow using the exec node. This tool has a Bluetooth connection option, so no need for cloud anything. It was a drop-in replacement for my solar charging automation (start/stop charging, set amps, set charge limit).

ASomerN commented 4 months ago

The Tessie dev says Bluetooth is limited to a few commands and not (for example) changing amps. Are you able to confirm this is the case? I can't see in that documentation anything specifically about Bluetooth but I might be blind.

jakepusateri commented 4 months ago

Check out the repo I posted, Tesla official. I am doing all of what I described currently and it works.

On Mon, Feb 12, 2024 at 2:27 AM ASomerN @.***> wrote:

The Tessie dev says Bluetooth is limited to a few commands and not (for example) changing amps. Are you able to confirm this is the case? I can't see in that documentation anything specifically about Bluetooth but I might be blind.

— Reply to this email directly, view it on GitHub https://github.com/onokje/node-red-contrib-tesla/issues/67#issuecomment-1938165095, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATA5MU7O35GTZKCHBL36TTYTG76XAVCNFSM6AAAAAA6BGRZ7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZYGE3DKMBZGU . You are receiving this because you commented.Message ID: @.***>

hitnrun30 commented 4 months ago

Yesterday I moved to use https://github.com/teslamotors/vehicle-command in my flow using the exec node. This tool has a Bluetooth connection option, so no need for cloud anything. It was a drop-in replacement for my solar charging automation (start/stop charging, set amps, set charge limit).

Can you give a bit more information on this?

jakepusateri commented 4 months ago

What do you want to know? That repo provides a tool called "tesla-control". After setup (detailed in their docs), I use an exec node to run commands like

~/go/bin/tesla-control -vin <MYVIN> -ble -key-file /data/private.pem charging-set-amps 20
demod-au commented 4 months ago

Here is my mock-up flow, working with my own other flows... but probably not enough robust or well-packaged yet, and without any explanation about how to configure it... But if you are able to follow teslamotors partner registration process, you should be able to get it work too.

If some contributors are interested, we can set a little project up to progress faster. The idea is to create 2 nodes :

  • tesla-api (compatibility with this github)
  • tesla-fleet (more efficient/evolutive one) And configuration nodes for Client ID&Secrets/Regions/Domains&Callbacks.

Here is the file (copyright myself) flows.json

@GaPhi I'm trying to use your code. Looks nice and I'm getting my head around it. One thing holding me back is; do I have to make my node-red publicly accessible for the callback? This is something I would like to avoid. Also is there somewhere else to discuss your implementation?

cstar707 commented 4 months ago

svwhisper

Hey any chance you could share your flows for your off grid setup I am looking to do the same.

Lineflyer commented 4 months ago

Yesterday I moved to use https://github.com/teslamotors/vehicle-command in my flow using the exec node. This tool has a Bluetooth connection option, so no need for cloud anything. It was a drop-in replacement for my solar charging automation (start/stop charging, set amps, set charge limit).

As seen in the readme.md of this tool it is also capable of acting as a proxy towards the tesla servers to enable usage of the new Fleet API for old API implementations.

Wouldn't it then be possible to add this proxy to node-red-contrib-tesla to make it work again?

svwhisper commented 3 months ago

svwhisper

Hey any chance you could share your flows for your off grid setup I am looking to do the same.

I don't know if this will be helpful, but have a look: https://pastebin.com/wemZzcUc

You will need to update your VIN and obtain and copy the bearer token, per Tessie docs.

Jeoffreybauvin commented 3 months ago

What do you want to know? That repo provides a tool called "tesla-control". After setup (detailed in their docs), I use an exec node to run commands like

~/go/bin/tesla-control -vin <MYVIN> -ble -key-file /data/private.pem charging-set-amps 20

I wanted to test this, but I need a legal business entity :(

sergio-daniels commented 3 months ago

Hello I was able to get it fixed with the info to change line 662 in the .js file. Now I'm able to execute command to retrieve data, but as soon I try to set something, I get "forbidden" as an answer. does it mean the authentication is not correct? Thanks for any help

sergio-daniels commented 2 months ago

Here is my mock-up flow, working with my own other flows... but probably not enough robust or well-packaged yet, and without any explanation about how to configure it... But if you are able to follow teslamotors partner registration process, you should be able to get it work too.

If some contributors are interested, we can set a little project up to progress faster. The idea is to create 2 nodes :

  • tesla-api (compatibility with this github)
  • tesla-fleet (more efficient/evolutive one) And configuration nodes for Client ID&Secrets/Regions/Domains&Callbacks.

Here is the file (copyright myself) flows.json

Thanks for this flow. I think I got it more or less up an running. But When I click any of the tests it always complains that the State is missing. From where should msg.STATE which is needed in function "Do user-api call" be set? If I set it manually it works but I don't see where it gets persistent after the function "Get Tesla authentication code" there its sent on the second output. Thanks for any information.

andreas-fe commented 2 months ago

I´m also not so familiar with node red, but in this open source project, they solved the connection issue: https://github.com/evcc-io/evcc/

Lineflyer commented 2 months ago

@andreas-fe Any link to an issue or pull request in that project with relation to that problem? I could not find it while scrolling through issues.

andreas-fe commented 2 months ago

@andreas-fe Any link to an issue or pull request in that project with relation to that problem? I could not find it while scrolling through issues.

We are still in the issue #67 with the problem of the deprecated Tesla API. For me as new node-red user, the usage of the latest version will result in a crash + reboot of node-red