Skip to content

Commit

Permalink
Add optional env vars config option
Browse files Browse the repository at this point in the history
  • Loading branch information
lildude committed Aug 11, 2024
1 parent 2b40dd2 commit a004746
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
9 changes: 9 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

- `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

It is now possible to import CSV data from TeslaFi, refer to the [official docs][teslafi-import].
Expand Down
9 changes: 7 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"timezone": "Europe/London",
"import_dir": "/share/teslamate",
"default_geofence": "",
"encryption_key": ""
"encryption_key": "",
"env_vars": []
},
"schema": {
"database_user": "str",
Expand All @@ -61,7 +62,11 @@
"timezone": "str",
"import_dir": "str",
"default_geofence": "str?",
"encryption_key": "password?"
"encryption_key": "password?",
"env_vars": [{
"name": "str?",
"value": "str?"
}]
},
"map": [
"share:rw"
Expand Down
8 changes: 8 additions & 0 deletions services/teslamate/run
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ export DATABASE_HOST DATABASE_NAME DATABASE_PASS DATABASE_PORT DATABASE_USER \
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

# 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
if bashio::config.true 'grafana_import_dashboards'; then
/dashboards.sh restore
Expand Down
3 changes: 3 additions & 0 deletions translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ configuration:
import_dir:
name: TeslaFi Import Directory
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.

0 comments on commit a004746

Please sign in to comment.