Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No location information starting with vehicle software 2023.38.x #69

Open
Lineflyer opened this issue Nov 13, 2023 · 32 comments
Open

No location information starting with vehicle software 2023.38.x #69

Lineflyer opened this issue Nov 13, 2023 · 32 comments

Comments

@Lineflyer
Copy link

After my vehicle (Model 3) upgraded to 2023.38.6 I noticed, that drive_state object is now missing the elements latitude and longitude. So you are no longer able to use the current vehicle location in Node Red.

According to what I read here it might be related to a change in the API respectively, that location information was already moved to new/other endpoints (might be related to #67)?

@Lineflyer Lineflyer changed the title No location information starting with vehilce software 2023.38.x No location information starting with vehicle software 2023.38.x Nov 13, 2023
@Lineflyer
Copy link
Author

Lineflyer commented Nov 13, 2023

Here is more info from Tesla about how to get location data with newer vehicle software:
https://developer.tesla.com/docs/fleet-api#announcements-amp-api-changelog

Edit: Seems you can still get it, but need to include location_data explicitly in your request. I guess this could be an easy fix?
https://developer.tesla.com/docs/fleet-api#vehicle_data

@ChutneyMary
Copy link

Yes, please consider this request x2. Many automations relying on the location data are now broken with the latest Tesla update.

@ChutneyMary
Copy link

Here's a different application and an example of how they have altered their code to suit the new endpoints -

ngardiner/TWCManager@adbf1cb

@ChutneyMary
Copy link

ChutneyMary commented Nov 14, 2023

Here's a flow to pull the new endpoints for location. Note the field 'your id here' is the value of the very first object if you place a debug node on node-red-contrib-tesla. The objects user_id and vehicle_id won't work.

Tesla Location Endpoint.json

@Lineflyer
Copy link
Author

@ChutneyMary
Thanks, this is very helpful and works as an interim solution.
How about the access token? I guess it will be invalid after some hours as there is no refresh included.

Additionally I do now run into problems as I now need to issue two requests (one with node-red-contrib-tesla and this one) and the server starts throttling (error 408). Need to find a clever timing solution for that (or include all other endpoints into your nodes instead).

@ChutneyMary
Copy link

I have the same problem with throttling with two requests running. It's a choice between losing automations that rely on location data versus all the other data... Think I'll have to manually open the garage door for awhile...1st world problems!
I think the Access Code only has an 8 hour validity, so not even a good interim solution.
There's a lot of code hanging off node-red-contrib-tesla. Hopefully @onokje can come to the rescue soon!

@Lineflyer
Copy link
Author

1st world problems!

Indeed.

Hopefully @onokje can come to the rescue soon!

I think your node if a good PoC for a possible fix in node-red-contrib-tesla.
It might even start to have a look at the source and see if I can provide a PR, but I am not really familiar with JS and not familiar with node red syntax. So chances are high, that I will not be successful.

@GaPhi
Copy link
Contributor

GaPhi commented Nov 14, 2023 via email

@ChutneyMary
Copy link

Hello @GaPhi. I tried installing your version using Manage Palette in Node-Red. Unfortunately it has a boxed 'conflict' message. It won't allow installation. It also says the version is 2 years and 2 months ago (1.0.6-0)?

Is this the latest branch you have tweaked with the new endpoint? Or have I misunderstood something?

@Lineflyer
Copy link
Author

Is this the latest branch you have tweaked with the new endpoint? Or have I misunderstood something?

@GaPhi
I would have the same question as I did not see any related commit in your fork?

@GaPhi
Copy link
Contributor

GaPhi commented Nov 14, 2023 via email

@Lineflyer
Copy link
Author

I just had to add the 'location_data' new endpoint.

And you use these msg.* objects as input into the node-red-contrib-tesla node?

@GaPhi
Copy link
Contributor

GaPhi commented Nov 14, 2023 via email

@Lineflyer
Copy link
Author

@GaPhi
Do you know the correct name of all the endpoints normally contained in a node-red-contrib-tesla "overall" request?
I guess that's the reason why I can't get it working.

@GaPhi
Copy link
Contributor

GaPhi commented Nov 16, 2023 via email

@ElBart00
Copy link

I use my version @gaphi/node-red-contrib-tesla and do not have any problem for several years. I just had to add the location_data endpoint since recent Tesla update in my automation (my garage door still open automatically), without any change in this node-red-contrib-tesla code. Probably a good starting point for the update you want to provide 😊

I'm not able to install npm packages on my node red device. I've tried installing @gaphi/node-red-contrib-tesla via Node Red pallette but get the following error:

2023-11-18T14:51:41.362Z Install : @gaphi/node-red-contrib-tesla 1.0.6-0

2023-11-18T14:51:41.674Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict @gaphi/[email protected]
2023-11-18T14:51:51.990Z [err] npm WARN config production Use --omit=dev instead.
2023-11-18T14:52:14.476Z [err] npm
2023-11-18T14:52:14.478Z [err]
2023-11-18T14:52:14.479Z [err] ERR! code
2023-11-18T14:52:14.480Z [err] ETARGET
2023-11-18T14:52:14.508Z [err] npm
2023-11-18T14:52:14.509Z [err] ERR! notarget
2023-11-18T14:52:14.511Z [err] No matching version found for @gaphi/[email protected].
2023-11-18T14:52:14.514Z [err] npm ERR! notarget In most cases you or one of your dependencies are requesting
2023-11-18T14:52:14.514Z [err] npm
2023-11-18T14:52:14.517Z [err] ERR! notarget a package version that doesn't exist.
2023-11-18T14:52:14.540Z [err]
2023-11-18T14:52:14.540Z [err] npm ERR!
2023-11-18T14:52:14.543Z [err] A complete log of this run can be found in: /data/home/nodered/.npm/_logs/2023-11-18T14_51_50_637Z-debug-0.log
2023-11-18T14:52:14.593Z rc=1

@GaPhi could you please fix the version in the Node Red pallete?
@onokje it would be nice to merge the pull request of @GaPhi

@Lineflyer
Copy link
Author

Here are the command arguments I use...

Somehow I can't get it working.
Should it work to just feed the node-red-contrib-tesla with this custom parameters or do I need a newer version (e.g. from your fork)?

@GaPhi
Copy link
Contributor

GaPhi commented Nov 20, 2023 via email

@ElBart00
Copy link

The palette doesn't get the updated version. I've installed package version 2.0.1-9 using the tgz file.
I've configured the API key and I'm able to get a list of vehicles.
I can't get any other get command to work. (haven't tried a post) I keep getting the
error [error] [tesla-api:Get status] TypeError: Cannot read properties of undefined (reading '0')
I've modified my live tesla.js file with extra console.log statements and found the cause of the issue is in the wakeup method line 53. I've put the whole method in a try catch block and this is the error it produces:
TypeError: Cannot read properties of undefined (reading '0') @40000000655d094a02a95fa4 at /data/home/nodered/.node-red/node_modules/@gaphi/teslajs/teslajs.js:612:33 @40000000655d094a02a96f44 at Request._callback (/data/home/nodered/.node-red/node_modules/@gaphi/teslajs/teslajs.js:512:13) @40000000655d094a02a97ee4 at self.callback (/data/home/nodered/.node-red/node_modules/request/request.js:185:22) @40000000655d094a02a98e84 at Request.emit (node:events:517:28) @40000000655d094a02a99654 at Request.<anonymous> (/data/home/nodered/.node-red/node_modules/request/request.js:1154:10) @40000000655d094a02abbd1c at Request.emit (node:events:517:28) @40000000655d094a02abc8d4 at IncomingMessage.<anonymous> (/data/home/nodered/.node-red/node_modules/request/request.js:1076:12) @40000000655d094a02abdc5c at Object.onceWrapper (node:events:631:28) @40000000655d094a02abe42c at IncomingMessage.emit (node:events:529:35) @40000000655d094a02abefe4 at endReadableNT (node:internal/streams/readable:1368:12)

