TeslaMate

Import your driving and charging data from TeslaMate.

Export from a normal Docker installation

In a shell, navigate to your TeslaMate directory and run this one-line command:

docker-compose exec -T database psql -U $(docker-compose exec -T database env | grep POSTGRES_USER | cut -d"=" -f2) -d $(docker-compose exec -T database env | grep POSTGRES_DB | cut -d"=" -f2) -c "\copy (WITH positiondata AS(SELECT cars.vin, positions.date, positions.latitude, positions.longitude, positions.speed, positions.power, positions.odometer, positions.ideal_battery_range_km, positions.battery_level, positions.outside_temp, positions.is_climate_on, positions.inside_temp, positions.rated_battery_range_km, positions.usable_battery_level, NULL :: NUMERIC AS charge_energy_added, NULL :: NUMERIC AS charger_actual_current, NULL :: NUMERIC AS charger_phases, NULL :: NUMERIC AS charger_pilot_current, NULL :: NUMERIC AS charger_power, NULL :: NUMERIC AS charger_voltage, NULL :: BOOLEAN AS fast_charger_present, NULL AS conn_charge_cable, NULL AS fast_charger_brand, NULL AS fast_charger_type, ( SELECT B.version FROM updates B WHERE B.end_date <= positions.date AND B.car_id = positions.car_id ORDER BY B.end_date DESC LIMIT 1) AS version, Row_number() over ( PARTITION BY positions.car_id, (Cast(Extract(epoch FROM positions.date) AS INTEGER) / 10) ORDER BY positions.DATE ASC) AS rn FROM positions inner join cars ON cars.id = positions.car_id), chargingdata AS (SELECT cars.vin, charges.date, positions.latitude, positions.longitude, NULL :: SMALLINT AS speed, NULL :: SMALLINT AS power, NULL :: SMALLINT AS odometer, charges.ideal_battery_range_km, charges.battery_level, charges.outside_temp, NULL :: BOOLEAN AS is_climate_on, NULL :: NUMERIC AS inside_temp, charges.rated_battery_range_km, charges.usable_battery_level, charges.charge_energy_added, charges.charger_actual_current, charges.charger_phases, charges.charger_pilot_current, charges.charger_power, charges.charger_voltage, charges.fast_charger_present, charges.conn_charge_cable, charges.fast_charger_brand, charges.fast_charger_type, ( SELECT B.version FROM updates B WHERE B.end_date <= charges.date AND B.car_id = positions.car_id ORDER BY B.end_date DESC LIMIT 1 ) AS version, Row_number() over ( PARTITION BY charges.charging_process_id, (Cast(Extract( epoch FROM charges.date) AS INTEGER) / 10) ORDER BY charges.date ASC) AS rn FROM charges inner join charging_processes ON charging_processes.id = charges.charging_process_id inner join cars ON cars.id = charging_processes.car_id inner join positions ON positions.id = charging_processes.position_id) SELECT vin, date, latitude, longitude, speed, power, odometer, ideal_battery_range_km, battery_level, inside_temp, outside_temp, is_climate_on, rated_battery_range_km, usable_battery_level, charge_energy_added, charger_actual_current, charger_phases, charger_pilot_current, charger_power, charger_voltage, fast_charger_present, conn_charge_cable, fast_charger_brand, fast_charger_type, version FROM positiondata WHERE rn = 1 UNION SELECT vin, date, latitude, longitude, speed, power, odometer, ideal_battery_range_km, battery_level, inside_temp, outside_temp, is_climate_on, rated_battery_range_km, usable_battery_level, charge_energy_added, charger_actual_current, charger_phases, charger_pilot_current, charger_power, charger_voltage, fast_charger_present, conn_charge_cable, fast_charger_brand, fast_charger_type, version FROM chargingdata WHERE rn = 1 ORDER BY DATE ASC) TO 'teslamate.csv' csv header" && docker-compose exec -T database cat teslamate.csv > teslamate.csv && tail -n +2 teslamate.csv | split -d -l 1000000 - teslamate-export- && for file in teslamate-export-*; do head -n 1 teslamate.csv > tmp_file && cat "$file" >> tmp_file && mv -f tmp_file "$file.csv" && gzip "$file.csv" && rm "$file"; done

Export from a manual non-Docker installation

In a shell, run this one-line command, substituting your username and database name:

psql -U YOUR_USER_NAME -d YOUR_DB_NAME -W -c "\copy (WITH positiondata AS(SELECT cars.vin, positions.date, positions.latitude, positions.longitude, positions.speed, positions.power, positions.odometer, positions.ideal_battery_range_km, positions.battery_level, positions.outside_temp, positions.is_climate_on, positions.inside_temp, positions.rated_battery_range_km, positions.usable_battery_level, NULL :: NUMERIC AS charge_energy_added, NULL :: NUMERIC AS charger_actual_current, NULL :: NUMERIC AS charger_phases, NULL :: NUMERIC AS charger_pilot_current, NULL :: NUMERIC AS charger_power, NULL :: NUMERIC AS charger_voltage, NULL :: BOOLEAN AS fast_charger_present, NULL AS conn_charge_cable, NULL AS fast_charger_brand, NULL AS fast_charger_type, ( SELECT B.version FROM updates B WHERE B.end_date <= positions.date AND B.car_id = positions.car_id ORDER BY B.end_date DESC LIMIT 1) AS version, Row_number() over ( PARTITION BY positions.car_id, (Cast(Extract(epoch FROM positions.date) AS INTEGER) / 10) ORDER BY positions.DATE ASC) AS rn FROM positions inner join cars ON cars.id = positions.car_id), chargingdata AS (SELECT cars.vin, charges.date, positions.latitude, positions.longitude, NULL :: SMALLINT AS speed, NULL :: SMALLINT AS power, NULL :: SMALLINT AS odometer, charges.ideal_battery_range_km, charges.battery_level, charges.outside_temp, NULL :: BOOLEAN AS is_climate_on, NULL :: NUMERIC AS inside_temp, charges.rated_battery_range_km, charges.usable_battery_level, charges.charge_energy_added, charges.charger_actual_current, charges.charger_phases, charges.charger_pilot_current, charges.charger_power, charges.charger_voltage, charges.fast_charger_present, charges.conn_charge_cable, charges.fast_charger_brand, charges.fast_charger_type, ( SELECT B.version FROM updates B WHERE B.end_date <= charges.date AND B.car_id = positions.car_id ORDER BY B.end_date DESC LIMIT 1 ) AS version, Row_number() over ( PARTITION BY charges.charging_process_id, (Cast(Extract( epoch FROM charges.date) AS INTEGER) / 10) ORDER BY charges.date ASC) AS rn FROM charges inner join charging_processes ON charging_processes.id = charges.charging_process_id inner join cars ON cars.id = charging_processes.car_id inner join positions ON positions.id = charging_processes.position_id) SELECT vin, date, latitude, longitude, speed, power, odometer, ideal_battery_range_km, battery_level, inside_temp, outside_temp, is_climate_on, rated_battery_range_km, usable_battery_level, charge_energy_added, charger_actual_current, charger_phases, charger_pilot_current, charger_power, charger_voltage, fast_charger_present, conn_charge_cable, fast_charger_brand, fast_charger_type, version FROM positiondata WHERE rn = 1 UNION SELECT vin, date, latitude, longitude, speed, power, odometer, ideal_battery_range_km, battery_level, inside_temp, outside_temp, is_climate_on, rated_battery_range_km, usable_battery_level, charge_energy_added, charger_actual_current, charger_phases, charger_pilot_current, charger_power, charger_voltage, fast_charger_present, conn_charge_cable, fast_charger_brand, fast_charger_type, version FROM chargingdata WHERE rn = 1 ORDER BY DATE ASC) TO 'teslamate.csv' csv header" && tail -n +2 teslamate.csv | split -d -l 1000000 - teslamate-export- && for file in teslamate-export-*; do head -n 1 teslamate.csv > tmp_file && cat "$file" >> tmp_file && mv -f tmp_file "$file.csv" && gzip "$file.csv" && rm "$file"; done

Tip: To run this command on Unraid, first visit Docker in the Unraid dashboard, then select the postgresql container and select Console.

Import into Tessie

Visit this page, click Import TeslaMate Export and select teslamate-export-00.csv.gz.

That's it! Tessie will process all of your data and you'll receive an email when it's done. Depending on the length of your vehicle history, this process may take several hours.

If there are additional export files, like teslamate-export-01.csv.gz, import each of these files in order.

Need more help? Contact us at support@tessie.com support@tessie.com