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.
If anyone wants to add an overall MPG panel use the JSON code below:

Code:
{
  "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"
}

You'll also need the $chargecost variable in your dashboard settings which is simply SELECT sum(cost) FROM charging_processes WHERE car_id = $car;

Only other "variable" is the 104.8 in the SQL formula which is fuel costs. Currently based on supermarket petrol from Compare latest petrol and diesel fuel prices | The AA

At the moment even at that cheapest fuel price my MPG is 7,070 lol :eek:.

eYHeIpg.png
 
64p charge cost for 1000 miles is impressive.
I'm sitting on £18.24 at 11k miles thanks to my employers free charging, but I'm going to run out of supercharger miles soon :(

Yeah it was at £3.50 odd before weekend just gone, but did 160 miles and managed to recharge from empty to full both before and after on minus figures. I've only used Superchargers twice for a total of 75 miles mind (out of my free 1000); lockdown has helped both with selective journeys and cheaper electricity.
 
Thought I'd try and make a quick status dashboard with an image background. Man, what a pain!

Faffing around installing plugins, that then only accept data in time series, rather than table format (which is what most of the data we'd want to use on it is).

All I've managed so far is a status 'Orb' (otherwise it only shows 4 for asleep etc..) and battery % - I'll see if I can find some more time tomorrow. Probably not going to be as useful as I'd hoped to be honest.

snapshot dash.png
 
I think it's when the car considers it cold outside and will have an impact on performance, same as you see inside the car on those days. I think latest update makes it clearer.
It's been about 32c here so definitely not cold out.

I decided to check the YAML settings for that dashboard, this is what I found in the SQL query:

Code:
    start_position.usable_battery_level as start_usable_battery_level,
    start_position.battery_level as start_battery_level,
    end_position.usable_battery_level as end_usable_battery_level,
    end_position.battery_level as end_battery_level,
    start_position.battery_level != start_position.usable_battery_level OR end_position.battery_level != end_position.usable_battery_level  as reduced_range,

I'm not really sure how the battery level & usable battery level could differ when the ambient temperature's pretty warm.
 
Has anyone successfully set up the Tesla Mate Agile project referenced above? MattJeanes/TeslaMateAgile

I am getting stuck and wondering if I could get a second pair of eyes. I have the container pulled. I created a variables.env file with the values listed on the Github Page (with X being real numbers) that contains the following:

-ConnectionStrings__TeslaMate: 'Server=192.168.1.X;Port=XXXX;Database=teslamate;User Id=teslamate;Password=teslamate;'
-TeslaMate__UpdateIntervalSeconds: '300'
-TeslaMate__GeofenceId: '1'
-TeslaMate__Phases: '1'
-Octopus__RegionCode: 'J'

However, every time I run:
docker run --env-file /home/pi/TeslaMateAgile/variables.env mattjeanes/teslamateagile

I get the following error:
docker: poorly formatted environment: variable '-ConnectionStrings__TeslaMate: 'Server' contains whitespaces.
See 'docker run --help'.

I can't for the life of me see what's wrong here. Has anyone gotten this up and running via Docker successfully that could spot the error of my ways?
 
Tried to install Docker and Teslamate on my rPi4 the other day. However I upon rebooting I ended up stuck in a loop on the graphical Raspbian login page would wouldn't let me past. I think there is an .Xauthority issue but I haven't been able to fix it yet. To be fair I don't think it is Teslamate's fault. I first had it when installing HomeAssistant, then managed to fix it. Thankfully I've got a backup SD card and I might just go back to that and try again.
 
Well it looks like I wasn't formatting the variables properly for Docket. I've updated to:

ConnectionStrings__TeslaMate=Server=127.0.0.1;Port=5432;Database=teslamate;User Id=teslamate;Password=teslamate;
TeslaMate__UpdateIntervalSeconds=300
TeslaMate__GeofenceId=1
TeslaMate__Phases=1
Octopus__RegionCode=J

And it's reading them and starting the service correctly however now I'm getting

fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]

An error occurred using the connection to database 'teslamate' on server 'tcp://127.0.0.1:5432'.

fail: Microsoft.EntityFrameworkCore.Query[10100]

An exception occurred while iterating over the results of a query for context type 'TeslaMateAgile.Data.TeslaMate.TeslaMateDbContext'.

System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.

---> Npgsql.NpgsqlException (0x80004005): Exception while connecting

---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (111): Connection refused 127.0.0.1:5432

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)

at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)

at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__274_0(IAsyncResult iar)

--- End of stack trace from previous location where exception was thrown ---
 
And to confirm, the PostGres service is listening on the correct port from the config.

Hey! DaveW pointed me here from Facebook, glad to see people taking interest :)

The IP address is most likely wrong here, if you're using the default docker-compose.yml from the TeslaMate documentation you should be able to use the name of the postgres container as a hostname so replace the Server=127.0.0.1 with Server=database (literally the word database, that's the name of the container as defined in Docker install | TeslaMate)

Hopefully that fixes it!