hue-hacking-node
Version:
Utility to control Philips Hue light bulbs
120 lines • 4.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RGB = exports.XYPoint = exports.HueBridgeGroupActionResponse = exports.HueBridgeStateChangeResponse = exports.HueUPNPResponse = exports.HueBridge = void 0;
exports.clampToRange = clampToRange;
var HueBridge = /** @class */ (function () {
function HueBridge() {
}
return HueBridge;
}());
exports.HueBridge = HueBridge;
var HueUPNPResponse = /** @class */ (function () {
function HueUPNPResponse(data) {
if (data) {
if (data.id && typeof data.id === 'string') {
this.id = data.id;
}
if (data.internalipaddress &&
typeof data.internalipaddress === 'string') {
this.internalipaddress = data.internalipaddress;
}
}
}
return HueUPNPResponse;
}());
exports.HueUPNPResponse = HueUPNPResponse;
var HueBridgeStateChangeResponse = /** @class */ (function () {
function HueBridgeStateChangeResponse(response) {
var changedStates = [];
for (var _i = 0, response_1 = response; _i < response_1.length; _i++) {
var update = response_1[_i];
var changedState = void 0;
for (var key in update.success) {
if (key.includes("/lights/") && key.includes("/state/")) {
changedState = {
attribute: key,
value: update.success[key]
};
}
}
if (changedState != undefined &&
changedState.attribute != undefined &&
changedState.value != undefined) {
changedStates.push(changedState);
}
}
this.changedStates = changedStates;
}
return HueBridgeStateChangeResponse;
}());
exports.HueBridgeStateChangeResponse = HueBridgeStateChangeResponse;
var HueBridgeGroupActionResponse = /** @class */ (function () {
function HueBridgeGroupActionResponse(response) {
var acknowledgedActions = [];
for (var _i = 0, response_2 = response; _i < response_2.length; _i++) {
var update = response_2[_i];
acknowledgedActions.push(update.success);
}
this.acknowledgedActions = acknowledgedActions;
}
return HueBridgeGroupActionResponse;
}());
exports.HueBridgeGroupActionResponse = HueBridgeGroupActionResponse;
/**
* Clamp a provided value into a range such that min <= value <= max.
*
* @param min Smallest possible acceptable value
* @param max Largest possible acceptable value
* @param value Value that must be between min and max, inclusive
*/
function clampToRange(min, max, value) {
return Math.min(Math.max(min, value), max);
}
/**
* Convenience wrapper class around the two floating point numbers that represent
* a position in the CIE 1931 color gamut triangle.
*/
var XYPoint = /** @class */ (function () {
function XYPoint() {
var xy = [];
for (var _i = 0; _i < arguments.length; _i++) {
xy[_i] = arguments[_i];
}
this.x = xy[0];
this.y = xy[1];
}
/** Return a human readable representation of this XYPoint instance. */
XYPoint.prototype.toString = function () {
return "{x: ".concat(this.x, ", y: ").concat(this.y, "}");
};
return XYPoint;
}());
exports.XYPoint = XYPoint;
/**
* Convenience wrapper class around the three 0-255 range integer values representing
* a traditional RGB color.
*/
var RGB = /** @class */ (function () {
function RGB() {
var rgb = [];
for (var _i = 0; _i < arguments.length; _i++) {
rgb[_i] = arguments[_i];
}
this.r = clampToRange(RGB.MIN, RGB.MAX, rgb[0] || 0);
this.g = clampToRange(RGB.MIN, RGB.MAX, rgb[1] || 0);
this.b = clampToRange(RGB.MIN, RGB.MAX, rgb[2] || 0);
}
/** Return a human-readable representation of this RGB color value. */
RGB.prototype.toString = function () {
return "r: ".concat(this.r, ", g: ").concat(this.g, ", b: ").concat(this.b);
};
/** Return a usable CSS rgb() function notation representation of this RGB color value. */
RGB.prototype.toCssString = function () {
return "rgb(".concat(this.r, ", ").concat(this.g, ", ").concat(this.b, ")");
};
RGB.MIN = 0;
RGB.MAX = 255;
return RGB;
}());
exports.RGB = RGB;
//# sourceMappingURL=hue-interfaces.js.map