Compare commits

...
20 Commits
Author SHA1 Message Date
renovate[bot] 1c521e808c Update TeslaMate to v2.1.1 (#100)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-05 09:34:41 +01:00
renovate[bot] 0d7507b3d9 Update actions/checkout action to v5 (#98)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-11 14:56:40 +01:00
renovate[bot] d8aa9cb7d9 Update actions/checkout action to v4.3.0 (#97)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-11 14:53:25 +01:00
renovate[bot] 2dfda5bbc0 Update docker/login-action action to v3.5.0 (#96)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-04 16:43:20 +01:00
renovate[bot] 522e9890ca Update TeslaMate to v2.1.0 (#94)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-21 16:19:45 +01:00
Colin Seymour 453252d864 Only set file limit to a max of 524288 (#93) 2025-07-07 09:14:42 +01:00
renovate[bot]andColin Seymour 800d3ee3ab Update TeslaMate to v2 (#85)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Colin Seymour <colin@symr.io>
2025-07-06 09:22:01 +01:00
Colin Seymour 562fd279b0 Prep for TeslaMate v2 update (#91)
* Prep docs for v2

* Add pg version check

* Import dashboards after DB

* Assume compatible

* Emphasis version

* Use 2 spaces for ident

* Improve logging
2025-07-06 09:13:44 +01:00
renovate[bot] 9d0729c9bf Update softprops/action-gh-release action to v2.3.2 (#90) 2025-06-11 08:49:21 +01:00
renovate[bot] e3a352b44d Update softprops/action-gh-release action to v2.3.0 (#89) 2025-06-10 07:53:17 +01:00
renovate[bot] fc5f6d6c2d Update softprops/action-gh-release action to v2.2.2 (#84) 2025-04-19 07:11:51 +01:00
renovate[bot] db77437898 Update TeslaMate to v1.33.0 (#83)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-29 09:39:46 +00:00
Colin Seymour 111527b4b6 Document migrating to a different PostgresSQL server and restoring teslamate.bak backups (#82)
* Add migrate and restore steps

* Link to TM backup docs

* Fix link and addon
2025-03-21 15:57:14 +00:00
renovate[bot] df2f87600b Update home-assistant/builder action to v2025.03.0 (#81)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-20 14:50:58 +00:00
Colin Seymour 4bc610e9a7 Update config to enable hassio_api access and improve TeslaMate settings message (#79)
* Addon needs hassio API access

* Fix TeslaMate config behaviour
2025-03-19 12:37:16 +00:00
Colin Seymour 48cc287c98 Update devcontainer config (#78) 2025-03-19 11:27:08 +00:00
Colin Seymour 04eb3228bd Use a PostgreSQL version agnostic method of determining if the database exists (#77)
Use PG version agnostic method to find DB
2025-03-19 11:19:28 +00:00
renovate[bot] a5180bcb8e Update docker/login-action action to v3.4.0 (#74)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-14 11:05:24 +00:00
renovate[bot] f2d6fcd514 Update home-assistant/builder action to v2025 (#72)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-25 16:56:17 +00:00
Colin Seymour 540732b90a Document additional TeslaMate configuration changes (#68)
* Add TeslaMate cfg helper message to log

* Add TeslaMate config details
2025-02-02 09:48:15 +00:00
10 changed files with 265 additions and 105 deletions
+6 -3
View File
@@ -1,8 +1,8 @@
{ {
"name": "HA Addon: TeslaMate", "name": "HA Addon: TeslaMate",
"image": "ghcr.io/home-assistant/devcontainer:addons", "image": "ghcr.io/home-assistant/devcontainer:2-addons",
"appPort": ["7123:8123", "7357:4357"], "appPort": ["7123:8123", "7357:4357"],
"postStartCommand": "sudo sed -i 's/export SUPERVISOR_VERSION=.*/export SUPERVISOR_VERSION=2024.03.1.dev1803/' /etc/supervisor_scripts/common && bash devcontainer_bootstrap", // Workaround until https://github.com/home-assistant/supervisor/issues/5021 is fixed" "postStartCommand": "bash devcontainer_bootstrap",
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"], "runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
"containerEnv": { "containerEnv": {
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
@@ -27,5 +27,8 @@
} }
} }
}, },
"mounts": ["type=volume,target=/var/lib/docker"] "mounts": [
"type=volume,target=/var/lib/docker",
"type=volume,target=/mnt/supervisor"
]
} }
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: ⤵️ Check out code from GitHub - name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4.2.2 uses: actions/checkout@v5.0.0
- name: 🚀 Run Home Assistant Add-on Lint - name: 🚀 Run Home Assistant Add-on Lint
uses: frenck/action-addon-linter@v2 uses: frenck/action-addon-linter@v2
+3 -3
View File
@@ -23,7 +23,7 @@ jobs:
steps: steps:
- name: Checkout the repository - name: Checkout the repository
uses: actions/checkout@v4.2.2 uses: actions/checkout@v5.0.0
- name: Get version - name: Get version
run: | run: |
@@ -35,14 +35,14 @@ jobs:
fi fi
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v3.3.0 uses: docker/login-action@v3.5.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish - name: Build and publish
uses: home-assistant/builder@2024.08.2 uses: home-assistant/builder@2025.03.0
with: with:
args: | args: |
--${{ matrix.arch }} \ --${{ matrix.arch }} \
+3 -3
View File
@@ -19,7 +19,7 @@ jobs:
packages: write packages: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v5
with: with:
path: teslamate path: teslamate
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -52,7 +52,7 @@ jobs:
git push --tags git push --tags
working-directory: ${{ github.workspace }}/teslamate working-directory: ${{ github.workspace }}/teslamate
- name: Create release - name: Create release
uses: softprops/action-gh-release@v2.2.1 uses: softprops/action-gh-release@v2.3.2
with: with:
tag_name: v${{ steps.semver.outputs.semver }} tag_name: v${{ steps.semver.outputs.semver }}
body_path: CHANGELOG.txt body_path: CHANGELOG.txt
@@ -61,7 +61,7 @@ jobs:
prerelease: false prerelease: false
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout addon repo - name: Checkout addon repo
uses: actions/checkout@v4.2.2 uses: actions/checkout@v5.0.0
with: with:
path: repo path: repo
repository: lildude/ha-addons repository: lildude/ha-addons
+2 -2
View File
@@ -32,10 +32,10 @@ jobs:
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v4.2.2 uses: actions/checkout@v5.0.0
- name: Build add-on - name: Build add-on
uses: home-assistant/builder@2024.08.2 uses: home-assistant/builder@2025.03.0
with: with:
args: | args: |
--test \ --test \
+106 -2
View File
@@ -7,7 +7,7 @@ A self-hosted data logger for your Tesla 🚘
[TeslaMate][teslamate] is a powerful, self-hosted data logger for your Tesla. [TeslaMate][teslamate] is a powerful, self-hosted data logger for your Tesla.
- Written in **[Elixir][elixir]** - Written in **[Elixir][elixir]**
- Data is stored in a **Postgres** database - Data is stored in a **PostgreSQL** database
- Visualization and data analysis with **Grafana** - Visualization and data analysis with **Grafana**
- Vehicle data is published to a local **MQTT** Broker - Vehicle data is published to a local **MQTT** Broker
@@ -16,6 +16,7 @@ This add-on allows you to run [TeslaMate][teslamate] on your Home Assistant serv
## Configuration ## Configuration
The configuration is self-explanatory, but essentially we need details about accessing the PostgreSQL database, Grafana and optionally MQTT. The configuration is self-explanatory, but essentially we need details about accessing the PostgreSQL database, Grafana and optionally MQTT.
You will also need to configure TeslaMate (see "TeslaMate Configuration" below) so the links to TeslaMate in the Grafana dashboards work.
### Options ### Options
@@ -107,7 +108,7 @@ Once you have Grafana up and running, you'll need to configure a data source to
‼️ **Note**: The name must be `TeslaMate` as all the dashboards expect the datasource to use this name. ‼️ **Note**: The name must be `TeslaMate` as all the dashboards expect the datasource to use this name.
![Grafana Postgres data source][grafana-datasource] ![Grafana PostgreSQL data source][grafana-datasource]
#### Other Options #### Other Options
@@ -126,6 +127,94 @@ Once you have Grafana up and running, you'll need to configure a data source to
Note: These will also overwrite any environment variable set using the configuration options above. Note: These will also overwrite any environment variable set using the configuration options above.
## TeslaMate Configuration
In order for the links in the Grafana dashboards and the TeslaMate UI to link to the correct locations, you will also need to configure TeslaMate.
Once you have started the add-on, look at the log output for the section which looks like this and take note of the two lines with `=>`:
```
[09:26:32] INFO: Configure TeslaMate settings by adding these values
to the URL you use to access your Home Assistant instance:
=> Web App: /api/hassio_ingress/ljiIc6sOVGOSQfTRjscvLVJJS5Rxp33gsdEtf9y3oQY
=> Dashboards: /api/hassio_ingress/G9ocwA44wt9Bcba8LvP8tDhlfFiFnnPftOZBwp-Pgzs
```
From the add-on Info tab, click "Open Web UI", enter the Tesla API access and refresh tokens if you haven't already, and then go to TeslaMate's Settings.
Scroll to the very bottom and set each of the URLs to the URL you use to access your Home Assistant instance with each of the above appended.
For example, if you access your Home Assistant instance at `https://ha.example.com`, set each as follows:
- Web App: `https://ha.example.com/api/hassio_ingress/ljiIc6sOVGOSQfTRjscvLVJJS5Rxp33gsdEtf9y3oQY`
- Dashboards: `https://ha.example.com/api/hassio_ingress/G9ocwA44wt9Bcba8LvP8tDhlfFiFnnPftOZBwp-Pgzs`
Do _not_ use these values. Use the values from your log output.
## Migrate TeslaMate to a Different PostgreSQL Server
In order to migrate TeslaMate to a different PostgreSQL server, you will need to make a backup of the original data and then restore it to the destination server.
This isn't much of a challenge for the seasoned sysadmin familiar with Docker, PostgreSQL and the command line, however most Home Assistant users aren't expert sysadmins so this guide if for you.
1. Ensure you have both the current and new PostgreSQL servers installed and running and ensure you have the same users and roles configured on both.
2. Stop the TeslaMate add-on.
3. Install the [pgAdmin4](https://github.com/expaso/hassos-addons) add-on.
4. Start the pgAdmin4 add-on and open the web UI
5. Make a new connection to the current PostgreSQL server by clicking "Add New Server".
1. Give it a recognisable name in the General tab.
2. Switch to the Connection tab and enter the hostname, port, username and password currently used.
You can find these in your TeslaMate add-on configuration.
3. Click Save
6. Click the dropdown next to the new server -> Databases and then select the database you use for TeslaMate.
This will be the same name you configured in the TeslaMate add-on configuration.
7. Go to Tools -> Backup, enter a filename, if you know what you're doing feel free to make other customisations but it's not essential, and then click Backup. [^1]
8. Once the backup has finished, repeats step 5 for your new PostgreSQL server to establish a connection to your new PostgreSQL server.
9. Select the new server, if not already selected, and go to Object -> Create -> Database and enter the same name and owner as used on your old server and click Save.
10. If the database is not already selected, select it and then go to Tools -> Restore, enter the filename you entered in step 7 and click Restore.
You may need to use the file browser to locate the file. If you didn't change the path in step 7, the backup should be in `/root/`.
11. Once the restore has completed, go to the TeslaMate add-on settings and update the database settings to point to your new database server.
The easiest approach is to use the steps in [Migrating to this version of the add-on][migrate-addon] further down in this file and change the `database_host` to the name of your new PostgreSQL server.
12. Update the Grafana configuration by going to the Grafana add-on -> Open web UI -> Grafana logo in top left -> Connections -> Datasources, select the TeslaMate source and change the Host URL to your new PostgreSQL server and click "Save & test".
13. Start the TeslaMate add-on and verifying everything is working as it was before. [^2]
You can now uninstall the pgAdmin4 add-on if you want and stop and uninstall your old PostgreSQL server if you're not using it for anything else.
## Import TeslaMate Backup
If you have made a backup of a TeslaMate installation as per the [TeslaMate backup documentation][teslamate-backup] and now have a `teslamate.bak` file you want to use with this add-on, you can do so as follows:
1. Install this TeslaMate add-on if you haven't already, but don't start it.
2. Install a PostgreSQL server and start it if you haven't already.
We recommend the [PostgreSQL 17 add-on][alexbelgium-postgres] from @alexbelgium's repository, or [TimescaleDB][timescaledb] (for advanced users).
3. Perform steps 3, 4 and 5 from [Migrate TeslaMate to a Different PostreSQL Server][migrate-psql] above.
4. Transfer the `teslamate.bck` file to the `/share/teslamate` folder on your Home Assistant instance.
You can do this using the [Samba][samba-addon] or [SSH][ssh-addon] add-ons.
5. Perform steps 9 and 10 from [Migrate TeslaMate to a Different PostreSQL Server][migrate-psql] above.
Note: the file location will be `/share/teslamate/teslamate.bck`.
6. Configure TeslaMate and Grafana as per the details at the top of this file.
7. Start TeslaMate.
## Data Import from TeslaFi ## Data Import from TeslaFi
It is now possible to import CSV data from TeslaFi, refer to the [official docs][teslafi-import]. It is now possible to import CSV data from TeslaFi, refer to the [official docs][teslafi-import].
@@ -143,12 +232,27 @@ Follow this process:
5. Once imported sucessfully, delete the CSV files to avoid the import screen being presented. 5. Once imported sucessfully, delete the CSV files to avoid the import screen being presented.
[alexbelgium-postgres]: https://github.com/alexbelgium/hassio-addons/tree/master/postgres_17
[docker]: https://hub.docker.com/r/teslamate/teslamate [docker]: https://hub.docker.com/r/teslamate/teslamate
[elixir]: https://elixir-lang.org/ [elixir]: https://elixir-lang.org/
[grafana-addon]: https://github.com/hassio-addons/addon-grafana [grafana-addon]: https://github.com/hassio-addons/addon-grafana
[grafana-datasource]: https://raw.githubusercontent.com/lildude/ha-addon-teslamate/main/imgs/grafana-postgres.png [grafana-datasource]: https://raw.githubusercontent.com/lildude/ha-addon-teslamate/main/imgs/grafana-postgres.png
[migrate-psql]: #migrate-teslamate-to-a-different-postresql-server
[migrate-addon]: https://github.com/lildude/ha-addon-teslamate/blob/main/README.md#migrating-to-this-version-of-the-add-on
[mosquitto-docs]: https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md [mosquitto-docs]: https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md
[pgadmin4]: https://github.com/expaso/hassos-addons
[samba-addon]: https://github.com/home-assistant/addons/blob/master/samba/DOCS.md [samba-addon]: https://github.com/home-assistant/addons/blob/master/samba/DOCS.md
[ssh-addon]: https://github.com/home-assistant/addons/blob/master/ssh/DOCS.md [ssh-addon]: https://github.com/home-assistant/addons/blob/master/ssh/DOCS.md
[teslafi-import]: https://docs.teslamate.org/docs/import/teslafi [teslafi-import]: https://docs.teslamate.org/docs/import/teslafi
[teslamate]: https://github.com/teslamate-org/teslamate/ [teslamate]: https://github.com/teslamate-org/teslamate/
[teslamate-backup]: https://docs.teslamate.org/docs/maintenance/backup_restore/#backup
[timescaledb]: https://github.com/expaso/hassos-addon-timescaledb
[^1]:
If the backup or restore fails due to a `server version mismatch` error, you will need to select the latest version of PostgreSQL in pgAdmin4 by going to File -> Paths -> Binary paths and add the correct path for each version.
For example, for PostgreSQL 14, enter `/usr/local/pgsql-14`, for PostgreSQL 15, enter `/usr/local/pgsql-15` etc.
[^2]:
If you see the `ERROR: type "earth" does not exist at character` error in the TeslaMate log, you can fix this by going back into pgAdmin4 and right click on the TeslaMate database -> "CREATE script".
Delete everything auto generated and paste in the [codeblock here](https://github.com/diogob/activerecord-postgres-earthdistance/issues/30#issuecomment-2122829036).
Click "Execute script" (It's the ▶️ symbol at the top).
+13 -4
View File
@@ -7,7 +7,7 @@ A self-hosted data logger for your Tesla 🚘
[TeslaMate][teslamate] is a powerful, self-hosted data logger for your Tesla. [TeslaMate][teslamate] is a powerful, self-hosted data logger for your Tesla.
- Written in **[Elixir][elixir]** - Written in **[Elixir][elixir]**
- Data is stored in a **Postgres** database - Data is stored in a **PostgreSQL** database
- Visualization and data analysis with **Grafana** - Visualization and data analysis with **Grafana**
- Vehicle data is published to a local **MQTT** Broker - Vehicle data is published to a local **MQTT** Broker
@@ -24,8 +24,8 @@ Thanks to @matt-FFFFFF for maintaining this add-on in the past.
## Requirements ## Requirements
TeslaMate needs a PostgreSQL database. **TeslaMate v2 needs a PostgreSQL 16.7 or 17.3 or later database.**
I recommend using the [PostgreSQL add-on][alexbelgium-postgres] from @alexbelgium's repository if you aren't already using Postgres. I recommend using the [PostgreSQL 17 add-on][alexbelgium-postgres] from @alexbelgium's repository, or [TimescaleDB][timescaledb] (for advanced users), if you aren't already using PostgreSQL.
To get the full experience, it is recommended that you also install the community [Grafana add-on][grafana-addon] and [MQTT integration][mqtt]. To get the full experience, it is recommended that you also install the community [Grafana add-on][grafana-addon] and [MQTT integration][mqtt].
@@ -46,6 +46,13 @@ To get the full experience, it is recommended that you also install the communit
1. Check the logs of the add-on to see if everything went well. 1. Check the logs of the add-on to see if everything went well.
1. Click the `OPEN WEB UI` button to open TeslaMate. 1. Click the `OPEN WEB UI` button to open TeslaMate.
## Upgrading this add-on from v1 to v2
TeslaMate v2 introduced a hard requirement on the version of PostgreSQL database.
**You will need to use PostgreSQL 16.7 or 17.3 or later.**
If you are currently using an earlier version of PostgreSQL, you will need to backup your TeslaMate data, upgrade the database, and then restore the data.
You can find details on how to do this in the "_Migrate TeslaMate to a Different Postres Server_" section of this add-on's documentation tab or in the [DOCS.md][docs-md] file in the add-on repository.
## Migrating to this version of the add-on ## Migrating to this version of the add-on
Migrating to this version of the add-on should not result in any loss of data, but you can never be too careful, so I recommend you take a full backup of your Home Assistant instance and also a direct backup of the TeslaMate database as detailed in the [TeslaMate documentation][teslamate-backup] before proceeding. Migrating to this version of the add-on should not result in any loss of data, but you can never be too careful, so I recommend you take a full backup of your Home Assistant instance and also a direct backup of the TeslaMate database as detailed in the [TeslaMate documentation][teslamate-backup] before proceeding.
@@ -67,9 +74,10 @@ Everything should pick up where it was before.
[addon]: https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Flildude%2Fha-addons [addon]: https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Flildude%2Fha-addons
[addons-repo]: https://github.com/lildude/ha-addons [addons-repo]: https://github.com/lildude/ha-addons
[alexbelgium-postgres]: https://github.com/alexbelgium/hassio-addons/tree/master/postgres [alexbelgium-postgres]: https://github.com/alexbelgium/hassio-addons/tree/master/postgres_17
[archs]: https://img.shields.io/badge/dynamic/json?color=green&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Flildude%2Fha-addon-teslamate%2Fmain%2Fconfig.json [archs]: https://img.shields.io/badge/dynamic/json?color=green&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Flildude%2Fha-addon-teslamate%2Fmain%2Fconfig.json
[docker]: https://hub.docker.com/r/teslamate/teslamate [docker]: https://hub.docker.com/r/teslamate/teslamate
[docs-md]: https://github.com/lildude/ha-addon-teslamate/blob/main/DOCS.md#migrate-teslamate-to-a-different-postgresql-server
[elixir]: https://elixir-lang.org/ [elixir]: https://elixir-lang.org/
[grafana-addon]: https://github.com/hassio-addons/addon-grafana [grafana-addon]: https://github.com/hassio-addons/addon-grafana
[ingres-badge]: https://img.shields.io/badge/dynamic/json?label=Ingress&query=%24.ingress&url=https%3A%2F%2Fraw.githubusercontent.com%2Flildude%2Fha-addon-teslamate%2Fmain%2Fconfig.json [ingres-badge]: https://img.shields.io/badge/dynamic/json?label=Ingress&query=%24.ingress&url=https%3A%2F%2Fraw.githubusercontent.com%2Flildude%2Fha-addon-teslamate%2Fmain%2Fconfig.json
@@ -79,3 +87,4 @@ Everything should pick up where it was before.
[teslamate-backup]: https://docs.teslamate.org/docs/maintenance/backup_restore [teslamate-backup]: https://docs.teslamate.org/docs/maintenance/backup_restore
[teslamate-version]: https://img.shields.io/badge/dynamic/json?label=TeslaMate%20Version&url=https%3A%2F%2Fraw.githubusercontent.com%2Flildude%2Fha-addon-teslamate%2Fmain%2Fbuild.json&query=%24.args.teslamate_version [teslamate-version]: https://img.shields.io/badge/dynamic/json?label=TeslaMate%20Version&url=https%3A%2F%2Fraw.githubusercontent.com%2Flildude%2Fha-addon-teslamate%2Fmain%2Fbuild.json&query=%24.args.teslamate_version
[teslamate]: https://github.com/teslamate-org/teslamate/ [teslamate]: https://github.com/teslamate-org/teslamate/
[timescaledb]: https://github.com/expaso/hassos-addon-timescaledb
+4 -4
View File
@@ -1,11 +1,11 @@
{ {
"build_from": { "build_from": {
"aarch64": "teslamate/teslamate:1.32.0", "aarch64": "teslamate/teslamate:2.1.1",
"amd64": "teslamate/teslamate:1.32.0", "amd64": "teslamate/teslamate:2.1.1",
"armv7": "teslamate/teslamate:1.32.0" "armv7": "teslamate/teslamate:2.1.1"
}, },
"args": { "args": {
"teslamate_version": "1.32.0" "teslamate_version": "2.1.1"
}, },
"codenotary": { "codenotary": {
"signer": "colin@symr.io" "signer": "colin@symr.io"
+5 -2
View File
@@ -9,6 +9,7 @@
"aarch64", "aarch64",
"amd64" "amd64"
], ],
"hassio_api": true,
"ingress": true, "ingress": true,
"init": false, "init": false,
"panel_icon": "mdi:car-connected", "panel_icon": "mdi:car-connected",
@@ -63,10 +64,12 @@
"import_dir": "str", "import_dir": "str",
"default_geofence": "str?", "default_geofence": "str?",
"encryption_key": "password?", "encryption_key": "password?",
"env_vars": [{ "env_vars": [
{
"name": "str?", "name": "str?",
"value": "str?" "value": "str?"
}] }
]
}, },
"map": [ "map": [
"share:rw" "share:rw"
+49 -8
View File
@@ -52,16 +52,32 @@ for env_var in $(bashio::config 'env_vars|keys'); do
export "${name}=${value}" export "${name}=${value}"
done done
# Import dashboards
if bashio::config.true 'grafana_import_dashboards'; then
/dashboards.sh restore || bashio::log.error "Failed to import dashboards"
fi
# Create the PostgreSQL database if it doesn't exist # Create the PostgreSQL database if it doesn't exist
bashio::log.info "Checking for database '$DATABASE_NAME' on $DATABASE_HOST"
if pg_isready -h "$DATABASE_HOST" -p "$DATABASE_PORT" > /dev/null 2>&1; then if pg_isready -h "$DATABASE_HOST" -p "$DATABASE_PORT" > /dev/null 2>&1; then
bashio::log.info "Creating database '$DATABASE_NAME' on $DATABASE_HOST" # Check the version of PostgreSQL database is v16.7 or later or v17.3 or later
pg_version=$(PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" postgres -Atqc "SELECT regexp_replace(version(), 'PostgreSQL ([^ ]+) .*', '\\1') AS version")
major_version=$(echo "$pg_version" | cut -d '.' -f 1)
minor_version=$(echo "$pg_version" | cut -d '.' -f 2)
compat=true
case "$major_version" in
16)
[[ "$minor_version" -lt 7 ]] && compat=false
;;
17)
[[ "$minor_version" -lt 3 ]] && compat=false
;;
*)
[[ "$major_version" -lt 16 ]] && compat=false
;;
esac
if [[ -n $(PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" postgres -Atqc "\list \"$DATABASE_NAME\"") ]]; then if [ $compat = false ]; then
bashio::log.error "PostgreSQL version $pg_version is not supported. Please upgrade to v16.7 or later or v17.3 or later."
exit 1
fi
if [[ -n $(PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" postgres -Atqc "SELECT datname FROM pg_database WHERE datname = '$DATABASE_NAME'") ]]; then
bashio::log.info "Database $DATABASE_NAME already exists" bashio::log.info "Database $DATABASE_NAME already exists"
else else
if PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" postgres -qc "CREATE DATABASE \"$DATABASE_NAME\""; then if PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" postgres -qc "CREATE DATABASE \"$DATABASE_NAME\""; then
@@ -76,7 +92,32 @@ else
exit 1 exit 1
fi fi
ulimit -n 1048576 # Import dashboards
if bashio::config.true 'grafana_import_dashboards'; then
bashio::log.info "Importing Grafana dashboards..."
/dashboards.sh restore || bashio::log.error "Failed to import dashboards"
fi
if [[ -z $(PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" "$DATABASE_NAME" -Atqc "SELECT 1 FROM settings WHERE base_url LIKE '%api/hassio_ingress%'" 2> /dev/null ) ]]; then
teslamate_ingress=$(bashio::addon.ingress_entry)
grafana_ingress=$(bashio::addon.ingress_entry "$(bashio::supervisor.addons | grep grafana)")
if [[ "$teslamate_ingress" == "$grafana_ingress" ]]; then
grafana_ingress="** Grafana addon not found. Ensure the addon is installed and running. **"
fi
bashio::log.notice ""
bashio::log.notice "Configure TeslaMate settings by adding these values"
bashio::log.notice "to the URL you use to access your Home Assistant instance:"
bashio::log.notice ""
bashio::log.notice "=> Web App: $teslamate_ingress"
bashio::log.notice "=> Dashboards: $grafana_ingress"
bashio::log.notice ""
fi
# Set max open file limit to avoid memory allocation issues
if [ "$(ulimit -Hn)" -gt 524288 ]; then
ulimit -n 524288
fi
bashio::log.info "Starting TeslaMate..." bashio::log.info "Starting TeslaMate..."