GithubHelp home page GithubHelp logo

teslamate-org / teslamate Goto Github PK

View Code? Open in Web Editor NEW
5.2K 132.0 661.0 42.9 MB

A self-hosted data logger for your Tesla 🚘

Home Page: https://docs.teslamate.org

License: MIT License

Elixir 89.04% CSS 0.18% JavaScript 1.77% HTML 6.14% Dockerfile 0.36% Makefile 0.07% Shell 0.34% SCSS 0.57% MDX 0.93% Nix 0.60%
tesla tesla-api elixir-lang grafana mqtt self-hosted phoenix-liveview openstreetmap srtm home-automation

teslamate's Introduction

TeslaMate

CI Publish Docker images

A powerful, self-hosted data logger for your Tesla.

  • Written in Elixir
  • Data is stored in a Postgres database
  • Visualization and data analysis with Grafana
  • Vehicle data is published to a local MQTT Broker

Documentation

The documentation is available at docs.teslamate.org.

Features

Dashboards

General

  • High precision drive data recording
  • No additional vampire drain: the car will fall asleep as soon as possible
  • Automatic address lookup
  • Easy integration into Home Assistant (via MQTT)
  • Easy integration into Node-Red & Telegram (via MQTT)
  • Geo-fencing feature to create custom locations
  • Supports multiple vehicles per Tesla Account
  • Charge cost tracking
  • Import from TeslaFi and tesla-apiscraper

Screenshots

Drive Details Web Interface

MORE SCREENSHOTS

Credits

teslamate's People

Contributors

adriankumpf avatar ayonix avatar brianmay avatar carloscuezva avatar ctraber avatar cwanja avatar dependabot-preview[bot] avatar dependabot[bot] avatar drmichael avatar dulanic avatar fatbasstard avatar gundalow avatar jakoblichterfeld avatar jheredianet avatar jlestel avatar mvaal avatar ngardiner avatar niek avatar nirkli avatar occultsound avatar oivindoh avatar pmboothby avatar roadrash2108 avatar spacecosmos avatar swiffer avatar tobiasehlert avatar toms3210 avatar tonia avatar tuxbox avatar virtualm2000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

teslamate's Issues

1.62-docker-compose up error and Range Difference

Anybody have any idea how to rectify this issue? This started with the 1.62. I did not have this issue with 1.60 when I used "docker-compose pull". I can access the Teslamate web interface at port 4000. Grafana appears to be working as well, so its not clear what the error is impacting. It's also identifying my vehicle as a Model 3 - even though it is a Model S. Is it possible this is affecting how my range is being reported? Teslamate reported range does not match the range reported in my car or the Tesla app.

Thanks in advance.

teslamate_1 | 21:56:04.047 [info] Already up
teslamate_1 | 21:56:14.091 [info] Running TeslaMateWeb.Endpoint with cowboy 2.6.3 at :::4000 (http)
teslamate_1 | 21:56:14.101 [info] Access TeslaMateWeb.Endpoint at http://192.168.86.22
teslamate_1 | 21:56:14.368 [info] Found Model 3: 'J's Model S'
mosquitto_1 | 1566878174: New connection from 172.19.0.2 on port 1883.
mosquitto_1 | 1566878174: New client connected from 172.19.0.2 as TESLAMATE_302E3937313 (p2, c1, k60).
teslamate_1 | 21:56:14.424 [info] Initializing handler
teslamate_1 | 21:56:14.425 [info] Connection has been established
teslamate_1 | 21:56:15.244 [error] Mounting lv:phx-YAnm40fq failed while verifying session with: :invalid
teslamate_1 | 21:56:15.764 car_id=1 [info] Start / :online
teslamate_1 | 21:56:16.251 [error] Mounting lv:phx-YAnm40fq failed while verifying session with: :invalid

Idiot's guide to getting this working on a Synology NAS

