Environment Variable integration for Home Assistant allows to add environment variable automatically each time Home Assistant is started, even after Home Assistant is updated/upgraded.
This integration is useful for Home Assistant OS (HAOS).
This integration is useless for Home Assistant Docker image and Core installations.
Variables that are set with this integration won't be available for automations.
Environment Variable integration may not be available yet from HACS interface, install Environment Variable by adding this Github repository to HACS custom repositories:
- Install HACS if not already done.
- Then, go to your Home Assistant,
- -> HACS
- -> Integrations
- -> Click the Three-dots button in top-right corner
- -> Custom repositories
- -> Fill in
- Repository: https://github.com/Athozs/hass-environment-variable.git
- Category: Integration
- -> Click Add
- Go to the Add-on store
- Install one of the SSH add-ons (you need to enable advanced mode in your user profile to see them)
- Configure the SSH add-on you chose by following the documentation for it
- Start the SSH add-on
- Connect to the SSH add-on
- Download the latest release of Environment Variable from Github (.zip):
wget https://github.com/Athozs/hass-environment-variable/releases/latest/download/environment_variable.zip
- Unzip archive:
unzip environment_variable.zip
- Move or copy folder
environment_variable
intoconfig/custom_components/
directory:
cp -r environment_variable config/custom_components/
If you're running Home Assistant core (Python package) directly on host, or running Home Assistant Docker image, you don't need Environment Variable integration. You should set your environment variables from your host OS or Docker Compose file.
- Enable Environment Variable integration in
configuration.yaml
and set custom environment variables:
Model:
# configuration.yaml
---
default_config:
environment_variable:
<string>: <string>
<string>: <string>
# ...: ...
Example:
# configuration.yaml
---
default_config:
environment_variable:
REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
FOOBAR: baz
# ...
-
Restart Home Assistant.
-
You may need to reload your integrations after Home Assistant has started to take environment variables into account.
-
Check the logs, look for pattern
environment_variable
in traces (there is not UI for Environment Variable).
When enabled, Environment Variable integration sets environment variables at Home Assistant application level using standard Python lib, meaning environment variables are available only inside Home Assistant Python application/integrations.
Environment variables that are set with this integration won't be available at operating system level.
It loads environment variables only at Home Assistant startup.
There is no control on integrations startup order, you may need to reload your integration after Home Assistant has completely started to take environment variables into account.
For now, Environment Variable won't be visible in Home Assistant integrations dashboard, there is not UI component for Environment Variable integration. This may be possible in future release.
- Delete Environment Variable from custom components:
rm -r config/custom_components/environment_variable
- Remove
environment_variable:
config key fromconfiguration.yaml
:
# configuration.yaml
---
default_config:
# environment_variable:
# FOOBAR: baz
# ...
- Restart Home Assistant.
You can't check your environment variables using the Shell prompt, because environment variables that are set with this integration are only available at Home Assistant Python application level.
The only way to check environment variable is to access it through Python code inside an integration.
n/a