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.
Here we go - screenshot as requested. I'm going to turn the API on and off now...

Screenshot 2021-09-28 18.52.48.png
 
  • Like
Reactions: init6
So I have no experience with docker/grafana and can barely navigate github but managed to get Teslamate up and running on a intel NUC on my home network.

I'm interested in setting pages with fuel savings panels and things like carbon footprint. Has anyone done this? I saw Russinating shared a JSON for MPG on page 15 but I can't get it to work.
 
So I have no experience with docker/grafana and can barely navigate github but managed to get Teslamate up and running on a intel NUC on my home network.

I'm interested in setting pages with fuel savings panels and things like carbon footprint. Has anyone done this? I saw Russinating shared a JSON for MPG on page 15 but I can't get it to work.

+1, would definitely be interested in some dashboards if they can be shared
 
So I have no experience with docker/grafana and can barely navigate github but managed to get Teslamate up and running on a intel NUC on my home network.

I'm interested in setting pages with fuel savings panels and things like carbon footprint. Has anyone done this? I saw Russinating shared a JSON for MPG on page 15 but I can't get it to work.
In what way can you not get it working?

Are you not able to import the json into a dashboard?
Have you imported this and you get an error or no data?
What does the panel look like on your dashboard?
 
In what way can you not get it working?

Are you not able to import the json into a dashboard?
Have you imported this and you get an error or no data?
What does the panel look like on your dashboard?
So the only way I've found so far to import using the JSON is to go to create -> import -> import via panel json. I then plug in the below code. It creates a blank dashboard call MPG with no panels or data.

I think I may be doing it wrong because its importing as a dashboard but I think the code is just for a panel. If I try to add/edit a panel I don't see anyway to import it with the JSON.

