Skip to content

Commit

Permalink
feat: expose some config options as env variables (#1099)
Browse files Browse the repository at this point in the history
Includes global and some MQTT options for now.

Closes #1094
  • Loading branch information
mKeRix authored Mar 13, 2022
1 parent ee057d8 commit 3ae8e9a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
7 changes: 5 additions & 2 deletions docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"]
}
}
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/integrations/home-assistant.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/integrations/mqtt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion nest-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"plugins": ["@nestjs/swagger/plugin"]
"plugins": ["@nestjs/swagger/plugin"],
"assets": ["config/definitions/*.yml"]
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"types": "dist/src/main.d.ts",
"files": [
"dist/**/*.{js,ts}",
"dist/config/definitions/*.yml",
"bin/*.js",
".github/FUNDING.yml"
],
Expand Down
18 changes: 18 additions & 0 deletions src/config/definitions/custom-environment-variables.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3ae8e9a

Please sign in to comment.