removed merge-options as well as useless characteristics parameter, added readme

This commit is contained in:
jangxx 2019-03-02 13:46:19 +01:00
parent 7dfa195cd1
commit cf4e9aaf76
4 changed files with 13 additions and 27 deletions

View File

@ -6,21 +6,6 @@ const {
const { Control } = require('magic-home'); const { Control } = require('magic-home');
const mergeOptions = require('merge-options'); 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 { class HCMagicHome extends HCColorLamp {
constructor(config) { constructor(config) {
super(config); super(config);
@ -29,16 +14,12 @@ class HCMagicHome extends HCColorLamp {
throw new Error(`Required configuration field "address" is missing"`); throw new Error(`Required configuration field "address" is missing"`);
} }
let type = "type1"; let opts = {
if (this._configuration.type != undefined) { wait_for_reply: (this._configuration.reply !== undefined) ? this._configuration.reply : false,
type = this._configuration.type; log_all_received: (this._configuration.logall !== undefined) ? this._configuration.logall : false,
} };
if (!(type in types)) throw new Error(`Type "${type}" could not be found`); this._control = new Control(this._configuration.address, opts);
let characteristics = mergeOptions(types[type], this._configuration.characteristics);
this._control = new Control(this._configuration.address, characteristics);
this._sumanager = new StateUpdateManager(this._state); this._sumanager = new StateUpdateManager(this._state);
} }

6
README.md Normal file
View File

@ -0,0 +1,6 @@
## Configuration
- `reply`
Sets `wait_for_reply` in the constructor.
- `logall`
Sets `log_all_received` in the constructor.

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "hc-magichome", "name": "hc-magichome",
"version": "1.0.2", "version": "1.0.3",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -14,7 +14,6 @@
"license": "UNLICENSED", "license": "UNLICENSED",
"dependencies": { "dependencies": {
"homecontrol-control-base": "git+https://git.literalchaos.de/jan/homecontrol-control-base.git", "homecontrol-control-base": "git+https://git.literalchaos.de/jan/homecontrol-control-base.git",
"magic-home": "^2.0.1", "magic-home": "^2.0.1"
"merge-options": "^1.0.1"
} }
} }