{
"datasource": "TeslaMate",
"cacheTimeout": null,
"colorBackground": false,
"colorValue": false,
"colors": [
"#299c46",
"rgba(237, 129, 40, 0.89)",
"#d44a3a"
],
"decimals": 0,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"gridPos": {
"h": 3,
"w": 2,
"x": 8,
"y": 6
},
"id": 65,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "mpg",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false,
"ymax": null,
"ymin": null
},
"tableColumn": "",
"targets": [
{
"format": "time_series",
"group": [],
"hide": false,
"metricColumn": "none",
"rawQuery": true,
"rawSql": "select $__time(date), convert_km(odometer, '$length_unit') / ($chargecost/(104.8/100)*0.219969157) from positions where car_id = $car order by date desc limit 1;",
"refId": "A",
"select": [
[
{
"params": [
"value"
],
"type": "column"
}
]
],
"timeColumn": "time",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": "",
"timeFrom": null,
"timeShift": null,
"title": "MPG",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [],
"valueName": "first"
}
 
Maybe you're way past this, but to import a new dashboard you need to log into Grafana (as admin) which is bottom left and then you can import a new dashboard (click the + symbol thats now visible on the left and then import). Not tried it myself, I have just created custom dashboard.

There's a share dashboard option at the top of the screen.

What are you trying to see with the MPG dashboard as there's a trips dashboard with efficiency etc?
 
It's a panel. So you need to create a new dashboard or add a new panel to an existing dashboard. Probably easiest doing the latter as an existing dashboard will have some of the variables.

When you've added the panel, click on the panel title->Inspect->Panel JSON
Delete all of the existing JSON and then cut and paste the new panel JSON. Apply the changes.

Go to the dashboard settings (cog near top right) then Variables and add the variables:
Screenshot 2021-09-29 at 19.41.04.png


Although russinating mentions 1 variable, there are actually two that are required.

Also, and this might be because of an update to Teslamate since russinating panel was written, you have to make a slight change to the query. You may see an error about missing function or something. goto panel title->Edit
In the query there is a bit that says convert_km(odometer, '$length_unit')
Change this to convert_km(odometer::numeric, '$length_unit')

That's all I changed this morning to get the panel to work.
 
Maybe you're way past this, but to import a new dashboard you need to log into Grafana (as admin) which is bottom left and then you can import a new dashboard (click the + symbol thats now visible on the left and then import). Not tried it myself, I have just created custom dashboard.

There's a share dashboard option at the top of the screen.

What are you trying to see with the MPG dashboard as there's a trips dashboard with efficiency etc?
Russinating has saved a panel not a dashboard, so some of the variables will be missing from any new dashboard.

Re the MPG: its an imaginary MPG figure for a car that doesn't use petrol/diesel :) It's also based on a price of £1.04 per litre which is somewhat optimistic.
 
Maybe you're way past this, but to import a new dashboard you need to log into Grafana (as admin) which is bottom left and then you can import a new dashboard (click the + symbol thats now visible on the left and then import). Not tried it myself, I have just created custom dashboard.

There's a share dashboard option at the top of the screen.

What are you trying to see with the MPG dashboard as there's a trips dashboard with efficiency etc?
Yeah I've tried hitting the plus button and then clicking import and pasting in that code.

What I'm interested in is a dashboard where I can plug in avg price per gal in my area and put in a typical MPG for a similar size vehicle and then compare how much gas savings I've incurred by driving electric.
 
Yeah I've tried hitting the plus button and then clicking import and pasting in that code.

What I'm interested in is a dashboard where I can plug in avg price per gal in my area and put in a typical MPG for a similar size vehicle and then compare how much gas savings I've incurred by driving electric.
I've got one of them. Slightly different calculation in that I've worked out the cost per mile of a 'gas' car In my case it was costing me £0.13 per mile. I'm sure you can work that out, but if not I'll find my formula. I've plugged that into my query and I get the cost savings which are equal to:

(Odometer miles * gas cost per mile) - total charging cost.

I've also got a £ sign, but you can change it for whatever currency you want.

Next post will have the code
 
  • Like
Reactions: glidesi
I've got one of them. Slightly different calculation in that I've worked out the cost per mile of a 'gas' car In my case it was costing me £0.13 per mile. I'm sure you can work that out, but if not I'll find my formula. I've plugged that into my query and I get the cost savings which are equal to:

(Odometer miles * gas cost per mile) - total charging cost.

I've also got a £ sign, but you can change it for whatever currency you want.

Next post will have the code
Great thank you! Also I appreciate the max speed/power drives dashboard you post as well.
 
  • Like
Reactions: init6
Since 9/30 Teslamate drives and charges pages don't show sthe location. If I click to view details of the specific timestamp it will show location correctly. Anyone have this happen and know why? Example:
What version of Teslamate are you running? There was a new one out this week. Have you updated Grafana? IIRC version 8 isn't supported by Teslamate and has been known to cause issues with locations (although I think that was only on the maps)
 
Im trying to figure out how teslamate properly calculates my consumption, specifically total kwh and consumption (wh/km)
Im trying to follow the sql query for calculating "drives" for my car in grafana, it seems like it is mostly relying on EPA data, not actual data in the car, so I wonder how both correlate:

The total kwh is calculated based on efficiency, which is the official consumption that is reported for the car, multiplied by the rated range difference for a drive, which is based on the EPA estimation in the car. So the consumption reported is based on the range difference / battery percentage lost for a drive. How can it provide an actual number if the total size of the car battery is unknown?
Isnt it more accurate and "real" to rely on the car battery size than EPA metrics?
It provides difference compared to the data shown by the "trip" consumption in the car
 
Im trying to figure out how teslamate properly calculates my consumption, specifically total kwh and consumption (wh/km)
Im trying to follow the sql query for calculating "drives" for my car in grafana, it seems like it is mostly relying on EPA data, not actual data in the car, so I wonder how both correlate:

The total kwh is calculated based on efficiency, which is the official consumption that is reported for the car, multiplied by the rated range difference for a drive, which is based on the EPA estimation in the car. So the consumption reported is based on the range difference / battery percentage lost for a drive. How can it provide an actual number if the total size of the car battery is unknown?
Isnt it more accurate and "real" to rely on the car battery size than EPA metrics?
It provides difference compared to the data shown by the "trip" consumption in the car
I'm pretty sure that question has been asked over on the Teslamate Github page. Might be worth looking there as the developer is very responsive to questions. There is also discussions page.
 
I'd also look at the API documentation (also on github) if you really want to know to see what data is provided everytime you ask the car. From memory the car tells you how energy is in the battery so it could simply subtract that at the end from the beginning but of course these things are never that simple as the battery reports a bit more after its warmed up and when cooled down again loses some.
 
  • Like
Reactions: init6