mirror of
https://github.com/lildude/ha-addon-teslamate.git
synced 2026-10-13 21:19:16 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4567555071 | ||
|
|
694b43eb93 | ||
|
|
04e01df081 | ||
|
|
d97377bc0e | ||
|
|
0aca1dd417 | ||
|
|
556a2f23af | ||
|
|
a73430c34d | ||
|
|
2b40dd2668 | ||
|
|
1757ed78ff |
@@ -35,14 +35,14 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v3.2.0
|
uses: docker/login-action@v3.3.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@master
|
uses: home-assistant/builder@2024.08.2
|
||||||
with:
|
with:
|
||||||
args: |
|
args: |
|
||||||
--${{ matrix.arch }} \
|
--${{ matrix.arch }} \
|
||||||
|
|||||||
@@ -35,12 +35,13 @@ jobs:
|
|||||||
- name: Get TeslaMate release notes
|
- name: Get TeslaMate release notes
|
||||||
run: |
|
run: |
|
||||||
touch CHANGELOG.txt
|
touch CHANGELOG.txt
|
||||||
gh pr list --repo lildude/ha-addon-teslamate --state=merged --search="Update TeslaMate" --limit=1 --json=body --jq '.[].body' | sed -n "/<\/summary>/,/<\/details>/p" | sed '1d;$d' > changelog.tmp
|
last_release_date=$(gh release list --repo lildude/ha-addon-teslamate --limit=1 --json=publishedAt)
|
||||||
|
gh pr list --repo lildude/ha-addon-teslamate --state=merged --search="Update TeslaMate in:title closed:>$last_release_date" --limit=1 --json=body --jq '.[].body' | sed -n "/<\/summary>/,/<\/details>/p" | sed '1d;$d' > changelog.tmp
|
||||||
if [ -s changelog.tmp ]; then
|
if [ -s changelog.tmp ]; then
|
||||||
echo "## TeslaMate Release Notes" > CHANGELOG.txt
|
echo "## TeslaMate Release Notes" > CHANGELOG.txt
|
||||||
cat changelog.tmp >> CHANGELOG.txt
|
cat changelog.tmp >> CHANGELOG.txt
|
||||||
echo -e "---\n\n## Add-on Release Notes\n\n" >> CHANGELOG.txt
|
|
||||||
fi
|
fi
|
||||||
|
echo -e "---\n\n## Add-on Release Notes\n\n" >> CHANGELOG.txt
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Create tag
|
- name: Create tag
|
||||||
@@ -51,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.0.7
|
uses: softprops/action-gh-release@v2.0.8
|
||||||
with:
|
with:
|
||||||
tag_name: v${{ steps.semver.outputs.semver }}
|
tag_name: v${{ steps.semver.outputs.semver }}
|
||||||
body_path: CHANGELOG.txt
|
body_path: CHANGELOG.txt
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4.1.7
|
uses: actions/checkout@v4.1.7
|
||||||
|
|
||||||
- name: Build add-on
|
- name: Build add-on
|
||||||
uses: home-assistant/builder@master
|
uses: home-assistant/builder@2024.08.2
|
||||||
with:
|
with:
|
||||||
args: |
|
args: |
|
||||||
--test \
|
--test \
|
||||||
|
|||||||
@@ -115,6 +115,15 @@ Once you have Grafana up and running, you'll need to configure a data source to
|
|||||||
|
|
||||||
- `import_dir`: (Optional) The path to the directory where TeslaMate should look for the TeslaMate export CSV file. Default: `/share/teslamate`.
|
- `import_dir`: (Optional) The path to the directory where TeslaMate should look for the TeslaMate export CSV file. Default: `/share/teslamate`.
|
||||||
|
|
||||||
|
- `env_vars`: (Optional) Set additional environment variables for TeslaMate which aren't currently exposed by the configuration options in this add-on.
|
||||||
|
|
||||||
|
Each entry is made up of a name and value:
|
||||||
|
|
||||||
|
- `name`: The case-sensitive environment variable name.
|
||||||
|
- `value`: The value to be set in the environment variable.
|
||||||
|
|
||||||
|
Note: These will also overwrite any environment variable set using the configuration options above.
|
||||||
|
|
||||||
## 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].
|
||||||
@@ -135,7 +144,7 @@ Follow this process:
|
|||||||
[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/hassio-addon-teslamate/main/imgs/grafana-postgres.png
|
[grafana-datasource]: https://raw.githubusercontent.com/lildude/ha-addon-teslamate/main/imgs/grafana-postgres.png
|
||||||
[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
|
||||||
[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
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ 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
|
||||||
[alexbegium-postgres]: https://github.com/alexbelgium/hassio-addons/tree/master/postgres
|
[alexbelgium-postgres]: https://github.com/alexbelgium/hassio-addons/tree/master/postgres
|
||||||
[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
|
||||||
[elixir]: https://elixir-lang.org/
|
[elixir]: https://elixir-lang.org/
|
||||||
|
|||||||
+7
-2
@@ -36,7 +36,8 @@
|
|||||||
"timezone": "Europe/London",
|
"timezone": "Europe/London",
|
||||||
"import_dir": "/share/teslamate",
|
"import_dir": "/share/teslamate",
|
||||||
"default_geofence": "",
|
"default_geofence": "",
|
||||||
"encryption_key": ""
|
"encryption_key": "",
|
||||||
|
"env_vars": []
|
||||||
},
|
},
|
||||||
"schema": {
|
"schema": {
|
||||||
"database_user": "str",
|
"database_user": "str",
|
||||||
@@ -61,7 +62,11 @@
|
|||||||
"timezone": "str",
|
"timezone": "str",
|
||||||
"import_dir": "str",
|
"import_dir": "str",
|
||||||
"default_geofence": "str?",
|
"default_geofence": "str?",
|
||||||
"encryption_key": "password?"
|
"encryption_key": "password?",
|
||||||
|
"env_vars": [{
|
||||||
|
"name": "str?",
|
||||||
|
"value": "str?"
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
"map": [
|
"map": [
|
||||||
"share:rw"
|
"share:rw"
|
||||||
|
|||||||
+21
-16
@@ -11,13 +11,14 @@
|
|||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
|
||||||
readonly HOST=$(bashio::config 'grafana_host')
|
HOST=$(bashio::config 'grafana_host')
|
||||||
readonly PORT=$(bashio::config 'grafana_port')
|
PORT=$(bashio::config 'grafana_port')
|
||||||
readonly USER=$(bashio::config 'grafana_user')
|
USER=$(bashio::config 'grafana_user')
|
||||||
readonly PASS=$(bashio::config 'grafana_pass')
|
PASS=$(bashio::config 'grafana_pass')
|
||||||
readonly DASHBOARDS_DIRECTORY="/dashboards"
|
DASHBOARDS_DIRECTORY="/dashboards"
|
||||||
readonly FOLDER_NAME=$(bashio::config 'grafana_folder_name')
|
FOLDER_NAME=$(bashio::config 'grafana_folder_name')
|
||||||
|
|
||||||
|
readonly HOST PORT USER PASS DASHBOARDS_DIRECTORY FOLDER_NAME
|
||||||
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
@@ -25,13 +26,12 @@ main() {
|
|||||||
|
|
||||||
URL="http://$HOST:$PORT"
|
URL="http://$HOST:$PORT"
|
||||||
LOGIN="$USER:$PASS"
|
LOGIN="$USER:$PASS"
|
||||||
|
|
||||||
case $task in
|
case $task in
|
||||||
backup) backup;;
|
backup) backup;;
|
||||||
restore) restore;;
|
restore) restore;;
|
||||||
*) exit 1;;
|
*) exit 1;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -42,9 +42,7 @@ backup() {
|
|||||||
dashboard_json=$(get_dashboard "$dashboard")
|
dashboard_json=$(get_dashboard "$dashboard")
|
||||||
|
|
||||||
if [[ -z "$dashboard_json" ]]; then
|
if [[ -z "$dashboard_json" ]]; then
|
||||||
echo "ERROR:
|
echo "ERROR: Couldn't retrieve dashboard $dashboard."
|
||||||
Couldn't retrieve dashboard $dashboard.
|
|
||||||
"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -57,10 +55,18 @@ backup() {
|
|||||||
|
|
||||||
restore() {
|
restore() {
|
||||||
bashio::log.info "Checking for Grafana folder: $FOLDER_NAME"
|
bashio::log.info "Checking for Grafana folder: $FOLDER_NAME"
|
||||||
FLD=$(curl --silent --show-error \
|
folders=$(curl --silent --show-error \
|
||||||
--user "$LOGIN" -H "Content-Type: application/json" \
|
--user "$LOGIN" -H "Content-Type: application/json" \
|
||||||
$URL/api/folders | jq ".[] | select(.title==\"$FOLDER_NAME\")")
|
"$URL/api/folders")
|
||||||
|
|
||||||
|
if [[ $folders == *"statusCode"* ]]; then
|
||||||
|
bashio::log.error "Error getting Grafana folders: $(echo "$folders" | jq -r .message)"
|
||||||
|
bashio::log.debug "$folders"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
FLD=$(echo "$folders" | jq ".[] | select(.title==\"$FOLDER_NAME\")")
|
||||||
|
|
||||||
if [[ -z "$FLD" ]]; then
|
if [[ -z "$FLD" ]]; then
|
||||||
bashio::log.info "Not found... creating"
|
bashio::log.info "Not found... creating"
|
||||||
FLD=$(curl \
|
FLD=$(curl \
|
||||||
@@ -72,7 +78,7 @@ restore() {
|
|||||||
"$URL/api/folders")
|
"$URL/api/folders")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FOLDER_ID=$(echo $FLD | jq -r .id)
|
FOLDER_ID=$(echo "$FLD" | jq -r .id)
|
||||||
|
|
||||||
if [[ -z "$FOLDER_ID" ]]; then
|
if [[ -z "$FOLDER_ID" ]]; then
|
||||||
bashio::log.error "Could not determine Grafana folder id"
|
bashio::log.error "Could not determine Grafana folder id"
|
||||||
@@ -123,5 +129,4 @@ list_dashboards() {
|
|||||||
cut -d '/' -f2
|
cut -d '/' -f2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
+7
-1
@@ -1,5 +1,11 @@
|
|||||||
#!/command/with-contenv bashio
|
#!/command/with-contenv bashio
|
||||||
# -*- bash -*-
|
# -*- bash -*-
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
mkdir /run/nginx
|
|
||||||
|
bashio::log.info "Starting NGINX..."
|
||||||
|
if [ -f /run/nginx ]; then
|
||||||
|
rm -f /run/nginx
|
||||||
|
fi
|
||||||
|
mkdir -p /run/nginx
|
||||||
|
|
||||||
exec nginx -g 'daemon off;error_log /proc/1/fd/1 error;'
|
exec nginx -g 'daemon off;error_log /proc/1/fd/1 error;'
|
||||||
+11
-3
@@ -44,16 +44,24 @@ export DATABASE_HOST DATABASE_NAME DATABASE_PASS DATABASE_PORT DATABASE_USER \
|
|||||||
DISABLE_MQTT MQTT_HOST MQTT_NAMESPACE MQTT_PASSWORD MQTT_TLS_ACCEPT_INVALID_CERTS \
|
DISABLE_MQTT MQTT_HOST MQTT_NAMESPACE MQTT_PASSWORD MQTT_TLS_ACCEPT_INVALID_CERTS \
|
||||||
MQTT_TLS MQTT_USERNAME IMPORT_DIR PORT TZ DEFAULT_GEOFENCE ENCRYPTION_KEY URL_PATH
|
MQTT_TLS MQTT_USERNAME IMPORT_DIR PORT TZ DEFAULT_GEOFENCE ENCRYPTION_KEY URL_PATH
|
||||||
|
|
||||||
|
# These are optional and applied last so we can override those set above if needed.
|
||||||
|
for env_var in $(bashio::config 'env_vars|keys'); do
|
||||||
|
name=$(bashio::config "env_vars[${env_var}].name")
|
||||||
|
value=$(bashio::config "env_vars[${env_var}].value")
|
||||||
|
bashio::log.debug "Setting Env Variable ${name} to ${value}"
|
||||||
|
export "${name}=${value}"
|
||||||
|
done
|
||||||
|
|
||||||
# Import dashboards
|
# Import dashboards
|
||||||
if bashio::config.true 'grafana_import_dashboards'; then
|
if bashio::config.true 'grafana_import_dashboards'; then
|
||||||
/dashboards.sh restore
|
/dashboards.sh restore || bashio::log.error "Failed to import dashboards"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the PostgreSQL database if it doesn't exist
|
# Create the PostgreSQL database if it doesn't exist
|
||||||
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"
|
bashio::log.info "Creating 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 "\list \"$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
|
||||||
@@ -70,7 +78,7 @@ fi
|
|||||||
|
|
||||||
ulimit -n 1048576
|
ulimit -n 1048576
|
||||||
|
|
||||||
bashio::log.info "Starting TeslaMate"
|
bashio::log.info "Starting TeslaMate..."
|
||||||
|
|
||||||
cd /opt/app
|
cd /opt/app
|
||||||
exec $(/usr/bin/env sh) /entrypoint.sh bin/teslamate start
|
exec $(/usr/bin/env sh) /entrypoint.sh bin/teslamate start
|
||||||
|
|||||||
@@ -67,3 +67,6 @@ configuration:
|
|||||||
import_dir:
|
import_dir:
|
||||||
name: TeslaFi Import Directory
|
name: TeslaFi Import Directory
|
||||||
description: The directory which holds the TeslaFi export you would like to import into TeslaMate.
|
description: The directory which holds the TeslaFi export you would like to import into TeslaMate.
|
||||||
|
env_vars:
|
||||||
|
name: Environment Variables
|
||||||
|
description: Set additional environment variables for TeslaMate which aren't currently exposed by the configuration options in this add-on.
|
||||||
|
|||||||
Reference in New Issue
Block a user