2
0
Files
node-red-contrib-mi-devices/src/nodes/yeelight/YeelightConfigurator.ts
Pierre CLEMENT 13d4282923 feat(yeelight): move to yeelight-wifi
Also add the configurator node, typescript & ejs.
Close #29 #25 #24
2018-01-20 13:23:08 +01:00

42 lines
1.0 KiB
TypeScript

import { Red, NodeProperties, NodeStatus, ClearNodeStatus } from "node-red";
import { Constants } from "../constants";
import { Searcher } from "./Searcher";
export interface IYeelightConfiguratorNode {
ip:string;
sid:number;
bulb:any;
on(event: "bulbFound", listener: () => void): any;
}
export default (RED:Red) => {
class YeelightConfigurator {
ip:string;
sid:number;
_bulb:any;
constructor(props: NodeProperties) {
RED.nodes.createNode(<any> this, props);
let {ip, sid} = <any> props;
this.sid = sid;
this.ip = ip;
}
set bulb(bulb) {
this._bulb = bulb;
(<any> this).emit('bulbFound');
}
get bulb() {
return this._bulb;
}
}
RED.nodes.registerType(`${Constants.NODES_PREFIX}-yeelight configurator`, <any> YeelightConfigurator, {
settings: {
miDevicesYeelightConfiguratorDiscoveredBulbs: { value: Searcher.bulbs, exportable: true }
}
});
};