Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
feat: support more ENV VARS for configuration (#788)
Browse files Browse the repository at this point in the history
  • Loading branch information
onedr0p committed Oct 15, 2020
1 parent cfd9f85 commit d7bdb2c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ After a [discussion](https://github.com/OpenZWave/Zwave2Mqtt/issues/201) with Op
- [Mesh](#mesh)
- [Debug](#debug)
- [Health check endpoints](#health-check-endpoints)
- [Environment variables](#environment-variables)
- [:question: FAQ](#-faq)
- [:pray: Thanks](#-thanks)
- [:pencil: TODOs](#-todos)
Expand Down Expand Up @@ -804,6 +805,17 @@ Remember to add the header: `Accept: text/plain` to your request.

Example: `curl localhost:8091/health/zwave -H "Accept: text/plain"`

## Environment variables

_**Note**: Each one of the following environment variables corresponds to their respective options in the UI settings and options saved in the UI take presence over these environment variables._

- `OZW_NETWORK_KEY`
- `OZW_SAVE_CONFIG`
- `OZW_POLL_INTERVAL`
- `OZW_AUTO_UPDATE_CONFIG`
- `OZW_CONFIG_PATH`
- `OZW_ASSUME_AWAKE`

## :question: FAQ

> A: Why when I add a value to Gateway values table I don't see all my devices?
Expand Down
10 changes: 7 additions & 3 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ async function init (cfg, socket) {
this.closed = false
this.scenes = jsonStore.get(store.scenes)

cfg.saveConfig = cfg.saveConfig || process.env.OZW_SAVE_CONFIG
cfg.autoUpdateConfig =
cfg.autoUpdateConfig || process.env.OZW_AUTO_UPDATE_CONFIG

// Full option list: https://github.com/OpenZWave/open-zwave/wiki/Config-Options
var options = {
Logging: cfg.logging,
Expand All @@ -146,7 +150,7 @@ async function init (cfg, socket) {
SaveConfiguration: Boolean(cfg.saveConfig),
// RetryTimeout: 10000,
// IntervalBetweenPolls: true,
PollInterval: cfg.pollInterval,
PollInterval: cfg.pollInterval || process.env.OZW_POLL_INTERVAL,
AutoUpdateConfigFile: Boolean(cfg.autoUpdateConfig)
// SuppressValueRefresh: true,
}
Expand All @@ -158,11 +162,11 @@ async function init (cfg, socket) {
}

if (cfg.configPath) {
options.ConfigPath = cfg.configPath
options.ConfigPath = cfg.configPath || process.env.OZW_CONFIG_PATH
}

if (cfg.assumeAwake) {
options.AssumeAwake = cfg.assumeAwake
options.AssumeAwake = cfg.assumeAwake || process.env.OZW_ASSUME_AWAKE
}

if (cfg.options) {
Expand Down

0 comments on commit d7bdb2c

Please sign in to comment.