diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index 26bb3bf2..d5ec6b29 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -14,7 +14,7 @@ Having trouble with your configuration? You can launch room-assistant with the ` ## Configuring with Docker -The official [Docker image](https://hub.docker.com/r/mkerix/room-assistant/) can be configured in two different ways. You can either mount your local config folder into the container as `/room-assistant/config` or you can provide the configuration as JSON through an environment variable. +The official [Docker image](https://hub.docker.com/r/mkerix/room-assistant/) can be configured in two different ways. You can either mount your local config folder into the container as `/room-assistant/config` or you can provide the configuration as JSON through an environment variable. Some settings may also be configured via special environment variables, in those cases the variable names are documented next to the options. ::: details Example docker-compose.yml @@ -27,10 +27,10 @@ services: volumes: - /var/run/dbus:/var/run/dbus environment: + RA_GLOBAL_INSTANCE_NAME: living-room NODE_CONFIG: > { "global": { - "instanceName": "living-room", "integrations": ["homeAssistant", "bluetoothClassic"] } } @@ -50,7 +50,10 @@ room-assistant exposes a few settings that affect the overall behavior of the ap | `integrations` | Array | | The integrations that should be loaded on this instance, denoted as camelCase. | | `apiPort` | Number | `6415` | The port that the REST API should be available on. | +These settings may also be configured as environment variables, using `RA_GLOBAL_INSTANCE_NAME`, `RA_GLOBAL_INTEGRATIONS` and `RA_GLOBAL_API_PORT`. + ::: details Example Config + ```yaml global: instanceName: bedroom diff --git a/docs/integrations/home-assistant.md b/docs/integrations/home-assistant.md index a3029b4b..a922f832 100644 --- a/docs/integrations/home-assistant.md +++ b/docs/integrations/home-assistant.md @@ -35,6 +35,8 @@ room-assistant makes use of the [MQTT auto discovery](https://www.home-assistant | `password` | String | | Password for authentication | | `rejectUnauthorized` | Boolean | `true` | Whether MQTTS connections should fail for invalid certificates or not. Set this to `false` if you are using a self-signed certificate and connect via TLS. | +Some of these settings may also be configured as environment variables, using `RA_HOME_ASSISTANT_MQTT_URL`, `RA_HOME_ASSISTANT_MQTT_USERNAME` and `RA_HOME_ASSISTANT_MQTT_PASSWORD`. + ::: details Example Config ```yaml diff --git a/docs/integrations/mqtt.md b/docs/integrations/mqtt.md index 85b8922b..a7bac79b 100644 --- a/docs/integrations/mqtt.md +++ b/docs/integrations/mqtt.md @@ -115,6 +115,8 @@ To get started with your automations based on these topics it is recommended to | `password` | String | | Password for authentication | | `rejectUnauthorized` | Boolean | `true` | Whether MQTTS connections should fail for invalid certificates or not. Set this to `false` if you are using a self-signed certificate and connect via TLS. | +Some of these settings may also be configured as environment variables, using `RA_MQTT_MQTT_URL`, `RA_MQTT_MQTT_USERNAME` and `RA_MQTT_MQTT_PASSWORD`. + ::: details Example Config ```yaml diff --git a/nest-cli.json b/nest-cli.json index 2e1000f0..cae451f8 100644 --- a/nest-cli.json +++ b/nest-cli.json @@ -2,6 +2,7 @@ "collection": "@nestjs/schematics", "sourceRoot": "src", "compilerOptions": { - "plugins": ["@nestjs/swagger/plugin"] + "plugins": ["@nestjs/swagger/plugin"], + "assets": ["config/definitions/*.yml"] } } diff --git a/package.json b/package.json index f7b120e9..c45bdea2 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "types": "dist/src/main.d.ts", "files": [ "dist/**/*.{js,ts}", + "dist/config/definitions/*.yml", "bin/*.js", ".github/FUNDING.yml" ], diff --git a/src/config/definitions/custom-environment-variables.yml b/src/config/definitions/custom-environment-variables.yml new file mode 100644 index 00000000..5c1a3ae4 --- /dev/null +++ b/src/config/definitions/custom-environment-variables.yml @@ -0,0 +1,18 @@ +global: + instanceName: RA_GLOBAL_INSTANCE_NAME + integrations: + __name: RA_GLOBAL_INTEGRATIONS + __format: json + apiPort: + __name: RA_GLOBAL_API_PORT + __format: number +homeAssistant: + mqttUrl: RA_HOME_ASSISTANT_MQTT_URL + mqttOptions: + username: RA_HOME_ASSISTANT_MQTT_USERNAME + password: RA_HOME_ASSISTANT_MQTT_PASSWORD +mqtt: + mqttUrl: RA_MQTT_MQTT_URL + mqttOptions: + username: RA_MQTT_MQTT_USERNAME + password: RA_MQTT_MQTT_PASSWORD