I finally got it working after digging through various sections of the github and doing some research on various commands and the synology (it's been a few years since I did any heavy linux programming, so some of the issues were me tracking down commands). Below are my "idiot proof" instructions for how to get this running on a home LAN with a synology and a Windows10 PC.

  1. Login to your Synology, go to the package center and install Docker

  2. Open your windows notepad and create your docker-compose.yml file. It should look like:

    REMOVED (find latest version here: https://docs.teslamate.org/docs/installation/docker)

  3. Now edit the file as follows:

    a. change localhost in the VIRTUAL_HOST line to whatever the local LAN IP address is for your synology (hopefully you have set your router to make that a static IP address). Should be something like 192.168.1.XXX
    b. change the TZ to equal the timezone where your synology resides. A list of the time zone codes that work can be found at List of tz database time zones - Wikipedia.

  4. Now save the file to your computer. It may be that Windows saves it as docker-compose.yml.txt. I had to go in and manually rename it, deleting the .txt part. It asked me if I wanted to change the file type and I said yes. No impact on it after that and I could still open it up with notepad.

  5. Now you need to transfer the file to Synology. If you can FTP to your synology, it's easy. If not, do the following:

    a. Open "File Station" in the Synology desktop.
    b. Navigate to a folder that is easy to get to (say a top level folder like "files"
    c Right click your mouse, select upload to and upload your file from your windows pc. It should now be sitting in your "files" directory (or wherever you put it).

  6. Next you need to set up your synology so you can SSH to it. If you have already done this, skip this step. Otherwise, go to Control Panel->Terminal & SNMP and in the Terminal tap, check the box to enable SSH Service, leave the default port of 22 selected.

  7. Now go back to your Windows box and open up an SSH terminal. In my box I did it by clicking the Windows and the X keys and then selecting Windows Powershell

  8. In the command prompt, I typed ssh admin@synologylocal address (I used ssh [email protected] but you should also be able to type ssh [email protected] (whatever your synology ip address is)).

  9. You will then get a prompt to enter the admin password. Type in the admin password for your synology and hit enter.
    10.You should get a display showing something like "admin@servername:/$" -- this is the synology SSH prompt.

  10. Typesudo -i(this changes you to root access to the synology box)

  11. You will get a password prompt...type in your admin password again

  12. You will now get a prompt that looks like root@servername:

  13. Now change directories to your docker directory. Type cd /volume1/@docker (note the @ before docker)

  14. Your prompt will now show root@servername:/volume1/@docker#

  15. Now it gets fun....you need to move your docker-compose.yml file to the @docker directory (which you can't access or see from the File Station synology app), so you need to move it via linux commands. The command to type is mv /volume1/files/docker-compose.yml /volume1/@docker/docker-compose.yml Note there is a space between mv and the first file location and between that location and the destination file location. In linux, everything is case-sensitive, so if your files directory is named "Files" then you need to write it that way.

  16. Type dir and, if you are successful, you will see docker-compose.yml in the current (@docker) directory.

  17. You've now done the hard stuff. Next you type the command to download and install the packages. The command is docker-compose up -d (note the space after compose and up and the space between up and -d. You DO NOT type .yml after docker-compose. If you did everything right, things will run and scroll for several minutes as it downloads multiple packages and installs them. At the very end you will get some "dones" and be back to your root@servername: prompt.

  18. Go back to your synology web interface and open the Docker app. In the overview tab you should see 4 containers running: docker_db_1, docker_grafana_1, docker_mosquito_1, and docker_teslamate_1.

  19. Now in your PC web browser, you want to type: synologyIP address:4000 (should be something like 192.168.0.123:4000). The TeslaMate interface will open. Type in your TESLA email address and password (just like when you login to the car app). It will open up a page which shows you the current status of your car. Note it defaults to kilometers and degrees C but you can change that on the settings page.

  20. Now in your PC web browser, type in synologyIP address:3000 (should be something like 192.168.0.123:3000. This will open up Grafana which is where you can see all the charts. Various charts are on the left. Most are blank until you do something with your car/time goes by, but it will start populating. If you click on the "position" chart, it should open a map with a red dot where your car currently is. If you can see that, it is getting data from the car!

Realize this is a long post but figured these instructions would be helpful to those with a Synology who have never done this kind of thing before. @adriankumpf - This is really a great piece of work. If desired, you can post these instructions somewhere on your github page as well (I didn't want to assume anything and post them there).

SoC Data Discrepancy

I'm trying to figure out this data discrepancy between the web interface and the Grafana interface. The web interface correctly shows 74% SoC while the Grafana board shows 78%.

Could this be a matter of bad database data? I don't mind clearing the data out completely to test that. Is there a simple way to do that, by the way?

image
image
image

How to resume logging when on the intranet?

Sorry not really an issue but a questions - I was looking to understand on how to resume logging when running this locally and not exposed online.

The documentation says to use Tasker or Shortcuts and all this:
PUT https://teslamate.your-domain.com/api/car/$car_id/logging/resume

I am running Docker on my Synology NAS; and and it its IP is 192.168.1.2, what do I use? And is there a way to tickle this IP without a PUT call? Would it be something like:
http://192.168.10.2:3000/api/car/$car_id/logging/resume

And I presume $car_id is the ID column from the cars table and not the eid or vid?

Thanks in advance!

General Question - Real-Time Logging

Just a general question as my wife went out on an errand.

Is the data logged real time?
Does the car have to be on WiFi (same network as teslamate) in order for data to get pulled, etc?

I saw that the 1st 21 minutes of a trip won't be logged. If we run short errands, etc none of this will be tracked/logged?

Feature request: log and chart elevation for drives

Changes in elevation have a significant impact on efficiency when driving. The data should already be present in vehicle's position information. Having a summed elevation change (+/- X m) in the "Drives" table as well as an elevation chart in drive details can help evaluate consumption and efficiency in more detail.

Grafana syntax errors

I manually imported and here are the errors I get:
Under Charging:
pq: syntax error at or near "ORDER"

It seems the $charging_process_id is hardcoded to a value of 28?

Under Consumption:
pq: syntax error at or near "AND"

It seems the $trip_id is hardcoded to value 459?

Not sure what the hardcoded values are supposed to represent, or if I imported wrong somehow

Model X type missmatch

My car is identified as P90D ( I wish! :) ) instead of 90D.
The code for correct option codes is there:
defp get_efficiency("MX", "BTX4", true, _), do: {"X 90D", 0.208},

but the log says:

17:16:03.548 [info] Found Model X P90D:

My option codes:

"option_codes":"REEU,AD15,AF02,AH01,APF1,APH2,APPB,AU01,BC0B,BP00,BR00,BS00,BTX4,CC03,CDM0,CF01,CH04,COGB,PMBL,CW02,DRRH,DSH7,DV4W,FG02,FR02,GLTL,HP00,IDCF,IX01,LP01,LT3W,ME01,MI00,OSSW,PA00,PF00,PI01,PK00,PS00,QLEW,RFPX,S06W,SC01,SP01,SR01,ST02,SU01,TIM7,TM00,TP03,TR01,TRA1,TW00,UM01,UTAB,WT20,X001,X003,X007,X011,X014,X021,X025,X026,X028,X031,X037,X039,X042,X044,YFCC,MDLX"

Thanks!

Tasker Setup Troubleshooting

As noted in the guide, @adriankumpf setup Teslamate with dynamic polling minimize the frequency your vehicle is polled when it is sleeping/inactive.

Tasker can automatically trigger Teslamate to resume polling the vehicle upon connecting to your Tesla's bluetooth.

With guidance from @IMgoRt :
"In tasker open a new task, add a javascriptlet and put the following:
xmlhttp = new XMLHttpRequest(); xmlhttp.open('PUT', 'https://192.168.1.1:4000/api/car/1/logging/resume');
where 192,168.1.1 is the IP address (I have mine over a VPN), 4000 is the port and 1 is the car number"

image

Unfortunately, this did not work for me - perhaps related to my NGINX setup. Perhaps I don't have Tasker configured properly yet. Maybe others can comment on what needs to be done to make this work.

I can however confirm this works without Secure HTTP.

Create a new Task : "Teslamate Resume"
Click the + sign to add a new Action>Net>HTTP Request
Set the Method to PUT
Set the URL to http://192.168.86.22:4000/api/car/1/logging/resume

image

You can then test it within Tasker by clicking the play button and checking against the Teslamate Server log.

image

Trigger the Task by connecting to your Model S Bluetooth
Select PROFILES
Click the + on the bottom right and name it : BT Connected
Choose STATE>Net>BT Connected
Name : click the magnifying glass to choose your Tesla
Address : click the magnifying glass to choose your Tesla
Select the Task Teslamate Resume

image

image

Setup a similar process to SUSPEND as required.

Hopefully others will find this useful. In the meantime, I will try and figure out how to make this work outside of my LAN.

IOS Shortcut to wake teslamate

Do you have an example or instructions on how to create the shortcut to:

  • listen for the bluetooth connection
  • call the http file in your instructions

Synology: Can't Access Web Interface

Completely new to this but just did a fresh install on a Synology NAS. I can access Grafana at port 3000 but can't access the Web Interface at port 4000.

I can see all 4 containers in Docker and they are all running. Was there anything I needed to change other than the VIRTUAL_HOST IP address in the docker-compose.yml file?

Efficiency Numbers Anomaly

After few days of running TeslaMate I'm starting to get the efficiency data. However, they are too good to be true.
For example a round trip I did yesterday. The difference can't be that high.
return trip

Also the Efficiency dash is looking like this:
efficiency

Thanks!

Feature request: add basic auth for Grafana (port 3000) access

First of all, great project, much appreciated.

Is it feasible to add some generic authentication, or OAuth (Google or GitHub) to the Grafana container?

I'm running on a cloud server.
For the teslamate container (port 4000), I can disable port 4000 immediately after entering my tesla credentials. But I feel a little uncomfortable about leaving port 3000 open without any auth.

Thanks,
-Steve

API post 1.6

Is the car_id in /api/car/$car_id/logging/resume Still a numerical value like 1 or is now the car name? Say my car name is Model 3.
Would it be

/api/car/Model_3/logging/resume

Or does it stay

/api/car/1/logging/resume

Thanks!

"Scheduled Charging" Displays "Invalid Date"

This isn't new for v1.6. I don't know when exactly it started and it's quite possible it has been this way since the beginning, but the "Schedule charging" value on the Teslamate (port 4000) page always lists "Invalid Date".

image

Thanks for everything you've done! I'm loving it.

Suggestion - Updating the Drive Details dashboard with seperate graph plots?

Just a suggestion not sure what others things about it - I personally prefer the driving details that tesla-apiscraper has where it breaks up some of the elements such as Speed and Power Reserve (e.g. see this).

All the plot lines with all the data is an overkill for me and takes me longer to track and see just the subset of data points I was interested in.

I was wondering if it is possible to do a similar graph, combined with the map. Essentially a mashup of the two? Separating the data points, do take up more space but possibly something to try? And I don't want to lose the maps here. :)

[Question] Anyone have it working on a Synology?

I have docker installed on my Synology NAS, but while trying to get things configured, I am getting an error:

ERROR: for docker_db_1 Cannot start service db: driver failed programming external connectivity on endpoint docker_db_1 (a2649d4dc2c7ce59f684756281115ea6df883189a9b6d44b4e9923fc6b3848e0): Error starting userland proxy: listen tcp 0.0.0.0:5432: bind: address already in use

ERROR: for db Cannot start service db: driver failed programming external connectivity on endpoint docker_db_1 (a2649d4dc2c7ce59f684756281115ea6df883189a9b6d44b4e9923fc6b3848e0): Error starting userland proxy: listen tcp 0.0.0.0:5432: bind: address already in use

5432 Seems to be the port that postgresql is listening on:

root@nas:/volume1/docker# netstat -an | grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 24238 /run/postgresql/.s.PGSQL.5432
unix 3 [ ] STREAM CONNECTED 46660660 /run/postgresql/.s.PGSQL.5432
unix 3 [ ] STREAM CONNECTED 46655926 /run/postgresql/.s.PGSQL.5432
unix 3 [ ] STREAM CONNECTED 46660662 /run/postgresql/.s.PGSQL.5432
unix 3 [ ] STREAM CONNECTED 190214 /run/postgresql/.s.PGSQL.5432

Report imperial metrics

obviously, the metric system is better but as someone living in the US it would be nice if there was a config to swap to reporting in Miles and Fahrenheit.

I have started doing this by simply converting units in the queries on my Grafana dashboards but this is a bit of a hassle.

Column p0.drive_id does not exist

Upgrading from 1.4 via docker-compose pull and now seeing this error on startup:

** (Postgrex.Error) ERROR 42703 (undefined_column) column p0.drive_id does not exist teslamate_1 | 17:53:45.342 [info] == Running 20190805092941 TeslaMate.Repo.Migrations.FixIncompleteChargingProcesses.up/0 forward teslamate_1 | ** (Postgrex.Error) ERROR 42703 (undefined_column) column p0.drive_id does not exist teslamate_1 | teslamate_1 | query: SELECT p0."id", p0."date", p0."latitude", p0."longitude", p0."speed", p0."power", p0."odometer", p0."ideal_battery_range_km", p0."battery_level", p0."battery_heater", p0."battery_heater_on", p0."battery_heater_no_power", p0."outside_temp", p0."inside_temp", p0."altitude", p0."fan_status", p0."driver_temp_setting", p0."passenger_temp_setting", p0."is_climate_on", p0."is_rear_defroster_on", p0."is_front_defroster_on", p0."car_id", p0."drive_id", p0."id" FROM "positions" AS p0 WHERE (p0."id" = $1) teslamate_1 | teslamate_1 | hint: Perhaps you meant to reference the column "p0.trip_id".

Charges - charged and kw data

On Charges dash the charged and kw data is not consistent with Charges Details.
Everything else (mph, SOC, etc) looks ok. I have a variable energy tariff hence the multiple charging sessions.

Screenshot 2019-08-26 at 12 24 09

Screenshot 2019-08-26 at 12 24 40

Thanks!

Missing Data In Grafana?

This might be related to getting Teslamate to start polling overnight. When I look at the States graph, it looks like the car did not sleep overnight (am I correct with this assumption?). I naturally assumed that the car was still being polled by Teslamate. Looking at DriveDetails it appears some data was captured - only when I reached my workplace (which is why the graph shows a straight line. The Drives graph captures nothing. I figured it would have captured my final destination as an end data point, and the original data point would be the start data point.

I just purchased Tasker for my Android phone - now I need to figure out how to PUSH/PUT resume to Teslamate (which is running on virtualized Ubuntu in VMWare).

On a separate note - should the Position graph display a "dot" where the vehicle is on the map? Currently I just get a map of the general area where the car is.

States

DriveDetails

Drives

BRAVO! Working on my Synology NAS in minutes!

This is by far no issue at all. I just wanted to say THANK YOU for an awesome project! I, too have a Synology NAS server. I followed these steps to get it working QUICKLY:

  1. On Synology NAS server, install the Docker Package
  2. SSH to the Synology NAS and sudo -i (root)
  3. cd /volume1/@docker
  4. Create the docker-compose.yml file and configure your settings.
    I modified the VIRTUAL_HOST= to point to the IP of my NAS and TZ=America\Los Angeles
    Set the password for the DATABASE_PASS parameter
  5. Save the file
  6. Run docker-compose up -d (looked around in the other issues and this -d option was very helpful)

Within minutes, I went to http://mynasip:4000 and entered my mytesla credentials. Then went to http://mynasip:3000 and boom! Grafana was up and running, too!

I really appreciate how slick this is and how easy it was to setup!

Is upgrading as easy as:

docker-compose pull and restart with docker-compose up -d again? Or do I have to shutdown the instances first then run a docker-compose pull command?

Looking forward to more features if more come along! Maybe this can rival teslafi.com ;) Seems like it has most everything already

Efficiency Calculation Incorrect

When using more power than rated for a particular vehicle the efficiency appears as over 100%. After investigating, the cause is likely that the fraction is inverse. For example, the current calculation looks like:

ideal_distance / distance

in reality it should be:

distance / ideal_distance

This way, if distance traveled is less than the ideal rated distance we will see a lower percentage and vice-versa if the opposite is true.

Units in the UK

Hi, thanks for this great project, I have it up and running on my Xpenology (open-source Synology) without issue.
In the UK we prefer to use Miles and Centigrade but the unit choices either provide full metric or full imperial, would it be possible to offer a hybrid setting.
TIA

Suspending Logging wakes up the car.

Firstly, awesome work!!! Thank you for your time!

This is the log from teslamate:
20:20:57.421 car_id=1 [info] Suspending logging
20:42:01.535 car_id=1 [info] Suspending logging
Meanwhile the status is "falling asleep for...".
I can see the car going to sleep by checking when it disconnects from wifi. Few seconds after "Suspending logging" the car comes back online and on wifi.
Time to try sleeping is set to 21 min.

Screen Shot 2019-08-22 at 21 00 30

This is the log from my DNS server. The connection to Tesla servers is visible.

2019-08-22 20:20:52 | A | owner-api.teslamotors.com | teslamate.local | OK (forwarded) | CNAME
2019-08-22 20:41:57 | A | owner-api.teslamotors.com | teslamate.local | OK (forwarded) | CNAME

Is this a design feature? One workaround is to increase the Time to try sleeping to 60 min. I have a script to resume logging anyway when connect to the car by BT.

Best regards,
Mihai

Vampire Drain High - Not Sleeping?

First off I would like to say kudos to the development of this app! I found it very easy to get setup on my own server and the stats have been very informative.

I'm having an issue where the car is not going to sleep or, if it is, it's being constantly woken up.
Please see the following:
Screen Shot 2019-08-13 at 9 19 45 AM

Ever since installing Teslamate I've had apparently an average vampire drain of ~200-230 W. I noticed I'd come to my car in the morning and be down more than a few percentage points of battery which I did not remember happening before installing Teslamate. Last night I decided to turn Teslamate off and then back on in the morning to see if that made a difference. As you can tell in the screenshot the loss of power was significantly down.

Is this expected behaviour or is something wrong?

Charging While Offline Interpreted Incorrectly

Where I am, the only supercharger nearby is inside of a garage where there is no cell/wifi signal. In this case, the car is offline while charging. This leads to the Teslamate thinking that the trip to the charger and back is a single trip rather than a trip, charge, and another trip.

This results in drive details which encompass the charge duration and skewed metrics. Attached are the summaries and one detailed view of a charge for reference.

If a car goes offline and gains a significant amount in SoC it should be considered a charge session that begins when the car went offline and ends when it came back online. In addition, the previous drive should be stopped when the charge session began (or the car went offline) and a new drive should begin.

OfflineChargingEg1
OfflineChargingEg2
OfflineChargingEg3

Provide docker-compose.yml and outsorce user settings to seperate file

Idea is to provide a docker-compose.yml within this repository and outsource the needed userdata like DATABASE_PASS to a file, for example environemt which stays local.
This would make prevent errors during yml creation and reduce variance. In addition the the update process would be more elegant.

Removal of TESLA_USERNAME and TESLA_PASSWORD from Environment Variables

Can we brainstorm some ways we can remove TESLA_USERNAME and TESLA_PASSWORD from Environment Variables? These are visible from the container settings and I don't like my password sitting out in the open.
Some sort of secrets manager or an endpoint that you can call that sets the credentials and starts the API after being called.

Drives Columns - Meaning

drives

Most of the column meanings I understand. Does Ø = Average?

What do these mean?

  • TR Loss
  • Ø Speed
  • Ø Consumption
  • Consumed (would I use this value to calculate the consumed kWh of say 7.7 kWh and multiply that by my utility rate ($0.15663/kWh) to find the cost of how much going on that trip would cost me to charge at home)

Even on a larger screen the columns get mushed together. Is there a better way to format/display this?

Thanks!

Ecto.MultipleResultsError: expected at most one result but got 3

I believe last week I updated to 1.5.3 and I didn't quite check after that, but it doesn't appear that new data was being retrieved since that update. Today I tried looking at my stats for the last several days and noticed. I tried updating to 1.6 but that didn't help.

I'm on Synology and here are the logs I see when I do (the same paragraph of logs seems to repeat every minute or so):

$ docker logs docker_teslamate_1

Crash dump is being written to: erl_crash.dump...done
10:07:33.196 [info] Already up
10:07:55.785 [info] Running TeslaMateWeb.Endpoint with cowboy 2.6.3 at :::4000 (http)
10:07:55.787 [info] Access TeslaMateWeb.Endpoint at http://nas
10:07:55.833 [info] Found Model 3 LR: 'Worth It'
10:07:55.864 [info] Application teslamate exited: TeslaMate.Application.start(:normal, []) returned an
error: shutdown: failed to start child: TeslaMate.Vehicles
** (EXIT) shutdown: failed to start child: TeslaMate.Vehicles.Vehicle_1
** (EXIT) %Ecto.MultipleResultsError{message: "expected at most one result but got 3 in
query:\n\nfrom s0 in TeslaMate.Log.State,\n where: ^1 == s0.car_id and is_nil(s0.end_date)\n"}
{"Kernel pid terminated",application_controller,"{application_start_failure,teslamate,{{shutdown,{failed_to_start_child,'Elixir.TeslaMate.Vehicles',{shutdown,{failed_to_start_child,'Elixir.TeslaMate.Vehicles.Vehicle_1',#{'exception' => true,'struct' => 'Elixir.Ecto.MultipleResultsError',message => <<"expected at most one result but got 3 in query:\n\nfrom s0 in TeslaMate.Log.State,\n where: ^1 == s0.car_id and is_nil(s0.end_date)\n">>}}}}},{'Elixir.TeslaMate.Application',start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,teslamate,{{shutdown,{failed_to_start_child,'Elixir.TeslaMate.Vehicles',{shutdown,{failed_to_start_child,'Elixir.TeslaMate.Ve
`

Charging_Processes table incomplete

Only start_date, car_id, position_id and address_id are being populated in charging_processes. Everything else is left null.

The charges table seems to be populating fully.

I've only started using this but the 3 entries populated so far in charging_processes have the same incomplete entries.

Database error after upgrading from 1.4.3 to latest

Noticed I was a few versions behind, so decided to update to latest and now I get the following:
db_1 | 2019-08-26 05:18:16.975 UTC [64] STATEMENT: SELECT c0."id", c0."name", c0."efficiency", c0."eid", c0."model", c0."version", c0."vid", c0."vin", c0."inserted_at", c0."updated_at", c0."id" FROM "cars" AS c0 WHERE (c0."id" = $1) teslamate_1 | ** (Postgrex.Error) ERROR 42703 (undefined_column) column c0.name does not exist teslamate_1 | teslamate_1 | query: SELECT c0."id", c0."name", c0."efficiency", c0."eid", c0."model", c0."version", c0."vid", c0."vin", c0."inserted_at", c0."updated_at", c0."id" FROM "cars" AS c0 WHERE (c0."id" = $1)

I initially updated the images via portainer UI, but that game the the error with c0.name column not existing as well, so I did a docker-compose up and that is what gave me the output from above.

Postgres issue starting up / vid "has already been taken"

I had teslamate working on my Ubuntu computer, but it's having issues now.

teslamate_1 | 13:41:10.682 [info] Already up
teslamate_1 | 13:41:16.681 [info] Running TeslaMateWeb.Endpoint with cowboy 2.6.3 at :::4000 (http)
teslamate_1 | 13:41:16.681 [info] Access TeslaMateWeb.Endpoint at http://192.168.10.51
teslamate_1 | 13:41:16.760 [info] Found car 'Kevin Model 3'
teslamate_1 | 13:41:16.773 [info] Application teslamate exited: TeslaMate.Application.start(:normal, []) returned an error: shutdown: failed to start child: TeslaMate.Vehicles
teslamate_1 | ** (EXIT) an exception was raised:
teslamate_1 | ** (MatchError) no match of right hand side value: {:error, #Ecto.Changeset<action: :insert, changes: %{efficiency: 0.153, eid: 36230209430047724, model: "M3", vid: 1749778265}, errors: [vid: {"has already been taken", [constraint: :unique, constraint_name: "cars_vid_index"]}], data: #TeslaMate.Log.Car<>, valid?: false>}
teslamate_1 | (teslamate) lib/teslamate/vehicles.ex:70: TeslaMate.Vehicles.create_new!/1
teslamate_1 | (teslamate) lib/teslamate/vehicles.ex:25: anonymous fn/2 in TeslaMate.Vehicles.init/1
teslamate_1 | (elixir) lib/enum.ex:1336: Enum."-map/2-lists^map/1-0-"/2
teslamate_1 | (teslamate) lib/teslamate/vehicles.ex:25: TeslaMate.Vehicles.init/1
teslamate_1 | (stdlib) supervisor.erl:295: :supervisor.init/1
teslamate_1 | (stdlib) gen_server.erl:374: :gen_server.init_it/2
teslamate_1 | (stdlib) gen_server.erl:342: :gen_server.init_it/6
teslamate_1 | (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
teslamate_1 | {"Kernel pid terminated",application_controller,"{application_start_failure,teslamate,{{shutdown,{failed_to_start_child,'Elixir.TeslaMate.Vehicles',{{badmatch,{error,#{'struct' => 'Elixir.Ecto.Changeset',action => insert,changes => #{efficiency => 0.153,eid => 36230209430047724,model => <<"M3">>,vid => 1749778265},constraints => [#{constraint => <<"cars_vid_index">>,error_message => <<"has already been taken">>,error_type => unique,field => vid,match => exact,type => unique},#{constraint => <<"cars_eid_index">>,error_message => <<"has already been taken">>,error_type => unique,field => eid,match => exact,type => unique}],data => #{'meta' => #{'struct' => 'Elixir.Ecto.Schema.Metadata',context => nil,prefix => nil,schema => 'Elixir.TeslaMate.Log.Car',source => <<"cars">>,state => built},'struct' => 'Elixir.TeslaMate.Log.Car',charging_processes => #{'cardinality' => many,'field' => charging_processes,'owner' => 'Elixir.TeslaMate.Log.Car','struct' => 'Elixir.Ecto.Association.NotLoaded'},drives => #{'cardinality' => many,'field' => drives,'owner' => 'Elixir.TeslaMate.Log.Car','struct' => 'Elixir.Ecto.Association.NotLoaded'},efficiency => nil,eid => 36230209430047724,id => nil,inserted_at => nil,model => nil,positions => #{'cardinality' => many,'field' => positions,'owner' => 'Elixir.TeslaMate.Log.Car','struct' => 'Elixir.Ecto.Association.NotLoaded'},updated_at => nil,vid => 1749778265},empty_values => [<<>>],errors => [{vid,{<<"has already been taken">>,[{constraint,unique},{constraint_name,<<"cars_vid_index">>}]}}],filters => #{},params => #{<<"efficiency">> => 0.153,<<"eid">> => 36230209430047724,<<"model">> => <<"M3">>,<<"vid">> => 1749778265},prepare => [],repo => 'Elixir.TeslaMate.Repo',repo_opts => [],required => [eid,vid,model,efficiency],types => #{charging_processes => {assoc,#{'struct' => 'Elixir.Ecto.Association.Has',cardinality => many,defaults => [],field => charging_processes,on_cast => nil,on_delete => nothing,on_replace => raise,owner => 'Elixir.TeslaMate.Log.Car',owner_key => id,queryable => 'Elixir.TeslaMate.Log.ChargingProcess',related => 'Elixir.TeslaMate.Log.ChargingProcess',related_key => car_id,relationship => child,unique => true,where => []}},drives => {assoc,#{'struct' => 'Elixir.Ecto.Association.Has',cardinality => many,defaults => [],field => drives,on_cast => nil,on_delete => nothing,on_replace => raise,owner => 'Elixir.TeslaMate.Log.Car',owner_key => id,queryable => 'Elixir.TeslaMate.Log.Drive',related => 'Elixir.TeslaMate.Log.Drive',related_key => car_id,relationship => child,unique => true,where => []}},efficiency => float,eid => integer,id => id,inserted_at => naive_datetime,model => string,positions => {assoc,#{'struct' => 'Elixir.Ecto.Association.Has',cardinality => many,defaults => [],field => positions,on_cast => nil,on_delete => nothing,on_replace => raise,owner => 'Elixir.TeslaMate.Log.Car',owner_key => id,queryable => 'Elixir.TeslaMate.Log.Position',related => 'Elixir.TeslaMate.Log.Position',related_key => car_id,relationship => child,unique => true,where => []}},updated_at => naive_datetime,vid => integer},'valid?' => false,validations => []}}},[{'Elixir.TeslaMate.Vehicles','create_new!',1,[{file,"lib/teslamate/vehicles.ex"},{line,70}]},{'Elixir.TeslaMate.Vehicles','-init/1-fun-0-',2,[{file,"lib/teslamate/vehicles.ex"},{line,25}]},{'Elixir.Enum','-map/2-lists^map/1-0-',2,[{file,"lib/enum.ex"},{line,1336}]},{'Elixir.TeslaMate.Vehicles',init,1,[{file,"lib/teslamate/vehicles.ex"},{line,25}]},{supervisor,init,1,[{file,"supervisor.erl"},{line,295}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,374}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,342}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}}},{'Elixir.TeslaMate.Application',start,[normal,[]]}}}"}
teslamate_1 | Kernel pid terminated (application_controller) ({application_start_failure,teslamate,{{shutdown,{failed_to_start_child,'Elixir.TeslaMate.Vehicles',{{badmatch,{error,#{'struct' => 'Elixir.Ecto.Chan
teslamate_1 |
teslamate_1 | Crash dump is being written to: erl_crash.dump...done
db_1 | 2019-08-13 20:41:20.582 UTC [685] LOG: incomplete startup packet
teslamate_1 | 13:41:22.813 [info] Already up

I tried connecting to the docker-compose psql and looking at the database directly, but it seemed to be fine:

sudo docker-compose run --rm db psql -h db -U teslamate

teslamate=# SELECT * from cars;
id | eid | vid | model | efficiency | inserted_at | updated_at
----+-------------------+------------+-------+------------+---------------------+---------------------
1 | 19822922099185452 | 1749778265 | M3 | 0.153 | 2019-07-31 17:46:32 | 2019-07-31 17:46:32
(1 row)

teslamate=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------------------+-------+-----------
public | addresses | table | teslamate
public | cars | table | teslamate
public | charges | table | teslamate
public | charging_processes | table | teslamate
public | drives | table | teslamate
public | geofences | table | teslamate
public | positions | table | teslamate
public | schema_migrations | table | teslamate
public | settings | table | teslamate
public | states | table | teslamate
public | tokens | table | teslamate
public | updates | table | teslamate
(12 rows)

I'm not sure how to get this fixed without wiping my entire docker install. Help?

Mileage Per Car Not Working

I own two vehicles. Most of the grafana charts work well by allowing you to switch between the two vehicles.

However, on the "Mileage" chart - there is no difference between vehicle 1 and 2. Both options show the mileage info for vehicle 1.

I'm using release 1.6.0

Error during WebSocket handshake: Unexpected response code: 403

Fresh install in docker container and receiving below error in chrome console window on TeslaMate home:

app-3e0520f22c38662b278d3df0a4160cd5.js?vsn=d:1 WebSocket connection to 'ws://{my_hostname}:4000/live/websocket?vsn=2.0.0' failed: Error during WebSocket handshake: Unexpected response code: 403

Websocket Error / Spinner

I've installed telsamate using the latest docker release. The UI runs and displays data from the car, but it displays a spinner in the center.

Looking at the debug window reports over 100 errors of the same type:
WebSocket connection to 'ws://IP_REDACTED:4000/live/websocket?vsn=2.0.0' failed: Error during WebSocket handshake: Unexpected response code: 403

grafana Charges display not updating

Since getting TeslaMate configured and running I've since charged our car 2 times. Before it was showing our 1st charge, now it's only showing our most recent charge at all times. No matter what time I change the time range to, it's always showing 1 charge. How can this be corrected/fixed?

Capture

Charge Details shows the two charges just fine, too

Capture1

Add "Actual Range" as a metric

Awesome tool you've developed! Wondering if you could add Actual Range as a metric. Would like to see range numbers match the Tesla app. Thank you

Setup Error Running Wizzy

Using the latest docker image then manually downloaded the english dashboard files to the same location as my docker_compose.yam. When trying to run wizzy (v. 0.6.0), I get an error.

I'm not sure if this is an error with wizzy or teslamate.

I'm running:
for d in dashboards/en_*; do wizzy export dashboard $(basename $d .json); done

And getting this error for each file:

/usr/local/lib/node_modules/wizzy/src/remote/grafana/exportSrv.js:140
			dashBody.dashboard.id = body_check.dashboard.id;
			                                            ^
TypeError: Cannot read property 'id' of undefined
    at Request.responseHandler [as _callback] (/usr/local/lib/node_modules/wizzy/src/remote/grafana/exportSrv.js:140:48)
    at Request.self.callback (/usr/local/lib/node_modules/wizzy/node_modules/request/request.js:185:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/wizzy/node_modules/request/request.js:1161:10)
    at emitOne (events.js:77:13)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/wizzy/node_modules/request/request.js:1083:12)
    at IncomingMessage.g (events.js:260:16)
    at emitNone (events.js:72:20)

Comparision with TeslaLogger

I stumpled across TeslaLogger and then across TeslaMate. You wrote TeslaLogger was an inspiration t the beginning. Can you specify what is the difference beside of the programming language?

Thanks in advance.

Weird data in grafana, postgresql data seems ok

First of all, thank you for this software!

Im having an issue with displaying stuff correctly in grafana. (First time ever using it so bear with me). For example under the drives, vampire drain and location dashboards I have the following data: https://imgur.com/a/gacJo0K

However in postgresql, I can see the following in for example drives table:

teslamate=# select * from drives limit 10; id | start_date | end_date | outside_temp_avg | speed_max | power_max | power_min | power_avg | start_range_km | end_range_km | start_km | end_km | distance | duration_min | consumption_kWh | consumption_kWh_100km | efficiency | car_id | inside_temp_avg | start_address_id | end_address_id ----+---------------------+---------------------+------------------+-----------+-----------+-----------+------------------+----------------+--------------+--------------+--------------+------------------+--------------+----------------- +-----------------------+-------------------+--------+-----------------+------------------+---------------- 1 | 2019-08-22 06:16:51 | 2019-08-22 06:31:23 | 11.3507692307692 | 92 | 78 | -31 | 10.1230769230769 | 214.1 | 200.1 | 28919.491025 | 28932.399636 | 12.9086109999989 | 15 | 2.604 | 20.172580922922 | 0.922043642857066 | 1 | 21.636923076923 | 1 | 2

Any idea why?

Thank you in advance.

Edit: It seems somehow the grafana data is from a testdata plugin. Oh well, learn something new every day. Case closed!

How to find $car_id?

teslamate_1  | 21:55:04.269 [info] Found car 'Tesla'
teslamate_1  | 21:55:04.278 [info] Running TeslaMateWeb.Endpoint with cowboy 2.6.3 at :::4000 (http)
teslamate_1  | 21:55:04.279 [info] Access TeslaMateWeb.Endpoint at http://homeservices
teslamate_1  | 21:55:04.940 [info] Start / :online

I am attempting to get Tasker setup properly by using the given links from the readme:

PUT https://teslamate.your-domain.com/car/$car_id/logging/resume
PUT https://teslamate.your-domain.com/car/$car_id/logging/suspend

I've tried filling $car_id with 1, 0, Tesla, tesla.
I've tried looking in the HTML to figure out what the ID is, but couldn't find mention of it.
With all the above I continually get 404 Not Found errors.

teslamate_1  | 02:53:02.327 [info] PUT /car/1/logging/resume
teslamate_1  | 02:53:02.328 [info] Sent 404 in 299µs
teslamate_1  | 02:53:02.328 [info] Converted error Phoenix.Router.NoRouteError to 404 response

Does this application not work immediately upon setup? Do I need to drive the car once or something like that to get all the state in the right place?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.