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

Add endpoints parameter #3373

Closed
wants to merge 3 commits into from
Closed

Add endpoints parameter #3373

wants to merge 3 commits into from

Conversation

jsight
Copy link
Contributor

@jsight jsight commented Oct 20, 2023

No description provided.

@jsight
Copy link
Contributor Author

jsight commented Oct 20, 2023

This seems a little hacky to me, but it does work around the problem.

@maerco
Copy link

maerco commented Oct 27, 2023

I tested on my deploy and it fix also my model 3 recently updated to 2023.38.4

@brontide
Copy link

This solved data loss after installation of 2023.38.4 on my Model Y.

@finnysamuel
Copy link

Thanks for the patch.. It worked - MYLR 23.38.4

@viorelovidiu
Copy link

This seems a little hacky to me, but it does work around the problem.

Hi, sorry being numb but how do I deploy this patch? I do have a Synology NAS with docker container. Thank you!

@jsight jsight changed the title Added a separate retrieval of location data Add endpoints parameter Oct 29, 2023
@jsight
Copy link
Contributor Author

jsight commented Oct 29, 2023

Change has been pushed to docker here: https://hub.docker.com/repository/docker/jsightler/teslamate/general

Also updated to (hopefully) be backward compatible and less crashy. :)

@swiffer
Copy link
Contributor

swiffer commented Oct 30, 2023

@jsight query param with get instead of encoding the params yourself

See example usage here

https://github.com/elixir-tesla/tesla?tab=readme-ov-file#direct-usage

@blexter
Copy link

blexter commented Oct 30, 2023

@adriankumpf
I would really appreciate if this PR could be approved and merged into the official release. 🙏🙏🙏

@jsight
Copy link
Contributor Author

jsight commented Oct 30, 2023

@swiffer Good idea, thank you!

@marcbaier
Copy link

would be great if someone could announce it here when the update is available in the Teslamate:latest version. thanks so much !

@marcbaier
Copy link

Change has been pushed to docker here: https://hub.docker.com/repository/docker/jsightler/teslamate/general

Also updated to (hopefully) be backward compatible and less crashy. :)

If I would like to use this update / patch and install it on my docker installation on my synology nas, can I just install it in docker by selecting my current teslamate/latest container and then selecting "import" "add from URL" ?

@blexter
Copy link

blexter commented Nov 1, 2023

@jsight
Getting "Internal Server Error" regularly since updated to this fix.

@brontide
Copy link

brontide commented Nov 1, 2023

@blexter You don't indicate if you are seeing that error in the browser or the logs. This code change is tiny and should have zero impact on the front-end of Teslamate where you might see errors in the browser. If it's in the logs please post the complete error messages so that they can be reviewed.

@blexter
Copy link

blexter commented Nov 1, 2023

@blexter You don't indicate if you are seeing that error in the browser or the logs. This code change is tiny and should have zero impact on the front-end of Teslamate where you might see errors in the browser. If it's in the logs please post the complete error messages so that they can be reviewed.

Checked the logs, not 100% sure what's sensitive data, so I might removed "to much", tell me if so and I can somehow send missing info.

