Created
January 12, 2020 22:11
-
-
Save ftes/6a08f097f3d75ea173a258d59db8cb32 to your computer and use it in GitHub Desktop.
zigbee2mqtt dynamic configuration.yaml with env variable substitution (e.g. for dynamic configuration via balena.io cloud)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Environment variables are escaped by the envsubst entrypoint | |
homeassistant: false | |
permit_join: $ZIGBEE2MQTT_PERMIT_JOIN | |
mqtt: | |
base_topic: zigbee2mqtt | |
server: 'mqtt://mqtt' | |
serial: | |
port: $ZIGBEE2MQTT_SERIAL_PORT | |
# Write auto-generated data to other files | |
devices: devices.yaml | |
groups: groups.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
mqtt: | |
image: eclipse-mosquitto | |
volumes: | |
- mosquitto_data:/mosquitto/data | |
- mosquitto_log:/mosquitto/log | |
zigbee2mqtt: | |
image: koenkk/zigbee2mqtt | |
volumes: | |
# Overwrite configuration.yaml with env-var-substituted version of configuration.yaml.env on every startup | |
- ./:/custom | |
- zigbee2mqtt_data:/app/data | |
entrypoint: /custom/envsubst.sh | |
depends_on: | |
- mqtt | |
privileged: true | |
environment: | |
TZ: Europe/Berlin | |
# Uncomment for local development. | |
# Comment when deploying to balena.io - it does not support env var substitution in compose file | |
# ZIGBEE2MQTT_PERMIT_JOIN: "${ZIGBEE2MQTT_PERMIT_JOIN}" | |
# ZIGBEE2MQTT_SERIAL_PORT: "${ZIGBEE2MQTT_SERIAL_PORT}" | |
volumes: | |
db: | |
zigbee2mqtt_data: | |
mosquitto_data: | |
mosquitto_log: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Interpolate (substitute) environment variables in configuration.yaml.env. | |
# Write the result to /app/data/configuration.yaml | |
INPUT=/custom/configuration.yaml.env | |
OUTPUT=/app/data/configuration.yaml | |
( echo "cat <<EOF" ; cat "$INPUT" ; echo EOF ) | sh > "$OUTPUT" | |
./run.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment