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.
Mine lasted a few days without warnings, just checked now and have one.
That's a shame - was hoping mine had just been complaining due to the initial setup stuff. Annoyingly you don't seem to be able to monitor actual memory usage on the instances unless you install the cloud monitor agent, which itself uses some resources - which is the last thing you want when it is running so close to the max. If only they extended the always free offer to the e2-micro machine types too!
 
I'm a bit time limited but have taken a look at what the absolute minimum is to achieve this. You might have also seen I posted a picture of the TeslaMate schema earlier in this thread. I've tried this on a test database and taken screenshots so you can see what you do and don't get. Depends on how much your OCD on charge data is nagging you!

The good news is that a charging_processes table record has no outward dependency on records in the charges table, the latter has to refer to a parent charging_processes record but not vica versa.

If all you want is the Charging Stats dashboard to have the right numbers for Total Cost, Total Number of Charges and Total kWh added then you can achieve that with manually inserting a single record for each missing charge session. This will make the Charging Stats dashboard totals reflect your manually added charge(s), no entries will be shown in the Charges dashboard though. The Charges dashboard entry is possible but will need more work on your side.

WARNING: make sure you take a backup of your database before you try any of this just in case you need to revert back. No warranty given or implied :D so do at your own risk.

Example of faked charging session for the following desired values:
29th June 2020, 23:00 - 23:30, 30 mins duration (SQL statement below inserts time/date in UTC so 1 hour offset to BST)
Charge added = 2.75kWh
Cost = 0.12
Assumes
only a single car in TeslaMate (car_id = 1)
Assumes charge is linked to first position ever logged in TeslaMate (position_id = 1), you can set this to a different value if you find the id of your desired position in the database but haven't described that here.
Only populates values in the table that cannot be left null as per the database design plus those values needed to get your charge costs correct.

Code:
INSERT INTO public.charging_processes(
 id,
 start_date,
 end_date,
 charge_energy_added,
 duration_min,
 car_id,
 position_id,
 cost
)
VALUES(
 nextval('public.charging_processes_id_seq'),
 TIMESTAMP '2020-06-29 22:00:00',
 TIMESTAMP '2020-06-29 22:30:00',
 2.75,
 30,
 1,
 1,
 0.12
);

Before view of Charging Stats dashboard
View attachment 560364

View attachment 560365


After view of Charging Stats dashboard with changes highlighted in red
1 charge session added
30 minutes added to total duration
Total charged kWh increased, TeslaMate always rounds to whole kWh value
Total charging cost increased
View attachment 560366

Faked charging session defaulting to a DC based charge.
No named location based on using position_id = 1 in my example database.
As we've not created any corresponding charge data stream records in the public.charges table there is no SOC data shown.
You won't be able to drill into the faked charging session, it only appears on the Charging Stats dashboard and contributes to maintaining your total number of charges, kWh, duration and costs.
View attachment 560367

Really appreciate the time taken to post this. I shall let you know how I get on.
 
  • Like
Reactions: NickName
You could also add the geo-fence column into that INSERT and supply the I’d of your home geo-fence, for example, if it was a home charge that’s missing.

It’s a supercharger that was missing but I have geofenced all superchargers so presumably it will have a geo-fence ID.

Sorry one very basic query - what command do I have to run to get to the position to use the “Insert” command you suggested above? Apologies I’m coming at this quite green.

Thanks again.
 
It’s a supercharger that was missing but I have geofenced all superchargers so presumably it will have a geo-fence ID.

Sorry one very basic query - what command do I have to run to get to the position to use the “Insert” command you suggested above? Apologies I’m coming at this quite green.

Thanks again.

You need to get to the DB, if you followed the inserting supercharger guide, you can use the first bit of that :)
 
That's a shame - was hoping mine had just been complaining due to the initial setup stuff. Annoyingly you don't seem to be able to monitor actual memory usage on the instances unless you install the cloud monitor agent, which itself uses some resources - which is the last thing you want when it is running so close to the max. If only they extended the always free offer to the e2-micro machine types too!

It's still only a recommendation at this stage, couldn't find any data to show where it had been an issue, I'm sure on my Pi when it ran both TM and Homebridge I had 1.4gb out of 2gb memory free. Since removing TM from running it's now got 1.6gb. So it might just be very close to the 600mb used.

Like you say, the metrics tell you nothing about memory, so no idea really, CPU barely does anything
 
That's a shame - was hoping mine had just been complaining due to the initial setup stuff. Annoyingly you don't seem to be able to monitor actual memory usage on the instances unless you install the cloud monitor agent, which itself uses some resources - which is the last thing you want when it is running so close to the max. If only they extended the always free offer to the e2-micro machine types too!
Yup, the monitoring uses 200 odd Mb of memory I believe so you can’t practically add that to F1-micro too.

I got the same message a while ago so bumped it up to F1-small. Costs £10 a month and nothing while you have your free $300 credit. I’ve just locked the can down the road until April 2021.

No idea what happens if you carry on leaving it on F1-micro with that warning...
 
Well I'll uninstall the monitor and switch back to the f1-micro for a bit and see what happens too.

As an aside I'm moving from Octopus Go to Octopus Agile as of midnight tonight so I've added Matt Jeanes' bit to the docker-compose.yml file for when I restart it - hopefully with the appropriate bits! Do I need to remove the current cost I have in the geofence in order for it to work do you know @Durzel ? I only want it to be triggering for charges at home from midnight tonight.
 
Well I'll uninstall the monitor and switch back to the f1-micro for a bit and see what happens too.

As an aside I'm moving from Octopus Go to Octopus Agile as of midnight tonight so I've added Matt Jeanes' bit to the docker-compose.yml file for when I restart it - hopefully with the appropriate bits! Do I need to remove the current cost I have in the geofence in order for it to work do you know @Durzel ? I only want it to be triggering for charges at home from midnight tonight.

You should be fine if some of your completed charges already have costs associated with them. If you have a default cost for that geo-fence then just remove it I think.

It just looks for completed charges associated with the geo-fence ID you specify that don't already have a cost set. So it should just work for all charges going forward if your existing charges already have a cost. Describes the behaviour in the comments on this part of the GitHub repo.
 
mine has the message now. not installed a monitor just pure Teslamate, im going to leave it as is and see what happens

error.JPG
 
  • Like
Reactions: DaveW
Excellent work that has been done in this thread. Thank you for all the pioneering and sharing your hard work. Using this thread last night I managed to install Teslamate within one hour and then migrate all data from my RaspberryPi at home to Teslamate in Google Cloud.
I added the Google Cloud Console ios app for monitoring my-fs1-micro.
 
  • Like
Reactions: DaveW
Well I have managed to get the teslamateagile stuff up and running - at least it seems to have worked out the costs ok for the first agile charge last night at least according to my attempts towork out would it would be on excel.

Only says to consider it.. mine still works absolutely fine so far, just as responsive as it was on the Pi.

Unfortunately I now seem to be stuck on e2-micro as if i try to change back to the f1-micro now then something in the setup doesn't work and grafana can't access the database. Teslamate itself seems to work (it shows the current state of the car at least) but going into grafana I get no details. As soon as I shut it down and change back to an e2-micro everything works ok again!

Think I'll just leave it as is for the time being and confirm what the ongoing cost would be after a month on the e2-micro when I get my invoice from GCP to tell me what tiny amount of my credit I've used up. In a month or two I may try setting everything up again from scratch on an f1-micro and use a backup/restore to migrate my current teslamate data over but I think I'll just leave things be for the moment seem I do have everything running as I want on the e2-micro without any warnings.
 
  • Like
Reactions: davidmc
Reading (translating) the thread that @BMW740iL - some of the instructions provided there include setting up a 1gb swap file, which thinking about it could well help with the memory exhaustion warnings we are getting.

I'll have a go and reboot the box to see if that improves things
 
  • Like
Reactions: davidmc
I'm a bit time limited but have taken a look at what the absolute minimum is to achieve this. You might have also seen I posted a picture of the TeslaMate schema earlier in this thread. I've tried this on a test database and taken screenshots so you can see what you do and don't get. Depends on how much your OCD on charge data is nagging you!

The good news is that a charging_processes table record has no outward dependency on records in the charges table, the latter has to refer to a parent charging_processes record but not vica versa.

If all you want is the Charging Stats dashboard to have the right numbers for Total Cost, Total Number of Charges and Total kWh added then you can achieve that with manually inserting a single record for each missing charge session. This will make the Charging Stats dashboard totals reflect your manually added charge(s), no entries will be shown in the Charges dashboard though. The Charges dashboard entry is possible but will need more work on your side.

WARNING: make sure you take a backup of your database before you try any of this just in case you need to revert back. No warranty given or implied :D so do at your own risk.

Example of faked charging session for the following desired values:
29th June 2020, 23:00 - 23:30, 30 mins duration (SQL statement below inserts time/date in UTC so 1 hour offset to BST)
Charge added = 2.75kWh
Cost = 0.12
Assumes
only a single car in TeslaMate (car_id = 1)
Assumes charge is linked to first position ever logged in TeslaMate (position_id = 1), you can set this to a different value if you find the id of your desired position in the database but haven't described that here.
Only populates values in the table that cannot be left null as per the database design plus those values needed to get your charge costs correct.

