aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2021-08-10 10:16:59 +0200
committerlonkaars <loek@pipeframe.xyz>2021-08-10 10:16:59 +0200
commit207cd3b9f419a025b00be47487f93e2422d433d9 (patch)
tree43428a182532c7a8b087fc4d598815178651012c
parent859d5d44633ab3afd2d5ebf060d16a88e99f80ff (diff)
lamp name and request error catch fixes
-rw-r--r--index.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/index.ts b/index.ts
index ddf93d3..e1b4406 100644
--- a/index.ts
+++ b/index.ts
@@ -34,7 +34,7 @@ export default class ESP8266RGBStrip implements AccessoryPlugin {
.setCharacteristic(this.api.hap.Characteristic.Manufacturer, 'nodemcu')
.setCharacteristic(this.api.hap.Characteristic.Model, 'esp8266');
- this.bulbService = new this.api.hap.Service.Lightbulb('White');
+ this.bulbService = new this.api.hap.Service.Lightbulb(this.name);
this.registerServices();
}
@@ -72,7 +72,10 @@ export default class ESP8266RGBStrip implements AccessoryPlugin {
v: Number(this.state.on && this.state.brightness),
});
var color = [rgb.red(), rgb.green(), rgb.blue()].map(i => Math.floor(i).toString(16).padStart(2, '0')).join('');
- if (color != this.lastMessage) axios.post('http://' + this.host, color);
+ if (color != this.lastMessage) {
+ axios.post('http://' + this.host, color)
+ .catch(() => this.log.warn('request failed'));
+ }
this.lastMessage = color;
}