Skip to content

Commit

Permalink
feat: add UID_DISCOVERY_PREFIX env var (#2698)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Sep 30, 2022
1 parent 2b20957 commit 93c16af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/guide/env-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
8 changes: 5 additions & 3 deletions lib/Gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 +
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 + ')',
Expand Down

0 comments on commit 93c16af

Please sign in to comment.