Compare commits

..

No commits in common. "2470300be12facd98da88da37adc7635a16adcfa" and "7dfa195cd109dd61c81c303ed5727fa6d8a25c6c" have entirely different histories.

4 changed files with 28 additions and 14 deletions

View File

@ -6,6 +6,21 @@ 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);
@ -14,12 +29,16 @@ class HCMagicHome extends HCColorLamp {
throw new Error(`Required configuration field "address" is missing"`); throw new Error(`Required configuration field "address" is missing"`);
} }
let opts = { let type = "type1";
wait_for_reply: (this._configuration.reply !== undefined) ? this._configuration.reply : false, if (this._configuration.type != undefined) {
log_all_received: (this._configuration.logall !== undefined) ? this._configuration.logall : false, type = this._configuration.type;
}; }
this._control = new Control(this._configuration.address, opts); 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._sumanager = new StateUpdateManager(this._state); this._sumanager = new StateUpdateManager(this._state);
} }

View File

@ -1,6 +0,0 @@
## 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.3", "version": "1.0.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "hc-magichome", "name": "hc-magichome",
"version": "1.0.4", "version": "1.0.3",
"description": "Magic Home Plugin for Homecontrol", "description": "Magic Home Plugin for Homecontrol",
"main": "HCMagicHome.js", "main": "HCMagicHome.js",
"scripts": { "scripts": {
@ -14,6 +14,7 @@
"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"
} }
} }