diff --git a/docs/guide/env-vars.md b/docs/guide/env-vars.md index 60e4391f44..f64dc1aa6c 100644 --- a/docs/guide/env-vars.md +++ b/docs/guide/env-vars.md @@ -22,11 +22,12 @@ This is the list of the supported environment variables: - `ZWAVEJS_LOGS_DIR`: The folder used to store Z-Wave JS logs if `Log to file` is selected in the Z-Wave settings. By default, this is the `store` folder. - `MQTT_NAME`: The name used as client name when connecting to the mqtt server. Overrides `mqtt.name` in `settings.json` - `DISABLE_LOG_ROTATION`: Set this env var to `'true'` to disable application log rotation management -- `ZUI_LOG_MAXFILES`: The maximum number of files to keep in the log directory, if you add `d` suffix this will set the number of days to keep logs. Default is `7d` +- `ZUI_LOG_MAXFILES`: The maximum number of files to keep in the log directory, if you add `d` suffix this will set the number of days to keep logs. Default is `7d`. - `ZUI_LOG_MAXSIZE`: The maximum size of a single log file. Default is `50m` (50MB) - `NO_LOG_COLORS`: Set this env var to `'true'` to disable application log colors also in the console. - `FORCE_DISABLE_SSL`: Set this env var to `'true'` to disable SSL. -- `BASE_PATH`: Set this env var to the base path where the application is served. Default is `/` +- `BASE_PATH`: Set this env var to the base path where the application is served. Default is `/`. +- `UID_DISCOVERY_PREFIX`: Sets the prefix used for MQTT Discovery `unique_id` of entities. Default is `zwavejs2mqtt_`. These variables can be used when running the webpack dev server with HMR (most users will not need them): diff --git a/lib/Gateway.ts b/lib/Gateway.ts index d74f32c50d..c1918a9e2d 100644 --- a/lib/Gateway.ts +++ b/lib/Gateway.ts @@ -32,6 +32,8 @@ const logger = module('Gateway') const NODE_PREFIX = 'nodeID_' +const UID_DISCOVERY_PREFIX = process.env.UID_DISCOVERY_PREFIX || 'zwavejs2mqtt_' + const GATEWAY_TYPE = { VALUEID: 0, NAMED: 1, @@ -849,7 +851,7 @@ export default class Gateway { // set a unique id for the component payload.unique_id = - 'zwavejs2mqtt_' + + UID_DISCOVERY_PREFIX + this._zwave.homeHex + '_Node' + node.id + @@ -1607,7 +1609,7 @@ export default class Gateway { // Set a unique id for the component payload.unique_id = - 'zwavejs2mqtt_' + + UID_DISCOVERY_PREFIX + this._zwave.homeHex + '_' + utils.sanitizeTopic(valueId.id, true) @@ -2213,7 +2215,7 @@ export default class Gateway { private _deviceInfo(node: ZUINode, nodeName: string): DeviceInfo { return { identifiers: [ - 'zwavejs2mqtt_' + this._zwave.homeHex + '_node' + node.id, + UID_DISCOVERY_PREFIX + this._zwave.homeHex + '_node' + node.id, ], manufacturer: node.manufacturer, model: node.productDescription + ' (' + node.productLabel + ')',