Commit Graph

68 Commits

Author SHA1 Message Date
Oleksandr Masliuchenko b4473d6e24 fix: Remove predefined endpoint list, remove limits on device friendly name (#21325)
* Get rid of predefined list of endpoints, correct friend name validations

* Fix minor bug while parsing a topic for an unknown device
2024-02-10 16:50:44 +01:00
Roland Huß b67888f938 fix: Fix load of empty configuration .yaml file failing (#20289)
* Always return an object when loading a YAML file, even when it is empty or containing the `null` value.

Fixes #20283

* Add unit test for having multiple device files, with one is empty. This test breaks without the proposed.
2023-12-20 19:31:49 +01:00
Nicolas Thumann 45ac44dd06 fix: Make frontend listen on both IPv4 and IPv6 by default (#19660)
* Change: Set frontend host to null by default

* Change: Allow frontend to listen on port without host

* Change: Unit test

* Add: Unit test
2023-11-10 21:57:53 +01:00
Koen Kanters aa021d988d feat: Support generating extended_pan_id (#18596)
* feat: Support generating extended_pan_id

* Update configuration.example.yaml
2023-08-12 15:07:30 +02:00
koenkk ba0cc61965 fix(ignore): Fix failing test 2023-07-31 18:05:00 +02:00
Tami 2eadf30199 Fix error when device is added when device: [] in configuration.yaml (#16629)
* fix for TypeError: The "path" argument must be of type string in writeDevicesOrGroups

* added test case that produces the error when running on old implementation

Summary of all failing tests
 FAIL  test/settings.test.js
  ● Settings › Should add devices even when devices exist empty

    TypeError: The "path" argument must be of type string. Received undefined

      275 |
      276 | jest.mock('../../lib/util/data', () => ({
    > 277 |     joinPath: (file) => require('path').join(mockDir, file),
          |                                         ^
      278 |     getPath: () => mockDir,
      279 | }));
      280 |

      at Object.join [as joinPath] (test/stub/data.js:277:41)
      at joinPath (lib/util/settings.ts:245:38)
      at writeDevicesOrGroups (lib/util/settings.ts:250:5)
      at Object.write [as addDevice] (lib/util/settings.ts:555:5)
      at Object.addDevice (test/settings.test.js:128:18)
2023-02-13 19:41:49 +01:00
Jakub Jirutka a2f8534823 Allow to specify full file name in value reference '!' (#14955)
* Extract parsing of value reference '!' in settings into a function

* Allow to specify full file name in value reference '!'

This `network_key: '!secret network_key'` is really confusing because
it looks like a YAML tag named 'secret' and a value "network_key".
When we write `network_key: '!secret.yaml network_key'` instead, it's
a little clearer what's going on. Also, it's more consistent with file
references in 'devices' and 'groups'.
2022-11-13 15:17:59 +01:00
Koen Kanters 2bca5deb66 Fix setting devices/groups to file via environment variables not working. #7807 2022-09-07 10:07:16 +02:00
Koen Kanters 8af3ad5541 Fix crash when ZIGBEE2MQTT_CONFIG_ADVANCED_NETWORK_KEY environment variable is set to GENERATE. https://github.com/Koenkk/zigbee2mqtt/issues/12999 2022-07-08 16:58:23 +02:00
Vladimir Vitkov 326c2aaa90 Allow to specify MQTT server in secrets (#12904)
* add server, pan_id, ext_pan_id to secrets

* fix tests

* clean secrets before every test run

* add interpolation of mqtt.server, advanced.pan_id, advanced.ext_pan_id and split mqtt.user, mqtt.pass requirement

* remove pan_id and ext_pan_id from secrets processing
2022-06-27 18:42:05 +02:00
Koen Kanters d0530b8214 Don't allow friendly names to include control character. #12379 2022-05-04 21:00:29 +02:00
Koen Kanters 30177b0db4 Restructure settings (#10437)
* -

* deep copy schema

* -

* -

* -

* -

* -

* -

* -

* -

* -

* -

* -

* -
2022-01-09 22:28:44 +01:00
Koen Kanters d4f560d198 Validate QOS value. https://github.com/Koenkk/zigbee2mqtt/issues/9962 2021-12-07 18:52:54 +01:00
Koen Kanters 0282011255 Replace old availability implementation with new one (#8904)
* Update

* Updates

* More refactoringzzz

* Bindoo

* Loadz of typescripting

* Logga

* Updates

* Updates

* Updates

* Updates

* cleanup

* updates

* Fix coverage

* Fixes

* Updates

* Updates

* Replace old availability implementation with new one.
2021-10-02 10:25:43 +02:00
Koen Kanters 045ee573a0 Final TypeScript refactor (#8859)
* Update

* Updates

* More refactoringzzz

* Bindoo

* Loadz of typescripting

* Logga

* Updates

* Updates

* Updates

* Updates

* cleanup

* updates

* Fix coverage

* Fixes

* Updates

* Updates
2021-10-02 10:09:38 +02:00
Koen Kanters 4125ae0888 TypeScript refactoring (#8567)
* Updates

* Updates

* Updates

* Rename

* Updates

* updates

* Updates

* Updates
2021-09-01 20:39:17 +02:00
Koen Kanters 3774a78134 Migrate utils to typescript. 2021-08-25 20:11:55 +02:00
Koen Kanters f571938efc Migrate settings.js to TypeScript. 2021-07-21 22:14:33 +02:00
github-actions[bot] d67649e458 Update dependencies (#7956)
* Update dependencies

* Update dependencies

* updates

* update

Co-authored-by: Koenkk <Koenkk@users.noreply.github.com>
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
2021-07-05 22:12:50 +02:00
Koen Kanters 9941be1d1a Honour optimisitic false for groups (#7615)
* Honour optimisitic false for groups. https://github.com/Koenkk/zigbee2mqtt/issues/7571

* Remove default optimistic true for groups. https://github.com/Koenkk/zigbee2mqtt/issues/7571

* Updates
2021-05-28 20:23:00 +02:00
Koen Kanters 00c2894bb4 Reread settings on restart. https://github.com/Koenkk/zigbee2mqtt/discussions/6628 2021-03-09 19:50:05 +01:00
noned80 ed7f12eb89 Spelling correction of error message (#6056) 2021-02-02 22:44:29 +01:00
Koen Kanters 48767a7bcf Allow to generate panID by setting "pan_id: GENERATE". https://github.com/Koenkk/zigbee2mqtt/issues/5745 2021-01-18 18:01:10 +01:00
Koen Kanters 7014bb05f0 Fix tests 2021-01-09 15:17:09 +01:00
Koen Kanters 77a6ec09fb More friendly name checks. https://github.com/Koenkk/zigbee2mqtt/commit/d7c74ca3ad65dc8cc0366d321c5494c4f3b7a51b 2021-01-09 14:21:01 +01:00
Koen Kanters 6548250eb4 Allow read-only devices/groups files by allowing to specify devices/groups in multiple files. #2970 2020-11-27 17:32:32 +01:00
Chris Nesbitt-Smith aabb88fbf4 Add force_disable_retain option (#4948)
* support configurable retain on mqtt settings since some servers throw errors and drop the connections if you try (e.g. aws iot)

* Revert "support configurable retain on mqtt settings since some servers throw errors and drop the connections if you try (e.g. aws iot)"

This reverts commit 40d3a9c0bc84c83d2b167e2e3c3a06ca6df80f47.

* support configurable retain on mqtt settings

* support subscribing to the whole base prefix

* Update mqtt.js

* Fixes

* Fixes

* Fix tests

* Updates

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
2020-11-16 17:27:49 +01:00
Tom 08524953bf Add Environment Variable Override (#4085)
* 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>
2020-08-13 23:50:30 +02:00
Koen Kanters ad13564687 Improve error messages when configuration is invalid. #3943 2020-07-23 19:17:26 +02:00
Koen Kanters 67f02adbd0 Prefer blocklist/passlist over blacklist/whitelist 2020-07-15 23:22:32 +02:00
Koen Kanters a90ebce677 Change device options. #3181 2020-06-13 23:28:06 +02:00
Koen Kanters d22e73ebb4 #3271 Allow to randomize network_key by settings 'network_key: GENERATE' 2020-04-21 21:58:43 +02:00
Koen Kanters 3ef7555ca2 Refactor 2020-04-05 00:05:05 +02:00
Koen Kanters 4fe23842cf Don't allow non existing entities on availability_blacklist or availability_whitelist. #3191 2020-03-25 20:46:20 +01:00
Koen Kanters a307747d8c Fix typo. 2020-03-25 20:05:18 +01:00
Koen Kanters 5cd1af569e Fix crash when removing device from group which has no devices in settings. #3185 2020-03-23 22:24:35 +01:00
Koen Kanters a3b285d1ac Don't allow MQTT wildcard (# or +) in friendly_name. #3175 2020-03-23 19:59:49 +01:00
Dustin Sallings 97a4b6b539 Add support for expiring retained messages. (#3082)
* 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>
2020-03-12 20:25:37 +01:00
Koen Kanters 4d54e5038b Refuse to start when friendly_name ends with /DIGIT. #2645 2020-03-07 23:06:22 +01:00
Koen Kanters 9cc84feb67 Allow to rename groups through zigbee2mqtt/bridge/config/rename. https://github.com/Koenkk/zigbee2mqtt/issues/2991 2020-02-23 21:51:30 +01:00
Koen Kanters d17eec5310 Don't allow postfix to be a friendly_name. #2486 2019-12-09 18:27:39 +01:00
Koen Kanters fdcaaee955 Fix typo. 2019-11-11 17:45:11 +01:00
Koen Kanters 0b0a9bca4d Update converters. 2019-11-10 19:53:37 +01:00
Koen Kanters af770acd2d Make retain a optional option and default it to false. 2019-11-06 20:30:33 +01:00
Jorge Schrauwen 5ad97325be Fix missing retain on add_group, allow specifying of groupID (#2266)
* 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
2019-11-04 17:59:00 +01:00
Koenkk 646cd34715 Support secret for network_key. https://github.com/Koenkk/zigbee2mqtt/issues/2209 2019-10-28 18:05:50 +01:00
Koen Kanters 78531a0878 Finish https://github.com/Koenkk/zigbee2mqtt/issues/2201. 2019-10-25 19:17:47 +02:00
Koenkk 505be311a4 Allow to store MQTT credentials separate from configuration.yaml. https://github.com/Koenkk/zigbee2mqtt/issues/2201 2019-10-25 18:43:14 +02:00
Koen Kanters 732a97ba0c Don’t write to configuration.yaml when it didn’t change. https://github.com/Koenkk/zigbee2mqtt/issues/2071 2019-10-03 20:06:31 +02:00
Koen Kanters c8eb503ae7 Simplify group optimistic mode. https://github.com/Koenkk/zigbee2mqtt/issues/764 2019-09-29 14:35:05 +02:00