From cf4e9aaf76c84a302b0b34cda02305b8d1aa9ac4 Mon Sep 17 00:00:00 2001 From: jangxx Date: Sat, 2 Mar 2019 13:46:19 +0100 Subject: [PATCH] removed merge-options as well as useless characteristics parameter, added readme --- HCMagicHome.js | 29 +++++------------------------ README.md | 6 ++++++ package-lock.json | 2 +- package.json | 3 +-- 4 files changed, 13 insertions(+), 27 deletions(-) create mode 100644 README.md diff --git a/HCMagicHome.js b/HCMagicHome.js index e94cdad..f63dd1b 100644 --- a/HCMagicHome.js +++ b/HCMagicHome.js @@ -6,21 +6,6 @@ const { const { Control } = require('magic-home'); const mergeOptions = require('merge-options'); -const types = Object.freeze({ - type1: { - rgb_min_0: true, - ww_min_0: true, - set_color_magic_bytes: [0xf0, 0x0f], - wait_for_reply: true - }, - type2: { - rgb_min_0: false, - ww_min_0: false, - set_color_magic_bytes: [0x00, 0x0f], - wait_for_reply: false - }, -}); - class HCMagicHome extends HCColorLamp { constructor(config) { super(config); @@ -29,16 +14,12 @@ class HCMagicHome extends HCColorLamp { throw new Error(`Required configuration field "address" is missing"`); } - let type = "type1"; - if (this._configuration.type != undefined) { - type = this._configuration.type; - } + let opts = { + wait_for_reply: (this._configuration.reply !== undefined) ? this._configuration.reply : false, + log_all_received: (this._configuration.logall !== undefined) ? this._configuration.logall : false, + }; - if (!(type in types)) throw new Error(`Type "${type}" could not be found`); - - let characteristics = mergeOptions(types[type], this._configuration.characteristics); - - this._control = new Control(this._configuration.address, characteristics); + this._control = new Control(this._configuration.address, opts); this._sumanager = new StateUpdateManager(this._state); } diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c56274 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +## Configuration + +- `reply` +Sets `wait_for_reply` in the constructor. +- `logall` +Sets `log_all_received` in the constructor. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f8b3f36..cebe164 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hc-magichome", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index dfc06cf..c2022c1 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "license": "UNLICENSED", "dependencies": { "homecontrol-control-base": "git+https://git.literalchaos.de/jan/homecontrol-control-base.git", - "magic-home": "^2.0.1", - "merge-options": "^1.0.1" + "magic-home": "^2.0.1" } }