homecontrol-control-base/states/ColorlampState.js

48 lines
826 B
JavaScript

const mergeOptions = require('merge-options');
const BaseState = require('./BaseState');
class ColorlampState extends BaseState {
constructor(cloneObj) {
super();
let cloneState = mergeOptions(ColorlampState.default, cloneObj);
this.on = cloneState.on;
this.brightness = cloneState.brightness;
this.color = {
hue: cloneState.color.hue,
sat: cloneState.color.sat,
l: cloneState.color.l
};
this.effect = cloneState.effect;
}
static get default() {
return {
on: false,
brightness: 0,
color: {
hue: 0,
sat: 0,
l: 0
},
effect: "none"
};
}
get asObj() {
return {
on: this.on,
brightness: this.brightness,
color: {
hue: this.color.hue,
sat: this.color.sat,
l: this.color.l
},
effect: this.effect
};
}
}
module.exports = ColorlampState;