updated dependency and glue code
This commit is contained in:
parent
8ca3dece00
commit
4d968f6670
64
HCTPLink.js
64
HCTPLink.js
@ -14,64 +14,38 @@ class HCTPLink extends HCSwitch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
turnOn() {
|
turnOn() {
|
||||||
return new Promise((resolve, reject) => {
|
let tp = new TPLink(this._configuration.address);
|
||||||
let tp = new TPLink(this._configuration.address, (err) => {
|
|
||||||
if (err) return reject(err);
|
|
||||||
|
|
||||||
tp.turnOn((parsed, resp) => {
|
return tp.turnOn().then(resp => {
|
||||||
if (!parsed) return reject("Could not parse response");
|
if (resp.system.set_relay_state.err_code == 0) {
|
||||||
|
this._state.on = true;
|
||||||
if (resp.system.set_relay_state.err_code == 0) {
|
this.emit("state change", this.state);
|
||||||
this._state.on = true;
|
}
|
||||||
this.emit("state change", this.state);
|
|
||||||
return resolve();
|
|
||||||
} else {
|
|
||||||
return reject("Could not parse response");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
turnOff() {
|
turnOff() {
|
||||||
return new Promise((resolve, reject) => {
|
let tp = new TPLink(this._configuration.address);
|
||||||
let tp = new TPLink(this._configuration.address, (err) => {
|
|
||||||
if (err) return reject(err);
|
|
||||||
|
|
||||||
tp.turnOff((parsed, resp) => {
|
return tp.turnOff().then(resp => {
|
||||||
if (!parsed) return reject("Could not parse response");
|
if (resp.system.set_relay_state.err_code == 0) {
|
||||||
|
this._state.on = false;
|
||||||
if (resp.system.set_relay_state.err_code == 0) {
|
this.emit("state change", this.state);
|
||||||
this._state.on = false;
|
}
|
||||||
this.emit("state change", this.state);
|
|
||||||
return resolve();
|
|
||||||
} else {
|
|
||||||
return reject("Could not parse response");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pullState() {
|
pullState() {
|
||||||
return new Promise((resolve, reject) => {
|
let tp = new TPLink(this._configuration.address);
|
||||||
let tp = new TPLink(this._configuration.address, (err) => {
|
|
||||||
if (err) return reject(err);
|
|
||||||
|
|
||||||
tp.getInfo((parsed, resp) => {
|
return tp.query().then(resp => {
|
||||||
if (parsed) {
|
let hashBefore = this.state.hash;
|
||||||
let hashBefore = this.state.hash;
|
|
||||||
|
|
||||||
this._state.on = (resp.system.get_sysinfo.relay_state == 1);
|
this._state.on = (resp.system.get_sysinfo.relay_state == 1);
|
||||||
|
|
||||||
if (this.state.hash != hashBefore) {
|
if (this.state.hash != hashBefore) {
|
||||||
this.emit("state change", this.state);
|
this.emit("state change", this.state);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hc-tplink-smartplug",
|
"name": "hc-tplink-smartplug",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -31,9 +31,9 @@
|
|||||||
"integrity": "sha512-JQVqSM5/mOaUoUhCYR0t1vgm8RFo7qpJtPvnoFCLeqQh1xrfmr3BCD3nGBnACzpIEF7F7EVgqGD3O4lao/BY/A=="
|
"integrity": "sha512-JQVqSM5/mOaUoUhCYR0t1vgm8RFo7qpJtPvnoFCLeqQh1xrfmr3BCD3nGBnACzpIEF7F7EVgqGD3O4lao/BY/A=="
|
||||||
},
|
},
|
||||||
"tplink-smartplug-node": {
|
"tplink-smartplug-node": {
|
||||||
"version": "1.1.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/tplink-smartplug-node/-/tplink-smartplug-node-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/tplink-smartplug-node/-/tplink-smartplug-node-2.0.0.tgz",
|
||||||
"integrity": "sha1-aDaXXWRlpSo+tn0tB4kCjdPD3FE="
|
"integrity": "sha512-IoZOLJjLb6/NwuHmfmljgFTf2NrKIXsHr2CkO8KgWhMAh9xJVsMdzmocOdGLokO2yWd1MxHzYPkxJQgtLxSNPA=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hc-tplink-smartplug",
|
"name": "hc-tplink-smartplug",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"description": "TP-Link Smart Plug Plugin for Homecontrol",
|
"description": "TP-Link Smart Plug Plugin for Homecontrol",
|
||||||
"main": "HCTPLink.js",
|
"main": "HCTPLink.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -14,6 +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",
|
||||||
"tplink-smartplug-node": "^1.1.0"
|
"tplink-smartplug-node": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user