Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add MQTT_NAME env var #1481

Merged
merged 8 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/guide/env-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This is the list of the actually supported env vars:
- `HOST`: The host address to bind to. Default is `0.0.0.0`
- `STORE_DIR`: The absolute path to the directory where all files will be stored. Default is `<path to your z2m dir>/store`
- `ZWAVEJS_EXTERNAL_CONFIG`: Mostly needed for docker users, it's the path to the folder used by zwave-js to [store config database](https://zwave-js.github.io/node-zwave-js/#/usage/external-config?id=specifying-an-external-config-db-location), by default on docker image it is `/usr/src/app/store/.config-db`. For users that are using a custom `STORE_DIR` this must be changed too
- `MQTT_NAME`: The name used as client name when connecting to the mqtt server. Overrides `mqtt.name` in `settings.json`

This env vars can be used when running webpack dev server with HMR (most users will not need them):

Expand Down
4 changes: 3 additions & 1 deletion lib/MqttClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ class MqttClient extends TypedEventEmitter<MqttClientEventCallbacks> {
return
}

this._clientID = sanitizeTopic(MqttClient.NAME_PREFIX + config.name)
this._clientID = sanitizeTopic(
MqttClient.NAME_PREFIX + (process.env.MQTT_NAME || config.name)
)

const parsed = url.parse(config.host || '')
let protocol = 'mqtt'
Expand Down