aboutsummaryrefslogtreecommitdiff
path: root/plugin.ts
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2021-08-05 17:42:06 +0200
committerlonkaars <loek@pipeframe.xyz>2021-08-05 17:42:06 +0200
commitc2920dbb3a80d7f46bc968864987cf12587d546b (patch)
tree41d43a45916302c1813b64788fc542d01799fcda /plugin.ts
parent34144332104dbbb2c1243ccfac79a8f81516e53d (diff)
less jankyness
Diffstat (limited to 'plugin.ts')
-rw-r--r--plugin.ts30
1 files changed, 20 insertions, 10 deletions
diff --git a/plugin.ts b/plugin.ts
index 318d56c..65abe0d 100644
--- a/plugin.ts
+++ b/plugin.ts
@@ -34,12 +34,12 @@ export default class BekenBridge implements AccessoryPlugin {
this.whiteState = {
on: false,
- brt: 0,
+ brt: 100,
};
this.rgbState = {
on: false,
- brt: 0,
+ brt: 100,
sat: 0,
hue: 0,
};
@@ -56,48 +56,58 @@ export default class BekenBridge implements AccessoryPlugin {
}
registerWhiteBulbServices() {
+ var setOn = (on: boolean) => {
+ this.whiteState.on = on;
+ if (this.rgbState.on) {
+ this.RGBBulbService.getCharacteristic(this.api.hap.Characteristic.On).setValue(false);
+ }
+ };
this.whiteBulbService.getCharacteristic(this.api.hap.Characteristic.On)
.onGet(() => this.whiteState.on)
.onSet((on: boolean) => {
- this.whiteState.on = on;
- if (this.rgbState.on) {
- this.RGBBulbService.getCharacteristic(this.api.hap.Characteristic.On).setValue(false);
- }
+ setOn(on);
this.updateLamp();
});
this.whiteBulbService.getCharacteristic(this.api.hap.Characteristic.Brightness)
.onGet(() => this.whiteState.brt)
.onSet((brt: number) => {
+ setOn(true);
this.whiteState.brt = brt;
this.updateLamp();
});
}
registerRGBBulbServices() {
+ var setOn = (on: boolean) => {
+ this.rgbState.on = on;
+ if (this.whiteState.on) {
+ this.whiteBulbService.getCharacteristic(this.api.hap.Characteristic.On).setValue(false);
+ }
+ };
this.RGBBulbService.getCharacteristic(this.api.hap.Characteristic.On)
.onGet(() => this.rgbState.on)
.onSet((on: boolean) => {
- this.rgbState.on = on;
- if (this.whiteState.on) {
- this.whiteBulbService.getCharacteristic(this.api.hap.Characteristic.On).setValue(false);
- }
+ setOn(on);
this.updateLamp();
});
this.RGBBulbService.getCharacteristic(this.api.hap.Characteristic.Brightness)
.onGet(() => this.rgbState.brt)
.onSet((brt: number) => {
+ setOn(true);
this.rgbState.brt = brt;
this.updateLamp();
});
this.RGBBulbService.getCharacteristic(this.api.hap.Characteristic.Hue)
.onGet(() => this.rgbState.hue)
.onSet((hue: number) => {
+ setOn(true);
this.rgbState.hue = hue;
this.updateLamp();
});
this.RGBBulbService.getCharacteristic(this.api.hap.Characteristic.Saturation)
.onGet(() => this.rgbState.sat)
.onSet((sat: number) => {
+ setOn(true);
this.rgbState.sat = sat;
this.updateLamp();
});