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.
I’ve been running Teslamate on a Raspberry Pi for about 6 months and absolutely love it. I find myself obsessively checking my car’s stats whenever I get home after a drive.

In the past month, I’ve been getting a “server not responding” fairly frequently when try to open the web page. This will often persist for a few minutes, but eventually if I hit refresh enough it will come back. Sometimes it will make me log back into Grafana. I’ve never had to reboot the Pi, or do anything more drastic than hitting refresh. And I have never seen it lose a bit of data, so I know it is constantly polling 24/7.

Anyone else ever seen this behavior? If so, is it anything I need to be concerned about? It’s more of an annoyance than anything.


When you talk about the web page are you talking about the teslamate home page? That's most likely a problem on your Pi or network.
What do the logs say?
 
Nope.

If the pi hasn't been rebooted in 6 months then I'd start there.
Following up to say that it appears my router was to blame. I noticed that another device on my 2.4 GHz network was also having problems, so I rebooted the router. The problem immediately disappeared after that and hasn’t been back in nearly a week. Phew! I was worried I might need to find another Raspberry Pi, which are not easy to come by these days.
 
Having upgraded to the latest version, I was trying to resolve the encryption warning.

However now every time the car wakes from sleep the main dashboard shows unavailable and all stats disappear.

Looking in the logs, I am getting this. Any ideas?

[36mteslamate_1 |[0m 2022-10-14 19:31:37.727 car_id=1 [info] Start / :eek:nline
[36mteslamate_1 |[0m 2022-10-14 19:31:37.755 [error] GenStateMachine :"1" terminating
[36mteslamate_1 |[0m ** (Ecto.ConstraintError) constraint error when attempting to insert struct:
[36mteslamate_1 |[0m
[36mteslamate_1 |[0m * positions_pkey (unique_constraint)
[36mteslamate_1 |[0m
[36mteslamate_1 |[0m If you would like to stop this constraint violation from raising an
[36mteslamate_1 |[0m exception and instead add it as an error to your changeset, please
[36mteslamate_1 |[0m call `unique_constraint/3` on your changeset with the constraint
[36mteslamate_1 |[0m `:name` as an option.
[36mteslamate_1 |[0m
[36mteslamate_1 |[0m The changeset defined the following constraints:
[36mteslamate_1 |[0m
[36mteslamate_1 |[0m * positions_drive_id_fkey (foreign_key_constraint)
[36mteslamate_1 |[0m * positions_car_id_fkey (foreign_key_constraint)
 
Here are the full DB log.

When I try to run the command from that link I get an error unfortunately.

CT@raspberrypi:~ $ SELECT nextval('positions_id_seq');
-bash: syntax error near unexpected token `('


CT@raspberrypi:~ $ SELECT nextval('positions_id_seq');
SELECT max(id) from positions;
-bash: syntax error near unexpected token `('
-bash: syntax error near unexpected token `('

1665856839514.png
 
Here are the full DB log.

When I try to run the command from that link I get an error unfortunately.

CT@raspberrypi:~ $ SELECT nextval('positions_id_seq');
-bash: syntax error near unexpected token `('


CT@raspberrypi:~ $ SELECT nextval('positions_id_seq');
SELECT max(id) from positions;
-bash: syntax error near unexpected token `('
-bash: syntax error near unexpected token `('

View attachment 864211
You need to run it from within the database. You can login to the database like this:
Code:
docker exec -it ct_database_1 psql -U teslamate -W teslamate
 
  • Helpful
Reactions: Godsense
You need to run it from within the database. You can login to the database like this:
Code:
docker exec -it ct_database_1 psql -U teslamate -W teslamate
Thanks for your help, think its sorted. It was related to corrupt data somewhere.

Looks like my backup got corrupt somehow. I restored an earlier one from my daily Cron backups and it picks up when the car in online now.
 
  • Like
Reactions: init6
Is it possible to get postcodes listed in drives information. I see it pulls place names from somewhere, postcodes would be super useful for business mileage tracking!
The postcode is stored in the addresses table, so it should be possible. I'll need to do some digging to see how to get that out. How are your DBA skills?

If you only go to a few places then a simpler alternative would be to set up Geofences with the postcode as the name.

Edit: It's actually not that difficult to add the postcode, but you need to be adept at changing dashboard panels.
 
Last edited:
Trying to manually close a drive that has not logged but get the following error:
View attachment 870622
I have checked permissions. Anything else I can check?

Edit: ran as sudo and worked, but the drive is still not logged.
You'll need to give us some more info if we are to help you. How did you determine what drive is missing? What command did you use to close the drive? Are you able to look at the drives table from the command line?
 
Last edited:
You'll need to give us some more info if we are to help you. How did you determine what drive is missing? What command did you use to close the drive? Are you able to look at the drives table from the command line?
Hi, I checked the drive id in the url for the latest drive and then added 1 assuming that would be the next id. I have done two more drives after which seem to be logged so will check their id’s. I used the command on the website to manually close the drive.I haven’t looked at the drives table as when I run the select command nothing shows so must be doing something wrong. I know sql but not from docker to Postgres. Thanks for helping.
 
Hi, I checked the drive id in the url for the latest drive and then added 1 assuming that would be the next id. I have done two more drives after which seem to be logged so will check their id’s. I used the command on the website to manually close the drive.I haven’t looked at the drives table as when I run the select command nothing shows so must be doing something wrong. I know sql but not from docker to Postgres. Thanks for helping.
You can add a table panel to any of the dashboards and put in SQL there. I do that quite often for quick queries and then just discard the panel.

I use this query to find unclosed drives:
Code:
select id, start_date from drives where end_date is null;

then use the id in the close drive script. I presume you don't get any errors when you run this? IIRC there's a typo in the command on the Teslamate site.
 
You can add a table panel to any of the dashboards and put in SQL there. I do that quite often for quick queries and then just discard the panel.

I use this query to find unclosed drives:
Code:
select id, start_date from drives where end_date is null;

then use the id in the close drive script. I presume you don't get any errors when you run this? IIRC there's a typo in the command on the Teslamate site.
Thanks. I just checked the id's and they are sequential. The drive from home to work yesterday is totally missing. The id before my drive to work is 64 and the id for my drive from work to home is 65 so the drive from home to work is totally missing.