Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jlestel authored May 27, 2024
2 parents 69d4a49 + ddafd09 commit 62ae2b9
Show file tree
Hide file tree
Showing 14 changed files with 1,063 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:

services:
db:
image: postgres:15
image: postgres:16
ports: ["5432:5432"]
env:
POSTGRES_PASSWORD: postgres
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@

### Improvements and bug fixes

- fix: Update statistics.json: change back uid (#3907 -@DrMichael)
- feat: Update TeslaFi importer to accept newer export formats (#3431 - @ithinuel)
- feat: Upgrade PostgreSQL to v16 (#3884 -@enoch85)

#### Build, CI, internal

- ci: Upgrade PostgreSQL to v16 in elixir workflow (#3916 - @JakobLichterfeld)

#### Dashboards

#### Translations

- feat: Update default.po for Thai translation (#3906 - @tomzt)

#### Documentation

- doc: update backup path location to current directory to work around no write access to placeholder directory issue (#3908 - @JakobLichterfeld)

## [1.29.1] - 2024-05-20

same as 1.29.0 but reverted: "Dynamic endpoints and token to use official Tesla API (self-hosted or from third party provider) (#3866 - @jlestel)" as it was breaking backwards compatibility
Expand Down
2 changes: 1 addition & 1 deletion grafana/dashboards/statistics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@
},
"timezone": "browser",
"title": "Statistics",
"uid": "1EZnXszMl",
"uid": "1EZnXszMk",
"version": 2,
"weekStart": ""
}
3 changes: 3 additions & 0 deletions lib/teslamate/import.ex
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ defmodule TeslaMate.Import do

defp parse_fname(name) do
case name do
<<m::binary-size(2), y::binary-size(4), ".csv"::bitstring>> ->
parse_date(y, m)

<<"TeslaFi"::bitstring, m::binary-size(2), y::binary-size(4), ".csv"::bitstring>> ->
parse_date(y, m)

Expand Down
3 changes: 3 additions & 0 deletions lib/teslamate/import/line_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ defmodule TeslaMate.Import.LineParser do
{"id", _val} ->
Map.put(acc, "id", :rand.uniform(65536))

{"vehicle_id", ""} ->
Map.put(acc, "vehicle_id", System.get_env("TESLAFI_IMPORT_VEHICLE_ID", "1"))

{"Date", val} ->
{:ok, datetime} =
with {:error, _reason} <- Timex.parse(val, "{YYYY}-{M}-{D} {h24}:{m}:{s}"),
Expand Down
14 changes: 7 additions & 7 deletions priv/gettext/th/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ msgstr "สร้างขอบเขตทางภูมิศาสตร์
#: lib/teslamate_web/templates/layout/root.html.heex:96
#, elixir-autogen, elixir-format
msgid "Geo-Fences"
msgstr "เขตทางภูมิศาสตร์"
msgstr "ขอบเขตทางภูมิศาสตร์"

#: lib/teslamate_web/live/settings_live/index.html.heex:55
#, elixir-autogen, elixir-format
Expand Down Expand Up @@ -472,7 +472,7 @@ msgstr "ค่าใช้จ่ายการชาร์จ"
#: lib/teslamate_web/live/settings_live/index.html.heex:106
#, elixir-autogen, elixir-format
msgid "Free Supercharging"
msgstr "ฟรีซูเปอร์ชาร์จ"
msgstr "ซูเปอร์ชาร์จฟรี"

#: lib/teslamate_web/live/settings_live/index.html.heex:142
#, elixir-autogen, elixir-format
Expand Down Expand Up @@ -637,24 +637,24 @@ msgstr "แรงดันลมยาง"
#: lib/teslamate_web/live/car_live/summary.html.heex:145
#, elixir-autogen, elixir-format
msgid "Low tire pressure, check (%{tire_low}) tire"
msgstr ""
msgstr "แรงดันลมยางต่ำ ตรวจสอบยาง (%{tire_low})"

#: lib/teslamate_web/live/car_live/summary.html.heex:65
#, elixir-autogen, elixir-format
msgid "Dog Mode"
msgstr ""
msgstr "โหมดสำหรับสุนัข"

#: lib/teslamate_web/live/car_live/summary.ex:139
#, elixir-autogen, elixir-format
msgid "Dog mode is enabled"
msgstr ""
msgstr "เปิดใช้งานโหมดสำหรับสุนัขแล้ว"

#: lib/teslamate_web/live/car_live/summary.html.heex:231
#, elixir-autogen, elixir-format
msgid "Expected Finish Time"
msgstr ""
msgstr "เวลาที่คาดว่าจะเสร็จสิ้น"

#: lib/teslamate_web/live/signin_live/index.html.heex:59
#, elixir-autogen, elixir-format, fuzzy
msgid "You are using the API key (%{token}) provided by %{url}. It will allow your TeslaMate to access the official Tesla Fleet API and Tesla Telemetry streaming."
msgstr ""
msgstr ""
1,000 changes: 1,000 additions & 0 deletions test/fixtures/import/07_alternative_variant/112023.csv

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions test/teslamate/import_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,34 @@ defmodule TeslaMate.ImportTest do
assert [] = all(State)
end

@tag :capture_log
test "accepts newer teslafi format where vin and id may not be defined", %{pid: pid} do
{:ok, _pid} = start_supervised({Import, directory: "#{@dir}/07_alternative_variant"})

assert %Import.Status{files: [f], message: nil, state: :idle} = Import.get_status()

assert f == %{
complete: false,
date: [2023, 11],
path: "#{@dir}/07_alternative_variant/112023.csv"
}

with_mock Repair, trigger_run: fn -> ok_fn(:trigger_run, pid) end do
assert :ok = Import.subscribe()
assert :ok = Import.run("America/Los_Angeles")

assert_receive %Status{files: [%{complete: false}], state: :running}, 3000
assert_receive %Status{files: [%{complete: false}], state: :running}, 3000
assert_receive %Status{files: [%{complete: true}], state: :running}, 3000
assert_receive %Status{files: [%{complete: true}], state: :complete}, 3000

assert_receive :trigger_run
assert_receive :trigger_run

refute_receive _
end
end

@tag :capture_log
test "captures errors of the vehicle process", %{pid: _pid} do
{:ok, _pid} = start_supervised({Import, directory: "#{@dir}/04_error"})
Expand Down
3 changes: 2 additions & 1 deletion website/docs/configuration/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ TeslaMate accepts the following environment variables for runtime configuration:
| **IMPORT_DIR** | The path of the directory for the import of data (e.g. TeslaFi) | ./import |
| **TZ** | Used to establish the local time zone, e.g. to use the local time in logs. See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | |
| **DEFAULT_GEOFENCE** | The default GEOFENCE to send via GEOFENCE if car not in geofence. Overrides the default of "" which will delete any retained value. | "" (no quotes) |
| **TESLAFI_IMPORT_VEHICLE_ID** | The default Vehicle ID used when importing from TeslaFi. If it is not defined and the import source does not contain the data, 1 is used.
| **TESLA_API_HOST** | Hostname of the Tesla API | https://owner-api.teslamotors.com (or for chinese: https://owner-api.vn.cloud.tesla.cn) |
| **TESLA_AUTH_HOST** | Hostname of the Tesla authentication API | https://auth.tesla.com |
| **TESLA_AUTH_PATH** | The Tesla authentication path | /oauth2/v3 |
| **TESLA_WSS_HOST** | Hostname of the Tesla streaming | wss://streaming.vn.teslamotors.com (or for chinese: wss://streaming.vn.cloud.tesla.cn) |
| **TESLA_WSS_TLS_ACCEPT_INVALID_CERTS** | Accepts invalid certificates on TESLA_WSS_HOST if `true` | |
| **TESLA_WSS_USE_VIN** | Use the `vin` field instead of `vid` to connect stream if `true` | |
| **TOKEN** | Token given by a third party Tesla API provider. This `TOKEN` is added to each API request and the format must be `?token=xxxx-xxxx-xxxx` | |
| **TOKEN** | Token given by a third party Tesla API provider. This `TOKEN` is added to each API request and the format must be `?token=xxxx-xxxx-xxxx` | |
2 changes: 1 addition & 1 deletion website/docs/guides/apache.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ services:
- all

database:
image: postgres:15
image: postgres:16
restart: always
environment:
- POSTGRES_USER=${TM_DB_USER}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/guides/traefik.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ services:
- ALL

database:
image: postgres:15
image: postgres:16
restart: always
environment:
- POSTGRES_USER=${TM_DB_USER}
Expand Down
4 changes: 4 additions & 0 deletions website/docs/import/teslafi.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ sidebar_label: TeslaFi
If there is an overlap between the already existing TeslaMate and TeslaFi data, only the data prior to the first TeslaMate data will be imported.
:::

:::note
If the CSV files are missing the vehicle ID, the imported will default to `1`. You can alter this behavior by setting the environment variable `TESLAFI_IMPORT_VEHICLE_ID`.
:::

:::note
Since the exported CSV files do not contain addresses, they are added automatically during and after the import. So please note that not all addresses are visible immediately after the import/restarting. Depending on the amount of data imported, it may take a while before they appear. The same applies to elevation data.
:::
2 changes: 1 addition & 1 deletion website/docs/installation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This setup is recommended only if you are running TeslaMate **on your home netwo
- all

database:
image: postgres:15
image: postgres:16
restart: always
environment:
- POSTGRES_USER=teslamate
Expand Down
2 changes: 1 addition & 1 deletion website/docs/maintenance/backup_restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ If you are using `docker-compose`, you are using Docker Compose v1, which has be
Create backup file `teslamate.bck`:

```bash
docker compose exec -T database pg_dump -U teslamate teslamate > /backuplocation/teslamate.bck
docker compose exec -T database pg_dump -U teslamate teslamate > ./teslamate.bck
```

:::note
Expand Down

0 comments on commit 62ae2b9

Please sign in to comment.