mirror of
https://github.com/lildude/ha-addon-teslamate.git
synced 2026-10-13 21:19:16 -04:00
Update, refactor and restructure repo (#1)
* Remove unused files * Update dev env * Update config * Update docker config * Add translations * Update run script * Auto-gen enc key if not set * Replace workflows * Replace dependabot with renovate * Remove armhf * Lint * Remove armhf * Whoops * Remove stray comma * Add image * Reorder options * Split and improve docs * Add back image line * Update cw * Typo * Use correct org * Move bootstrap to run * Update scripts * Update config * Add note about database * Label in dockerfile * tmp force devcontainer version * Start implementing db creation if not exists * Create DB if doesn't exist * Update words * Remove unused file
This commit is contained in:
@@ -1,136 +1,60 @@
|
||||
# TeslaMate Addon for Home Assistant
|
||||
# Home Assistant Add-on: TeslaMate
|
||||
|
||||
🔔 Note this project is looking for a new maintainer: https://github.com/matt-FFFFFF/hassio-addon-teslamate/issues/124
|
||||
A self-hosted data logger for your Tesla 🚘
|
||||
|
||||
This addon builds on the excellent work of [Adrian Kumpf](https://github.com/adriankumpf/teslamate). See his repo for information regarding the TeslaMate application.
|
||||
## About
|
||||
|
||||
This addon is part of [my Home Assistant addon repo](https://github.com/matt-FFFFFF/hassio-addon-repository) - see link for instructions on how to add to Home Assistant.
|
||||
[TeslaMate][teslamate] is a powerful, self-hosted data logger for your Tesla.
|
||||
|
||||
- Written in **[Elixir][elixir]**
|
||||
- Data is stored in a **Postgres** database
|
||||
- Visualization and data analysis with **Grafana**
|
||||
- Vehicle data is published to a local **MQTT** Broker
|
||||
|
||||
This addon allows you to run [TeslaMate][teslamate] on your Home Assistant server based on the the official TeslaMate [docker image][docker].
|
||||
|
||||
[![Sponsor me to maintain this addon][sponsor-badge]](https://github.com/sponsors/lildude)
|
||||
|
||||
![TeslaMate Version][teslamate-version]
|
||||
![Ingress][ingres-badge]
|
||||
![Supported Architectures][archs]
|
||||
|
||||
## Requirements
|
||||
|
||||
TeslaMate needs a PostgreSQL database.
|
||||
All development and testing has been done using [PostgreSQL add-on][postgres] for convenience but you're welcome to use your own.
|
||||
|
||||
For convenience, my [add-ons repository][addons-repo] includes configuration that points to the [PostgreSQL add-on][postgres] so you can install everything from one repo.
|
||||
|
||||
To get the full experience, it is recommended that you also install the community [Grafana add-on][grafana-addon] and [MQTT integration][mqtt].
|
||||
|
||||
## Installation
|
||||
|
||||
1. Add [my repository](https://github.com/matt-FFFFFF/hassio-addon-repository) to Home Assistant. See [installing third party addons](https://www.home-assistant.io/hassio/installing_third_party_addons/) from the Home Assistant documentation.
|
||||
2. Add the `TeslaMate` and the `PostgreSQL` addons from my repo and the `Grafana` addon from the community repo.
|
||||
3. Before starting Postgres, [configure](https://github.com/matt-FFFFFF/hassio-addon-postgres/blob/main/README.md) the addon by setting the DB name, username and password. Now you can start it up.
|
||||
1. Add my [add-ons repository][addons-repo] to Home Assistant or click the button below to open my add-on repository on your Home Assistant instance.
|
||||
|
||||
### Tesla API Token Encryption Key
|
||||
[![Open add-on repo on your Home Assistant instance][repo-btn]][addon]
|
||||
|
||||
To ensure that the Tesla API tokens are stored securely, an encryption key must be provided via the ENCRYPTION_KEY environment variable.
|
||||
This is set in the addon configuration, using the `encryption_key` configuration item.
|
||||
1. Install this add-on.
|
||||
1. Install the PostgreSQL add-on and configure and start it, if you wish to use this add-on. The database name isn't important here as the TeslaMate addon will create the database you name in the settings if it doesn't exist.
|
||||
1. Configure Grafana as detailed in this addon's documentation.
|
||||
1. Enter your PostgreSQL configuration information.
|
||||
1. Enter your Grafana configuration information.
|
||||
1. Enter your MQTT configuration information.
|
||||
1. Click the `Save` button to store your configuration.
|
||||
1. Start the add-on.
|
||||
1. Check the logs of the add-on to see if everything went well.
|
||||
1. Click the `OPEN WEB UI` button to open TeslaMate.
|
||||
|
||||
**A default has been provided but it is highly recommended to change this!**
|
||||
|
||||
### DB Connection
|
||||
|
||||
If using the Postgres addon from my addon repo, the database host is `29b65938-postgres`.
|
||||
Below is a snippit from the TeslaMate addon configuration, just replace the DB name, username and password on the `Configuration` tab of the addon before starting it and you will be good to go.
|
||||
|
||||
```yaml
|
||||
database_user: username
|
||||
database_pass: password
|
||||
database_name: databasename
|
||||
database_host: 29b65938-postgres
|
||||
database_ssl: false
|
||||
database_port: 5432
|
||||
```
|
||||
|
||||
### MQTT Configuration
|
||||
|
||||
You **must** have a username and password defined for your MQTT user, do not use the HA local login (thanks [quach128](https://github.com/quach128)). Below is a sample configuration using the Mosquitto MQTT addon available in the Home Assistant core addon repo:
|
||||
|
||||
```yaml
|
||||
disable_mqtt: false
|
||||
mqtt_host: core-mosquitto
|
||||
mqtt_user: mymqttuser
|
||||
mqtt_pass: mymqtttpass
|
||||
mqtt_tls: false
|
||||
mqtt_tls_accept_invalid_certs: true
|
||||
```
|
||||
|
||||
#### Mosquitto access control list
|
||||
|
||||
You must specify an access control list entry for the teslamate user, for example:
|
||||
|
||||
```text
|
||||
user teslamate
|
||||
topic readwrite teslamate/#
|
||||
```
|
||||
|
||||
See the [official docs](https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md) on how to configure access control with Mosquitto
|
||||
|
||||
### Grafana Configuration
|
||||
|
||||
I recommend you use the existing Grafana addon from the community addons, if you do, please enable the following plugins in your yaml configurations, e.g.
|
||||
|
||||
```yaml
|
||||
plugins:
|
||||
- natel-discrete-panel
|
||||
- natel-plotly-panel
|
||||
- pr0ps-trackmap-panel
|
||||
- grafana-piechart-panel
|
||||
custom_plugins:
|
||||
- name: panodata-map-panel
|
||||
url: https://github.com/panodata/panodata-map-panel/releases/download/0.16.0/panodata-map-panel-0.16.0.zip
|
||||
unsigned: true
|
||||
custom_plugins: []
|
||||
env_vars:
|
||||
- name: GF_SECURITY_ADMIN_USER
|
||||
value: <youruser>
|
||||
- name: GF_SECURITY_ADMIN_PASSWORD
|
||||
value: <yourpass>
|
||||
ssl: true # optional if you are using TLS
|
||||
certfile: fullchain.pem # optional if you are using TLS
|
||||
keyfile: privkey.pem # optional if you are using TLS
|
||||
```
|
||||
|
||||
> Note that the security admin password and usernames can only be set on the first start of the Grafana addon, so if you already have it configured you'll need to remove it and re-add it.
|
||||
|
||||
#### Data Source
|
||||
|
||||
Configure a PostgreSQL data source as follows:
|
||||
|
||||

|
||||
|
||||
#### Automatically Uploading Grafana Dashboards
|
||||
|
||||
Without this step you won't be able to use the TeslaMate dashboards, so this is recommended.
|
||||
|
||||
Configure the `Grafana` addon and set the admin username and password - we will need this to upload the dashboards:
|
||||
|
||||
> Important! These environment variables are only parsed on the initial set up of Grafana.
|
||||
> If you already have the addon configured you'll need to remove it and re-add, setting this configuration for the initial start-up.
|
||||
|
||||
```yaml
|
||||
env_vars:
|
||||
- name: GF_SECURITY_ADMIN_USER
|
||||
value: admin
|
||||
- name: GF_SECURITY_ADMIN_PASSWORD
|
||||
value: mysecretpassword
|
||||
```
|
||||
|
||||
Now configure the `Teslamate` addon:
|
||||
|
||||
```yaml
|
||||
grafana_import_dashboards: true
|
||||
grafana_folder_name: TeslaMate
|
||||
grafana_host: a0d7b954-grafana # this is correct if you use the community addon
|
||||
grafana_port: 3000 # this is correct if you use the community addon
|
||||
grafana_user: admin
|
||||
grafana_pass: mysecretpassword
|
||||
```
|
||||
|
||||
## Data Import from TeslaFi
|
||||
|
||||
It is now possible to import CSV data from TeslaFi, refer to the [official docs](https://docs.teslamate.org/docs/import/teslafi).
|
||||
|
||||
Follow this process:
|
||||
|
||||
1. Copy the CSV data to the `/share/teslamate` folder on your Home Assistant instance.
|
||||
You can do this using the [Samba](https://github.com/home-assistant/addons/blob/master/samba/DOCS.md) or [SSH](https://github.com/home-assistant/addons/blob/master/ssh/DOCS.md) addons.
|
||||
|
||||
2. Make sure the `import_path` configuration setting is set to `/share/teslamate`.
|
||||
|
||||
3. Restart the TeslaMate addon and navigate to the web UI, you should be presented with the import screen.
|
||||
|
||||
4. Import the data
|
||||
|
||||
5. Once imported sucessfully, delete the CSV files to avoid the import screen being presented.
|
||||
[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
|
||||
[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
|
||||
[elixir]: https://elixir-lang.org/
|
||||
[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
|
||||
[mqtt]: https://www.home-assistant.io/integrations/mqtt
|
||||
[postgres]: https://github.com/matt-FFFFFF/hassio-addon-postgres
|
||||
[repo-btn]: https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg
|
||||
[sponsor-badge]: https://img.shields.io/badge/Sponsor_Me-%E2%9D%A4-ec6cb9?logo=GitHub
|
||||
[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/
|
||||
|
||||
Reference in New Issue
Block a user