Compare commits

..
6 Commits
Author SHA1 Message Date
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
6 changed files with 52 additions and 9 deletions
+7 -4
View File
@@ -1,8 +1,8 @@
{
"name": "HA Addon: TeslaMate",
"image": "ghcr.io/home-assistant/devcontainer:addons",
"image": "ghcr.io/home-assistant/devcontainer:2-addons",
"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"],
"containerEnv": {
"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"
]
}
+2 -2
View File
@@ -35,14 +35,14 @@ jobs:
fi
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.3.0
uses: docker/login-action@v3.4.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish
uses: home-assistant/builder@2024.08.2
uses: home-assistant/builder@2025.02.0
with:
args: |
--${{ matrix.arch }} \
+1 -1
View File
@@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v4.2.2
- name: Build add-on
uses: home-assistant/builder@2024.08.2
uses: home-assistant/builder@2025.02.0
with:
args: |
--test \
+25
View File
@@ -16,6 +16,7 @@ This add-on allows you to run [TeslaMate][teslamate] on your Home Assistant serv
## Configuration
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
@@ -126,6 +127,30 @@ 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.
## 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 addon, 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 addon 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.
## Data Import from TeslaFi
It is now possible to import CSV data from TeslaFi, refer to the [official docs][teslafi-import].
+1
View File
@@ -9,6 +9,7 @@
"aarch64",
"amd64"
],
"hassio_api": true,
"ingress": true,
"init": false,
"panel_icon": "mdi:car-connected",
+16 -2
View File
@@ -59,9 +59,9 @@ fi
# Create the PostgreSQL database if it doesn't exist
if pg_isready -h "$DATABASE_HOST" -p "$DATABASE_PORT" > /dev/null 2>&1; then
bashio::log.info "Creating database '$DATABASE_NAME' on $DATABASE_HOST"
bashio::log.info "Checking for database '$DATABASE_NAME' on $DATABASE_HOST"
if [[ -n $(PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" postgres -Atqc "\list \"$DATABASE_NAME\"") ]]; then
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"
else
if PGPASSWORD="$DATABASE_PASS" psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" postgres -qc "CREATE DATABASE \"$DATABASE_NAME\""; then
@@ -76,6 +76,20 @@ else
exit 1
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.info "Configure TeslaMate settings by adding these values
to the URL you use to access your Home Assistant instance:
=> Web App: $teslamate_ingress
=> Dashboards: $grafana_ingress
"
fi
ulimit -n 1048576
bashio::log.info "Starting TeslaMate..."