Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

TeslaMate [megathread]

This site may earn commission on affiliate links.
Sorry init6, how do I do that? Complete numpty when it comes to this.
I am running TM on free GC.
from the command line on your server:

docker exec -it teslamate_database_1 psql -U teslamate

It'll ask for your db password

then:
SELECT * FROM drives ORDER BY start_date desc;

That should give you a list of all your drives. Check that your new ones are showing up. If not share the output.
 
Just for completeness. OP had a lot of unclosed drives - possibly due to poor connectivity. We upped the database_timeout setting and that seems to have stopped the drives from being left unclosed and also allowed the close_drives script to plonk (albeit slowly) through the missing drives.
 
Just for completeness. OP had a lot of unclosed drives - possibly due to poor connectivity. We upped the database_timeout setting and that seems to have stopped the drives from being left unclosed and also allowed the close_drives script to plonk (albeit slowly) through the missing drives.
Is this close_drives script in Teslamate?

i got loads of inclosed drives as my connection drops when I arrive home in the underground parking garage
 
Is this close_drives script in Teslamate?

i got loads of inclosed drives as my connection drops when I arrive home in the underground parking garage
Yes and no.

There's a script to close one drive on Teslamate GitHub. I just cobbled something together to search for open drives and run that script against the IDs.

You might want to increase your timeout too. IIRC we change it to 4 minutes. Might help with your problem.
 
I've had a few occasions recently where teslamate requires tokens to be entered again. I'm not sure what causes this, but I tend to only notice when my home assistant automation to open the garage door doesn't work. The info for this is provided by MQTT from teslamate.

Is it possible for teslamate to provide API auth status over MQTT so that I could have home assistant notify me as soon as it's not working?

As an aside, any idea why I'm getting logged out sometimes?
 
On a slightly different teslamate related topic to it not working. does anyone know how some of the metrics are worked out.

I was looking at efficiency screen and it has the current rated efficiency and a series of derived ideal effiociencies which are more or less the same. I can't see in any of the API data where efficiency is actually provided, so is the "rated efficiency" the best fit of the "derived ideal efficiencies" or something else? The reason why I ask is I still have data for my old M3 in there, and itis showing that has a worse ideal efficiency than my MY which might be true, but would surprise me it if was (both are LR models on srd wheels).

I'm just trying to work out what I'm actually looking at, whether its EPA, WLTP, or just another metric based on how many miles are being added to the battery when I charge and add so many kwh which is how I've seen the efficiency being calculated elsewhere.

