initial commit

This commit is contained in:
jangxx 2019-01-25 16:15:03 +01:00
commit 995041845e
5 changed files with 94 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

3
.jshintrc Normal file
View File

@ -0,0 +1,3 @@
{
"esversion": 6
}

59
HCMagicHome.js Normal file
View File

@ -0,0 +1,59 @@
const {
HCColorLamp
} = require('homecontrol-control-base');
const { Control } = require('magic-home');
class HCMagicHome extends HCColorLamp {
constructor(config) {
super(config);
this._control = new Control(this._configuration.address, this._configuration.characteristics);
}
turnOn() {
return new Promise((resolve, reject) => {
this._control.turnOn((err) => {
if (err) return reject(err);
this._state.on = true;
this.emit("state change", this.state);
return resolve(err);
});
});
}
turnOff() {
return new Promise((resolve, reject) => {
this._control.turnOff((err) => {
if (err) return reject(err);
this._state.on = false;
this.emit("state change", this.state);
return resolve(err);
});
});
}
toggle() {
if(this._state.on) {
return this.turnOff();
} else {
return this.turnOn();
}
}
changeBrightness(brightness) {
}
changeColor(hue, sat, light) {
}
pullState() {
}
}
module.exports = HCMagicHome;

13
package-lock.json generated Normal file
View File

@ -0,0 +1,13 @@
{
"name": "hc-magichome",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"magic-home": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/magic-home/-/magic-home-1.4.0.tgz",
"integrity": "sha512-hSq3C/9rbEH3RB2t2rG/LsSb2vpalzIGh/mLKJyjaki3Wbvt9ss+2OUJ1JsAOAjjgkvxDEfbQ044yFsHZUS75A=="
}
}
}

18
package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "hc-magichome",
"version": "1.0.0",
"description": "Magic Home Plugin for Homecontrol",
"main": "HCMagicHome.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@git.literalchaos.de:jan/hc-magichome.git"
},
"author": "Jan Scheiper",
"license": "UNLICENSED",
"dependencies": {
"magic-home": "^1.4.0"
}
}