* Add Environment Variable Override
I need to be able to manage settings on this service via Environment Variables. I've added the ability to override anything in the settings schema with a corresponding environment variable.
e.g. to override settings.serial.port you can set ZIGBEE2MQTT_SERIAL_PORT=/dev/ttyS0
to override the mqtt username you can set ZIGBEE2MQTT_MQTT_USER=testusername
This new addition will not perform any action on existing installations unless the matching environment variable is set. I have tested this setting string, number, boolean, object and array values.
* Adding test case for environment variables and slight modification to ensure 100% code coverage.
* Adding a test to confirm that env variables will set non default values. Also realized that I was errantly applying the env variables to the defaults for testing. Understanding what this is doing more clearly I realize that should be clean.
* Refactoring to
1. Remove the test variables from the schema and defaults and manually reflect the tests in the test.
2. Rename environment variable base from ZIGBEE2MQTT_ to ZIGBEE2MQTT_CONFIG_
* Small improvements
* Removing the unneeded test.
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
* Add support for expiring retained messages.
For most of my environmental monitoring use cases, I want the readings
retained so I can pick them up from clients at any time, but if the
sensor (or zigbee2mqtt) fails, I want the readings to go away so I can
tell the difference between a stale reading and a missing reading.
This is easily accomplished in MQTTv5 using the "message expiry
interval" property. To add that to zigbee2mqtt, I added a 'version'
option to the mqtt section so I can specify to connect with version 5
and added a 'retention' property to devices allowing me to specify how
long items should be retained.
e.g.
mqtt:
base_topic: site/zigbee2mqtt
server: 'mqtt://myserver'
user: zigbee
version: 5
serial:
port: /dev/ttyACM0
devices:
'0x00358d00022308da':
friendly_name: someroom
retain: true
retention: 900
* Also get from deviceOptions
* Update settings.js
* Update controller.js
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
* Accept json for add_group so a groupID can be provided, also set retain property on group creation
* Update util/settings tests for groupID and retain
* Update bridgeConfig tests for add_group with json
* Add missing `zcl-id` dependency
* Improve devicePublish test
Now passes in both mocha and jest
Each test now waits for all publishes, such as readbacks,
and asserts their number.
Replaced `calledOnce` and such with numeric assertion,
for a more informative error message.
* Use sinon default sandbox
* Take assert out of chai
Improves clutter, but also `jest-codemods` also makes use of this.
* Replace proxyquire with simple cache delete
* Reduce shared mutable state in settings.test