This is example_config.js:
|
module.exports = { |
|
logConfig: { |
|
filename: "/var/log/zwave/zwave", |
|
forceConsole: true, |
|
logToFile: true, |
|
level: "info", |
|
}, |
|
|
|
storage: { |
|
cacheDir: "/opt/zwave_js_server/data", |
|
deviceConfigPriorityDir: "/opt/zwave_js_server/data/config", |
|
}, |
|
|
|
// Generated with: "< /dev/urandom tr -dc A-F0-9 | head -c32 ;echo" |
|
securityKeys: { |
|
S0_Legacy: Buffer.from("<NETWORK_KEY>", "hex"), |
|
}, |
|
}; |
Here is where the config file is parsed:
|
if (configPath) { |
|
try { |
|
// Pull presets out of options so we can pass them to the driver |
|
({ presets: presetNames, ...options } = require(configPath)); |
|
// If both securityKeys.S0_Legacy and networkKey are defined, throw an error. |
|
if (options.securityKeys?.S0_Legacy && options.networkKey) { |
|
throw new Error( |
|
"Both `networkKey` and `securityKeys.S0_Legacy` options are present in the " + |
|
"config. Remove `networkKey`.", |
|
); |
|
} |
|
const securityKeyNames = [ |
|
"S0_Legacy", |
|
"S2_AccessControl", |
|
"S2_Authenticated", |
|
"S2_Unauthenticated", |
|
]; |
|
// We prefer the securityKeys option over the networkKey one |
|
if (options.securityKeys) { |
|
for (const key of securityKeyNames) { |
|
if (key in options.securityKeys) { |
|
options.securityKeys[key] = normalizeKey( |
|
options.securityKeys[key], |
|
`securityKeys.${key}`, |
|
); |
|
} |
|
} |
|
} |
|
// If we get here, securityKeys.S0_Legacy is not defined, so we can safely use networkKey |
|
// make sure that networkKey is passed as buffer and accept both zwave2mqtt format and ozw format |
|
if (options.networkKey) { |
|
if (!options.securityKeys) options.securityKeys = {}; |
|
options.securityKeys.S0_Legacy = normalizeKey( |
|
options.networkKey, |
|
"networkKey", |
|
); |
|
console.warn( |
|
"The `networkKey` option is deprecated in favor of `securityKeys` option. To eliminate " + |
|
"this warning, move your networkKey into the securityKeys.S0_Legacy option. Refer to " + |
|
"the Z-Wave JS docs for more information", |
|
); |
|
delete options.networkKey; |
|
} else if (!options.securityKeys?.S0_Legacy) |
|
throw new Error("Error: `securityKeys.S0_Legacy` key is missing."); |
|
|
|
// Support long range keys |
|
const securityKeysLongRangeNames = [ |
|
"S2_AccessControl", |
|
"S2_Authenticated", |
|
]; |
|
if (options.securityKeysLongRange) { |
|
for (const key of securityKeysLongRangeNames) { |
|
if (key in options.securityKeysLongRange) { |
|
options.securityKeysLongRange[key] = normalizeKey( |
|
options.securityKeysLongRange[key], |
|
`securityKeysLongRange.${key}`, |
|
); |
|
} |
|
} |
|
} |
|
} catch (err) { |
|
console.error(`Error: failed loading config file ${configPath}`); |
|
console.error(err); |
|
return; |
|
} |
|
} |
It supports a lot of options, but it does not support "mock-driver", "port", "host", or "disable-dns-sd" options. Instead, these options are parsed separately:
|
const args = parseArgs<Args>([ |
|
"_", |
|
"config", |
|
"mock-driver", |
|
"port", |
|
"host", |
|
"disable-dns-sd", |
|
]); |
It would be really great to be able to tell zwave-js-server to "read all my config options" and have the port, host, encryption keys, and the like all in one place. This would make it a lot easier to maintain individual configurations for each zwave device and its corresponding server, which is useful for how zwave-js-server is typically deployed on a server.
For example, this is the zwave-js-server package in the Arch Linux AUR:
https://aur.archlinux.org/packages/zwave-js-server
Here is the zwave-js-server@.service file that it includes (link):
[Unit]
Description=ZWave-JS Server Daemon "%i" instance
Before=home-assistant.service
[Service]
ExecStart=/usr/bin/zwave-server /dev/%I
[Install]
WantedBy=multi-user.target
If we could pass a configuration file to zwave-server and have everything we need, then this would be great 😄
Thanks for the great project! Cheers!
This is example_config.js:
zwave-js-server/example_config.js
Lines 1 to 18 in 1fb161d
Here is where the config file is parsed:
zwave-js-server/src/bin/server.ts
Lines 68 to 133 in 1fb161d
It supports a lot of options, but it does not support "mock-driver", "port", "host", or "disable-dns-sd" options. Instead, these options are parsed separately:
zwave-js-server/src/bin/server.ts
Lines 34 to 41 in 1fb161d
It would be really great to be able to tell zwave-js-server to "read all my config options" and have the port, host, encryption keys, and the like all in one place. This would make it a lot easier to maintain individual configurations for each zwave device and its corresponding server, which is useful for how zwave-js-server is typically deployed on a server.
For example, this is the zwave-js-server package in the Arch Linux AUR:
https://aur.archlinux.org/packages/zwave-js-server
Here is the
zwave-js-server@.servicefile that it includes (link):If we could pass a configuration file to
zwave-serverand have everything we need, then this would be great 😄Thanks for the great project! Cheers!