2023-11-01 09:02:12.741 [error] Task #PID<0.3967.0> started from TeslaMate.Vehicles terminating
** (KeyError) key :drive_state not found in: %TeslaApi.Error{
reason: :unknown,
message: "{"error": "Get \"http://localhost:7654/vehicle_data?slow_query_time=15&headers%5BX-Request-Timeout%5D=5&let_sleep=true&user_command=true\\\": EOF"}",
env: %Tesla.Env{
method: :get,
url: "https://owner-api.teslamotors.com/api/1/vehicles/1234567890/vehicle_data",
query: [],
headers: [
{"x-xss-protection", "1; mode=block"},
{"x-txid", "1234567890"},
{"content-type", "application/json; charset=utf-8"},
{"x-request-id", "1234567890"},
{"content-length", "219"},
{"x-envoy-upstream-service-time", "1336"},
{"date", "Wed, 01 Nov 2023 08:02:12 GMT"},
{"server", "envoy"},
{"x-frame-options", "DENY"},
{"x-content-type-options", "nosniff"},
{"strict-transport-security", "max-age=31536000; includeSubDomains"},
{"cache-control", "no-cache, no-store, private, s-max-age=0"}
],
body: %{
"error" => "{"error": "Get \"http://localhost:7654/vehicle_data?slow_query_time=15&headers%5BX-Request-Timeout%5D=5&let_sleep=true&user_command=true\\\": EOF"}",
"error_description" => "",
"response" => nil
},
status: 540,
opts: [
access_token: "abcdef1234567890"
],
module: TeslaApi,
client: %Tesla.Client{fun: nil, pre: [], post: [], adapter: nil}
}
}
(teslamate 1.28.0-dev) lib/tesla_api/vehicle.ex:59: TeslaApi.Vehicle.get_with_state/2
(teslamate 1.28.0-dev) lib/teslamate/api.ex:299: TeslaMate.Api.preload_vehicle/2
(elixir 1.15.6) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
(elixir 1.15.6) lib/task/supervised.ex:36: Task.Supervised.reply/4
Function: &:erlang.apply/2
Args: [#Function<2.69151209/1 in TeslaMate.Api.handle_result/3>, [%TeslaApi.Vehicle{id: 1234567890, vehicle_id: 1234567890, vin: "1234567890", tokens: ["1234567890", "1234567890"], state: "online", option_codes: [""], in_service: false, display_name: "Model S", color: nil, calendar_enabled: true, backseat_token: nil, backseat_token_updated_at: nil, api_version: 67, charge_state: nil, climate_state: nil, drive_state: nil, gui_settings: nil, vehicle_config: nil, vehicle_state: nil}]]
2023-11-01 09:02:18.157 [notice] Application teslamate exited: shutdown
Kernel pid terminated (application_controller) ("{application_terminated,teslamate,shutdown}")

Crash dump is being written to: erl_crash.dump...done

@DrMichael
Copy link
Collaborator

@adriankumpf Given, that without that PR teslamate is broken, we need this PR incorporated. If you don't have the time, your opinion in #3384 would be very much appreciated.
We don't probably jump to a forked teslamate.

@tpd-opitz
Copy link

How can I apply the change locally to my teslamate instance until the this PR is merged?
I thought of adding RUN directive to my dockerfile to apply the change using sed like suggested [here] (https://stackoverflow.com/a/27714071) but I cant find the file vehicle.ex within the container...

@sargue
Copy link

sargue commented Nov 8, 2023

How can I apply the change locally to my teslamate instance until the this PR is merged? I thought of adding RUN directive to my dockerfile to apply the change using sed like suggested [here] (https://stackoverflow.com/a/27714071) but I cant find the file vehicle.ex within the container...

Well, you have several options.

The simple one is to trust the patched docker image that the same author of this PR uploaded to Docker Hub.

Another option is to build yourself a patched image, which seems to be what you're trying.

NOTE: I haven't tried any of this myself, my car is still on a previous version. Be very careful, do a full backup before you change anything.

If you have access to the command line and docker, and you have git installed (or you can install it), you can just build a local image with the change, then change the docker-compose.yml to point, temporarily, to this new local image.

It should be something like this. You can do this on the same system you're running Teslamate. Make sure you don't have already a teslamate directory because the first command will create one.

git clone https://github.com/jsight/teslamate.git
cd teslamate
git reset --hard 8134150b247eec5a08572e62fdc4ebe6fda22f63
git clean -df
docker build . -t teslamate-patch

If all commands are successful, then you can just point your docker-compose.yml to your local patched image.

services:
  teslamate:
    image: teslamate-patch

Another option is to clone the official repository, then apply manually the change, then build the image in the same way. It should be the same.

@SebastianGode
Copy link

SebastianGode commented Nov 8, 2023

I guess once @adriankumpf gets his car updated to the 2023.38.x this PR will get merged.
So shouldn't take that much longer again although I personally would suggest Adrian to add a second trustworthy maintainer to the repo :)

@tpd-opitz
Copy link

tpd-opitz commented Nov 8, 2023

If all commands are successful, then you can just point your docker-compose.yml to your local patched image.

 services:
     teslamate:
         image: teslamate-patch

Is teslamate-patch just an identifier I need to use at both places, the docker build command and the docker-compose.yml or are there any constraints to the directories involved?

@sargue
Copy link

sargue commented Nov 9, 2023

Correct, it's just a tag, any string will do. As you point out, you just need to make sure it's the same on the docker build command and the docker-compose.yml.

There's no restriction on where you build or use the image, it's all a reference in the docker local repository. You can see that with docker image ls.

By the way, I've been told that grafana needs to be updated as well, as the current master branch of teslamate has some changes as well.

If someone tries it, please share the outcome here.

@tpd-opitz
Copy link

tpd-opitz commented Nov 9, 2023

I got it runnig:

$ docker-compose up -d
Creating network "teslamate_default" with the default driver
Creating teslamate_mosquitto_1 ... done
Creating teslamate_grafana_1   ... done
Creating teslamate_teslamate_1 ... done
Creating teslamate_database_1  ... done

$ docker ps
CONTAINER ID   IMAGE                      COMMAND                  CREATED          STATUS                   PORTS                                       NAMES
4d6aa4bdecf0   postgres:13                "docker-entrypoint.s…"   10 minutes ago   Up 10 minutes            5432/tcp                                    teslamate_database_1
4ae87db8d2a0   teslamate/grafana:latest   "/run.sh"                10 minutes ago   Up 10 minutes            0.0.0.0:3000->3000/tcp, :::3000->3000/tcp   teslamate_grafana_1

7c5632baf27d   teslamate-patch:latest     "tini -- /bin/sh /en…"   10 minutes ago   Up 10 minutes            0.0.0.0:4000->4000/tcp, :::4000->4000/tcp   teslamate_teslamate_1

8ff0a3268b98   eclipse-mosquitto:1.6      "/docker-entrypoint.…"   10 minutes ago   Up 10 minutes            0.0.0.0:1883->1883/tcp, :::1883->1883/tcp   teslamate_mosquitto_1
90a26f4c4145   buanet/iobroker            "/bin/bash -c /opt/s…"   22 months ago    Up 11 months (healthy)   0.0.0.0:8081->8081/tcp, :::8081->8081/tcp   iobroker

$ docker-compose logs -f  teslamate 
Attaching to teslamate_teslamate_1
...
teslamate_1  | 2023-11-09 22:27:18.957 [info] GET /
teslamate_1  | 2023-11-09 22:27:19.051 [info] Sent 200 in 93ms
teslamate_1  | 2023-11-09 22:35:49.847 car_id=1 [info] Start / :online
teslamate_1  | 2023-11-09 22:35:49.873 car_id=1 [info] Logged missing software update: 2023.38.6 c1f85ddb415f
teslamate_1  | 2023-11-09 22:35:49.988 car_id=1 [info] Connecting ...

And at least it updated the SoC and the firmware version (got update 2023.38.6 last night)
Bildschirmfoto_2023-11-09_22-45-37

@sargue
Copy link

sargue commented Nov 10, 2023

@tpd-opitz , remove the :latest from the image line on the docker-compose.yml. It's trying to pull the image from a remote repository, but there's no remote repository (the image is local).

@brianmay
Copy link
Collaborator

Big question is: Is this change permanent? Or is Tesla going to change in the future and break this yet again?

@jaymunro
Copy link

Is there some way to up the priority on this? TeslaMate is completely broken with the the new API from Tesla.

@nelsongraca
Copy link

any timeline to merge this?

@jsight
Copy link
Contributor Author

jsight commented Nov 11, 2023

@brianmay It is in the official API documentation. They could change it further, but I'd guess they will document any further changes as well.

@brianmay
Copy link
Collaborator

There is official API documentation? Where is this? Everything I have seen clearly says unofficial only.

@jsight
Copy link
Contributor Author

jsight commented Nov 12, 2023

@brianmay Official API docs: https://developer.tesla.com/docs/fleet-api#vehicle_data

It is listed as the "fleet API", but the ones that I've seen are the same ones that we are used to. The notes call out the specific changes in 2023.38+ as well.

@swiffer
Copy link
Contributor

swiffer commented Nov 12, 2023

Fact is that the current latest version 1.27.3 is broken and the fix discussed here is working well (and is documented change for the fleet API). Not having this or #3398 merged means broken Teslamate. There are more and more forks popping up

In addition there are efforts of coordinating a fork

It would be really great to avoid that, broden the admin and combine forces in making teslamate a better product - or at least try to coordinate forking.

@brianmay
Copy link
Collaborator

I have had to use my fork for some time, simply because I have not had any feedback on my pr #3087. This in turn reduces motivation to work on other issues that have been nagging me.

I can understand though that @adriankumpf may feel that he is unable to keep with with this project anymore. I have been in this situation myself on a number of occasions.

I think we are all very grateful for the time and effort that @adriankumpf and others have spent on this project to date.

Handing over the project is a big step too, can you really trust the new maintainer? I have heard some horror stories where this can go wrong. In at least one case the new maintainer inserted malicious code into a project he had just taken over. And plenty of times where I accidentally end up being the new maintainer, and I am already over committed.

The problem with creating a fork, is that 50 forks is not going to help. We need one fork that the entire community can get behind and support. Maybe one, like the above that isn't directly tied to one person, so that the responsible people can change with time too.

If we can agree on one fork to be the new official repo, we can then ask github to mark it as such. Then the annotations will change to make this project an fork of the new official fork, rather then vice verse.

@szinn
Copy link

szinn commented Nov 12, 2023

I can confirm this API works on 2023.27.7 as well. The vehicle_data_combo likely isn't needed since it appears to be an encoded blob and doesn't add anything new to the remainder of the request.

@Dulanic
Copy link
Collaborator

Dulanic commented Nov 13, 2023

With #3398 merged, this is is no longer needed correct?

@swiffer
Copy link
Contributor

swiffer commented Nov 13, 2023

@Dulanic - yes, can be closed

@DrMichael DrMichael closed this Nov 13, 2023
@Dulanic
Copy link
Collaborator

Dulanic commented Nov 13, 2023

I have had to use my fork for some time, simply because I have not had any feedback on my pr #3087. This in turn reduces motivation to work on other issues that have been nagging me.

I can understand though that @adriankumpf may feel that he is unable to keep with with this project anymore. I have been in this situation myself on a number of occasions.

I think we are all very grateful for the time and effort that @adriankumpf and others have spent on this project to date.

Handing over the project is a big step too, can you really trust the new maintainer? I have heard some horror stories where this can go wrong. In at least one case the new maintainer inserted malicious code into a project he had just taken over. And plenty of times where I accidentally end up being the new maintainer, and I am already over committed.

The problem with creating a fork, is that 50 forks is not going to help. We need one fork that the entire community can get behind and support. Maybe one, like the above that isn't directly tied to one person, so that the responsible people can change with time too.

If we can agree on one fork to be the new official repo, we can then ask github to mark it as such. Then the annotations will change to make this project an fork of the new official fork, rather then vice verse.

I dont disagree, there needs to be a head person responsible for all of it. Who that can be? I'm not sure at this point. But I think we are open to talking about it. There is a open discussion currently.

mattdoran added a commit to mattdoran/tesla that referenced this pull request Nov 14, 2023
A recent API change means the vehicle state no longer retrieves the location data by default.   This change fixes this.

See this change in TeslaMate - teslamate-org/teslamate#3373
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

Successfully merging this pull request may close these issues.