So it seems the cause is in the teslajs package. @GaPhi do you know what might cause this?

@GaPhi
Copy link
Contributor

GaPhi commented Nov 21, 2023 via email

@osvedman
Copy link

I have found a workaround that works for this node.

  1. Back-up /home/pi/.node-red/node_modules/teslajs/teslajs.js
  2. Edit teslajs.js Line 704:

From:
get_command(options, "vehicle_data", callback);

To:
get_command(options, "vehicle_data?endpoints=location_data%3Bcharge_state%3Bclimate_state%3Bclosures_state%3Bdrive_state%3Bgui_settings%3Bvehicle_config%3Bvehicle_state", callback);

  1. Restart Node-RED

@Lineflyer
Copy link
Author

Thanks @osvedman . Confirmed working for me!

@cycl0ne
Copy link

cycl0ne commented Dec 7, 2023

@GaPhi hi, just hijacking this thread. i installed your code into my nodered. and it works well, but only for the first car. i can select whatever i want.. it just takes my first car. any clue?

@GaPhi
Copy link
Contributor

GaPhi commented Dec 7, 2023

I only have one Tesla... but the code seems to support more : const vehicleID = msg.vehicleID ?? config.vehicleID;

Then, if you set msg.vehicleID (not in the payload), then another car should be selected I suppose, otherwise it is the one selected in the node configuration.

