version 1.0.0
This commit is contained in:
commit
951a4fc3bc
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules/
|
||||||
68
HCrcswitch.js
Normal file
68
HCrcswitch.js
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
const {
|
||||||
|
HCSwitch
|
||||||
|
} = require('homecontrol-control-base');
|
||||||
|
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
|
let rcswitch;
|
||||||
|
|
||||||
|
if(os.arch() == 'arm' || os.arch() == 'arm64') {
|
||||||
|
rcswitch = require('rcswitch');
|
||||||
|
} else {
|
||||||
|
/**
|
||||||
|
* "Polyfill" for development purposes. Should run correctly on actual Raspberry PI hardware
|
||||||
|
*/
|
||||||
|
rcswitch = {
|
||||||
|
switchOn: function() {
|
||||||
|
console.log("switchOn", arguments);
|
||||||
|
},
|
||||||
|
switchOff: function() {
|
||||||
|
console.log("switchOff", arguments);
|
||||||
|
},
|
||||||
|
enableTransmit: function() {
|
||||||
|
console.log("enableTransmit", arguments);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class HCrcswitch extends HCSwitch {
|
||||||
|
constructor(config) {
|
||||||
|
super(config);
|
||||||
|
|
||||||
|
if (!("pin" in this._configuration)) {
|
||||||
|
throw new Error(`Required configuration field "address" is missing"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!("group" in this._configuration)) {
|
||||||
|
throw new Error(`Required configuration field "group" is missing"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!("switch" in this._configuration)) {
|
||||||
|
throw new Error(`Required configuration field "switch" is missing"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
rcswitch.enableTransmit(this._configuration.pin);
|
||||||
|
}
|
||||||
|
|
||||||
|
turnOn() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
rcswitch.switchOn(this._configuration.group, this._configuration.switch);
|
||||||
|
|
||||||
|
this._state.on = true;
|
||||||
|
this.emit("state change", this.state);
|
||||||
|
return resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
turnOff() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
rcswitch.switchOff(this._configuration.group, this._configuration.switch);
|
||||||
|
|
||||||
|
this._state.on = false;
|
||||||
|
this.emit("state change", this.state);
|
||||||
|
return resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = HCrcswitch;
|
||||||
65
package-lock.json
generated
Normal file
65
package-lock.json
generated
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"name": "hc-rcswitch",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
|
"dependencies": {
|
||||||
|
"bindings": {
|
||||||
|
"version": "1.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.4.0.tgz",
|
||||||
|
"integrity": "sha512-7znEVX22Djn+nYjxCWKDne0RRloa9XfYa84yk3s+HkE3LpDYZmhArYr9O9huBoHY3/oXispx5LorIX7Sl2CgSQ==",
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"file-uri-to-path": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"file-uri-to-path": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"homecontrol-control-base": {
|
||||||
|
"version": "git+https://git.literalchaos.de/jan/homecontrol-control-base.git#809acfad8245dad9d974cba5b1eff2dfc5419cc9",
|
||||||
|
"from": "git+https://git.literalchaos.de/jan/homecontrol-control-base.git",
|
||||||
|
"requires": {
|
||||||
|
"merge-options": "^1.0.1",
|
||||||
|
"node-object-hash": "^1.4.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"is-plain-obj": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
|
||||||
|
"integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4="
|
||||||
|
},
|
||||||
|
"merge-options": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/merge-options/-/merge-options-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-iuPV41VWKWBIOpBsjoxjDZw8/GbSfZ2mk7N1453bwMrfzdrIk7EzBd+8UVR6rkw67th7xnk9Dytl3J+lHPdxvg==",
|
||||||
|
"requires": {
|
||||||
|
"is-plain-obj": "^1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nan": {
|
||||||
|
"version": "2.12.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz",
|
||||||
|
"integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"node-object-hash": {
|
||||||
|
"version": "1.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-object-hash/-/node-object-hash-1.4.1.tgz",
|
||||||
|
"integrity": "sha512-JQVqSM5/mOaUoUhCYR0t1vgm8RFo7qpJtPvnoFCLeqQh1xrfmr3BCD3nGBnACzpIEF7F7EVgqGD3O4lao/BY/A=="
|
||||||
|
},
|
||||||
|
"rcswitch": {
|
||||||
|
"version": "0.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rcswitch/-/rcswitch-0.3.1.tgz",
|
||||||
|
"integrity": "sha1-zJGN+cUwaczWQycC46cIjcqiwy8=",
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"bindings": "^1.2.1",
|
||||||
|
"nan": "^2.0.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
package.json
Normal file
21
package.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "hc-rcswitch",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "rcswitch integration for Homecontrol",
|
||||||
|
"main": "HCrcswitch.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.literalchaos.de/jan/hc-rcswitch"
|
||||||
|
},
|
||||||
|
"author": "Jan Scheiper",
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"dependencies": {
|
||||||
|
"homecontrol-control-base": "git+https://git.literalchaos.de/jan/homecontrol-control-base.git"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"rcswitch": "^0.3.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user