From 207cd3b9f419a025b00be47487f93e2422d433d9 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Tue, 10 Aug 2021 10:16:59 +0200 Subject: lamp name and request error catch fixes --- index.ts | 7 +++++-- 1 file 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; } -- cgit v1.2.3