@cycl0ne
Copy link

cycl0ne commented Dec 7, 2023

hmm the pull down doesnt work for me.. allways my first car as output. Question, since im new to node.red since 4h ;-)
payload i use template and select in the pulldown: <msg.vehicleId>, this is what i give as text in template?
{"vehicleID":"1234567890"}

@Lineflyer
Copy link
Author

@cycl0ne
You can also follow the workaround posted by @osvedman to modify the tesla.js file. That for sure will work with multiple vehicles.

@cycl0ne
Copy link

cycl0ne commented Dec 7, 2023

@cycl0ne You can also follow the workaround posted by @osvedman to modify the tesla.js file. That for sure will work with multiple vehicles.

ah sorry the whole "multiple cars" wont work with me.. i just ask for the model: i allways get model 3, but my 2nd (wife) is a model y.
i was just hijacking this thread because of GaPhi has no issue tracker on his github repo and saw hes answering here.. ;-)

but since you all have no 2nd car... wont help me :( .. this is why i try to understand template and sending maybe the vehicleID per template to the node.

@cycl0ne
Copy link

cycl0ne commented Dec 8, 2023

i will open an own issue now.. i tried all kinds of stuff, but it allways falls back to the first car.

@venomako
Copy link

The attached file works perfectly. I have made the modification mentioned above and added the functionality to also send the latitude and longitude of the vehicle, as I was using it and needed it. Remember to rename the file to Teslajs.js Regards.
teslajs.txt

@ChutneyMary
Copy link

Hello @venomako. I've installed the node-red-contrib-tesla via the Palette Manager. Where do you find the Teslajs.js file to replace with the one you provided? I've installed Node-Red on a 'standard' Raspberry Pi image.
I've also read that you need to provide your own domain to work with the new Tesla authentication process. How does that link into the functionality of node-red-contrib-tesla? Sorry for the basic questions but I'm really missing having a functioning method to get Tesla vehicle data.

@Lineflyer
Copy link
Author

The attached file works perfectly. I have made the modification mentioned above and added the functionality to also send the latitude and longitude of the vehicle, as I was using it and needed it. Remember to rename the file to Teslajs.js Regards. teslajs.txt

What model of Tesla are you connecting to?
I am asking because AFAICS the API used by this node is deprecated and no longer working at least for Models 3 and Y. Are you maybe connecting to an older model X or S?

@Lineflyer
Copy link
Author

Hello @venomako. I've installed the node-red-contrib-tesla via the Palette Manager. Where do you find the Teslajs.js file to replace with the one you provided? I've installed Node-Red on a 'standard' Raspberry Pi image. I've also read that you need to provide your own domain to work with the new Tesla authentication process. How does that link into the functionality of node-red-contrib-tesla? Sorry for the basic questions but I'm really missing having a functioning method to get Tesla vehicle data.

IMHO it should not work, despite changes made by @venomako at least for the current models.
As you describe: You need to be an official listed partner with its domain to make use of the new API....a modified node should not help...

I deinstalled this node meanwhile and decided to use the service of Teslemetry.com, which provide the exact same data as with the old API via their partner-licensed API access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants