UNPKG

yeelight-awesome

Version:

The node.js client api to control yeelight device over WIFI

112 lines 4.08 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __spreadArray = (this && this.__spreadArray) || function (to, from) { for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i]; return to; }; exports.__esModule = true; exports.CfScene = exports.CtScene = exports.HsvScene = exports.ColorScene = exports.Scene = void 0; var enums_1 = require("./enums"); var Scene = /** @class */ (function () { function Scene(type) { this.type = type; } Scene.prototype.getData = function () { return null; }; return Scene; }()); exports.Scene = Scene; // tslint:disable-next-line:max-classes-per-file var ColorScene = /** @class */ (function (_super) { __extends(ColorScene, _super); function ColorScene(color, bright) { var _this = _super.call(this, enums_1.SceneType.COLOR) || this; _this.color = color; _this.bright = bright; return _this; } ColorScene.prototype.getData = function () { return [this.type, this.color.getValue(), this.bright]; }; return ColorScene; }(Scene)); exports.ColorScene = ColorScene; // tslint:disable-next-line:max-classes-per-file var HsvScene = /** @class */ (function (_super) { __extends(HsvScene, _super); function HsvScene(hue, satuation, brightness) { var _this = _super.call(this, enums_1.SceneType.HSV) || this; _this.hue = hue; _this.satuation = satuation; _this.brightness = brightness; return _this; } HsvScene.prototype.getData = function () { return [this.type, this.hue, this.satuation, this.brightness]; }; return HsvScene; }(Scene)); exports.HsvScene = HsvScene; /** * change the smart LED to specified ct and brightness */ // tslint:disable-next-line:max-classes-per-file var CtScene = /** @class */ (function (_super) { __extends(CtScene, _super); /** * @constructor * @param temperature : K temperature value * @param brightness max brightness level */ function CtScene(temperature, brightness) { var _this = _super.call(this, enums_1.SceneType.CT) || this; _this.temperature = temperature; _this.brightness = brightness; return _this; } CtScene.prototype.getData = function () { return [this.type, this.temperature, this.brightness]; }; return CtScene; }(Scene)); exports.CtScene = CtScene; // tslint:disable-next-line:max-classes-per-file var CfScene = /** @class */ (function (_super) { __extends(CfScene, _super); /** * @constructor * @param flowAction The LED behavior after flow finish * @param states : The set of state changes * @param repeat : number of repeas. 0 is infinity */ function CfScene(flowAction, states, repeat) { var _this = _super.call(this, enums_1.SceneType.CF) || this; _this.flowAction = flowAction; _this.states = states; _this.repeat = repeat; return _this; } CfScene.prototype.getData = function () { var list = this.states.reduce(function (a, b) { return __spreadArray(__spreadArray([], a), b.getState()); }, []); return [this.type, this.repeat, this.flowAction, list.join(",")]; }; return CfScene; }(Scene)); exports.CfScene = CfScene; //# sourceMappingURL=scene.js.map