doc(main): update documentation and flows
This commit is contained in:
43
dist/nodes/yeelight/YeelightConfigurator.js
vendored
Normal file
43
dist/nodes/yeelight/YeelightConfigurator.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const constants_1 = require("../constants");
|
||||
const YeelightServer_1 = require("../../devices/yeelight/YeelightServer");
|
||||
exports.default = (RED) => {
|
||||
class YeelightConfigurator {
|
||||
constructor(props) {
|
||||
RED.nodes.createNode(this, props);
|
||||
let { sid } = props;
|
||||
this.sid = parseInt(sid);
|
||||
if (this.sid) {
|
||||
this.setBulb();
|
||||
}
|
||||
let server = YeelightServer_1.YeelightServer.getInstance();
|
||||
server.on('yeelight-online', (sid) => {
|
||||
if (sid === this.sid) {
|
||||
this.setBulb();
|
||||
this.emit('bulb-online');
|
||||
}
|
||||
});
|
||||
server.on('yeelight-offline', (sid) => {
|
||||
if (sid === this.sid) {
|
||||
this._bulb = null;
|
||||
this.emit('bulb-offline');
|
||||
}
|
||||
});
|
||||
}
|
||||
setBulb() {
|
||||
this._bulb = YeelightServer_1.YeelightServer.getInstance().getBulb(this.sid);
|
||||
}
|
||||
get bulb() {
|
||||
return this._bulb;
|
||||
}
|
||||
}
|
||||
RED.nodes.registerType(`${constants_1.Constants.NODES_PREFIX}-yeelight configurator`, YeelightConfigurator, {
|
||||
settings: {
|
||||
miDevicesYeelightConfiguratorDiscoveredBulbs: {
|
||||
value: YeelightServer_1.YeelightServer.getInstance().bulbs,
|
||||
exportable: true
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user