Code:
INSERT INTO public.charging_processes(
 id,
 start_date,
 end_date,
 charge_energy_added,
 duration_min,
 car_id,
 position_id,
 cost
)
VALUES(
 nextval('public.charging_processes_id_seq'),
 TIMESTAMP '2020-06-29 22:00:00',
 TIMESTAMP '2020-06-29 22:30:00',
 2.75,
 30,
 1,
 1,
 0.12
);

Before view of Charging Stats dashboard
View attachment 560364

View attachment 560365


After view of Charging Stats dashboard with changes highlighted in red
1 charge session added
30 minutes added to total duration
Total charged kWh increased, TeslaMate always rounds to whole kWh value
Total charging cost increased
View attachment 560366

Faked charging session defaulting to a DC based charge.
No named location based on using position_id = 1 in my example database.
As we've not created any corresponding charge data stream records in the public.charges table there is no SOC data shown.
You won't be able to drill into the faked charging session, it only appears on the Charging Stats dashboard and contributes to maintaining your total number of charges, kWh, duration and costs.
View attachment 560367

Thanks again for this. Finally had a chance to start putting it together.

Apologies for another basic question. The only outstanding item I have is the position ID.

You mentioned the following:

Assumes charge is linked to first position ever logged in TeslaMate (position_id = 1), you can set this to a different value if you find the id of your desired position in the database but haven't described that here.

My query is how to find the position ID. It is the same location as most of my other charges (South Mimms), but I can't quite see how to find the position ID. I've looked in the JSON tables within Grafana and within the URLs.

If it is easier to go down this route, it is also one of my saved geo-fences.

Much appreciated as always!
 
Thanks again for this. Finally had a chance to start putting it together.

Apologies for another basic question. The only outstanding item I have is the position ID.

You mentioned the following:

Assumes charge is linked to first position ever logged in TeslaMate (position_id = 1), you can set this to a different value if you find the id of your desired position in the database but haven't described that here.

My query is how to find the position ID. It is the same location as most of my other charges (South Mimms), but I can't quite see how to find the position ID. I've looked in the JSON tables within Grafana and within the URLs.

If it is easier to go down this route, it is also one of my saved geo-fences.

Much appreciated as always!

Questions are fine, I know some of my descriptions might be shorthand. :)

So based on what you've said, find an existing charge you have for the location you want in the Charges dashboard, then click through to the relevant Charge Details dashboard for that charge.

In the URL shown in the browser you’ll then see the ID for the charging process shown at the end of the URL, ‘4’ in the example below. Make a note of your relevant charging_process_id.

http://127.0.0.1:3000/d/BHhxFeZRz/charge-details?orgId=1&from=1591759802000&to=1591761621000&var-car_id=1&var-charging_process_id=4

Go to your database, and then execute the command below, replacing ‘4’ with the charging_process_id you noted above.

Code:
SELECT position_id FROM public.charging_processes WHERE id = 4;

This will return something like this:
Code:
 position_id
-------------
          37
(1 row)

You can then use this position_id value, ’37’ in my example as the position_id in the INSERT statement I gave you.

Note that this is a slight short-cut, doing this will just associate your new charge with a position record which already exists for the same physical location but at a different point in time. Otherwise we’d have to find the position record that existed for where you car was at the date/time you charged BUT I guess that doesn’t exist as otherwise you wouldn’t need to add the charge manually in the first place ;)

The position_id only really seems to be used on the Charge Details dashboard, as it used to show the charging location on the local area map panel. For your faked charge session you won’t have the detailed charging data for the Charge Details to be viewable anyway for the faked session.

I think if you set position_id to the value you look up and also set the geofence_id (think you said you can find that already?) to match your supercharger location then you’ll get something sensible regarding the location summaries on the Charging Stats dashboard.

A revised example of the INSERT statement I gave you originally but with the geofence_id added will look like this:
Code:
INSERT INTO public.charging_processes(
 id,
 start_date,
 end_date,
 charge_energy_added,
 duration_min,
 car_id,
 position_id,
 geofence_id,
 cost
)
VALUES(
 nextval('public.charging_processes_id_seq'),
 TIMESTAMP '2020-06-29 22:00:00',
 TIMESTAMP '2020-06-29 22:30:00',
 2.75,
 30,
 1,
 37,
 1,
 0.12
);
 
  • Like
Reactions: hingus2000