On a similar basis I'm trying to understand the "Net" v "Gross" efficiency figures on the overview screen and how they're calculated (I don't mean "with and without heating", more what data points are provided by the car to calculate them, unless those figures are provided by the car)
 
On a slightly different teslamate related topic to it not working. does anyone know how some of the metrics are worked out.

I was looking at efficiency screen and it has the current rated efficiency and a series of derived ideal effiociencies which are more or less the same. I can't see in any of the API data where efficiency is actually provided, so is the "rated efficiency" the best fit of the "derived ideal efficiencies" or something else? The reason why I ask is I still have data for my old M3 in there, and itis showing that has a worse ideal efficiency than my MY which might be true, but would surprise me it if was (both are LR models on srd wheels).

The efficiency figure is calculated at each charge:
Each charging session will trigger a recalculation of the efficiency, which is applied retroactively to all data. In other words, the longer you use TeslaMate, the more accurate the efficiency value will become.
Edit Pressed return too soon. Hold on for an answer for part 2.
 
  • Informative
Reactions: GeorgeSymonds
On a similar basis I'm trying to understand the "Net" v "Gross" efficiency figures on the overview screen and how they're calculated (I don't mean "with and without heating", more what data points are provided by the car to calculate them, unless those figures are provided by the car)
Net is calculated from (start_range - end_range)*efficiency for each drive >=0.1km
Gross is calculated from ( loss in range from the previous charging session * efficiency)/(distance travelled between charging sessions)
 
  • Informative
Reactions: GeorgeSymonds
What do the logs say?
It was logged out again this morning when I checked.

logs look like a lot of this:

Code:
teslamate_1  | 2023-03-01 20:09:35.241 [warning] Retrying in 5 minutes...
teslamate_1  | 2023-03-01 20:10:00.403 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/<snip> -> 401 (194.778 ms)
teslamate_1  | 2023-03-01 20:10:00.404 [info] Refreshing access token ...
teslamate_1  | 2023-03-01 20:10:00.405 car_id=1 [error] Error / :unauthorized
teslamate_1  | 2023-03-01 20:10:05.436 [error] POST https://auth.tesla.com/oauth2/v3/token -> error: "timeout" (5030.454 ms)
teslamate_1  | 2023-03-01 20:10:05.437 [warning] Token refresh failed: %TeslaApi.Error{env: nil, message: "timeout", reason: :token_refresh}
teslamate_1  | 2023-03-01 20:10:05.437 [warning] Retrying in 5 minutes...
teslamate_1  | 2023-03-01 20:10:30.896 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/<snip> -> 401 (488.077 ms)
teslamate_1  | 2023-03-01 20:10:30.897 [info] Refreshing access token ...
teslamate_1  | 2023-03-01 20:10:30.897 car_id=1 [error] Error / :unauthorized
teslamate_1  | 2023-03-01 20:10:35.923 [error] POST https://auth.tesla.com/oauth2/v3/token -> error: "timeout" (5024.283 ms)
teslamate_1  | 2023-03-01 20:10:35.923 [warning] Token refresh failed: %TeslaApi.Error{env: nil, message: "timeout", reason: :token_refresh}
teslamate_1  | 2023-03-01 20:10:35.923 [warning] Retrying in 5 minutes...
teslamate_1  | 2023-03-01 20:11:01.249 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/<snip> -> 401 (348.356 ms)
teslamate_1  | 2023-03-01 20:11:01.251 car_id=1 [error] Error / not_signed_in
teslamate_1  | 2023-03-01 20:11:25.992 [notice]     :alarm_handler: {:set, {:"Elixir.TeslaMate.Api.unauthorized", :fuse_blown}}
teslamate_1  | 2023-03-01 20:11:25.993 [notice]     :alarm_handler: {:set, {TeslaMate.Vehicles.Vehicle_1_api_error, :fuse_blown}}
teslamate_1  | 2023-03-01 20:13:21.019 [info] GET /
teslamate_1  | 2023-03-01 20:13:21.078 [info] Sent 302 in 59ms
teslamate_1  | 2023-03-01 20:13:21.087 [info] GET /sign_in
teslamate_1  | 2023-03-01 20:13:21.117 [info] Sent 200 in 29ms

Bit odd, it has been working without intervention for quite a while and I've made no config changes.

I added my tokens again (exact same)

Code:
teslamate_1  | 2023-03-01 20:15:35.924 [warning] Cannot refresh access token: :not_signed_in
teslamate_1  | 2023-03-01 20:22:46.404 [info] GET /
teslamate_1  | 2023-03-01 20:22:46.433 [info] Sent 302 in 28ms
teslamate_1  | 2023-03-01 20:22:46.466 [info] GET /sign_in
teslamate_1  | 2023-03-01 20:22:46.526 [info] Sent 200 in 60ms
teslamate_1  | 2023-03-01 20:23:18.371 [info] POST https://auth.tesla.com/oauth2/v3/token -> 200 (614.431 ms)
teslamate_1  | 2023-03-01 20:23:18.384 [info] Scheduling token refresh in 6 h
teslamate_1  | 2023-03-01 20:23:18.713 [info] GET /
teslamate_1  | 2023-03-01 20:23:19.035 [info] Starting logger for 'Dave'
teslamate_1  | 2023-03-01 20:23:19.052 [info] Sent 200 in 338ms
teslamate_1  | 2023-03-01 20:23:19.373 car_id=1 [info] Start / :asleep
 
It was logged out again this morning when I checked.

logs look like a lot of this:

Code:
teslamate_1  | 2023-03-01 20:09:35.241 [warning] Retrying in 5 minutes...
teslamate_1  | 2023-03-01 20:10:00.403 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/<snip> -> 401 (194.778 ms)
teslamate_1  | 2023-03-01 20:10:00.404 [info] Refreshing access token ...
teslamate_1  | 2023-03-01 20:10:00.405 car_id=1 [error] Error / :unauthorized
teslamate_1  | 2023-03-01 20:10:05.436 [error] POST https://auth.tesla.com/oauth2/v3/token -> error: "timeout" (5030.454 ms)
teslamate_1  | 2023-03-01 20:10:05.437 [warning] Token refresh failed: %TeslaApi.Error{env: nil, message: "timeout", reason: :token_refresh}
teslamate_1  | 2023-03-01 20:10:05.437 [warning] Retrying in 5 minutes...

[/QUOTE]
Anything changed on your [URL='https://github.com/adriankumpf/teslamate/issues/2726']network[/URL]?

ISTR seeing this fixed with a router reboot.