feat(yeelight): move to yeelight-wifi
Also add the configurator node, typescript & ejs. Close #29 #25 #24
This commit is contained in:
41
src/nodes/yeelight/YeelightConfigurator.ts
Normal file
41
src/nodes/yeelight/YeelightConfigurator.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
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 }
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user