diff options
author | lonkaars <loek@pipeframe.xyz> | 2021-08-10 10:16:59 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2021-08-10 10:16:59 +0200 |
commit | 207cd3b9f419a025b00be47487f93e2422d433d9 (patch) | |
tree | 43428a182532c7a8b087fc4d598815178651012c | |
parent | 859d5d44633ab3afd2d5ebf060d16a88e99f80ff (diff) |
lamp name and request error catch fixes
-rw-r--r-- | index.ts | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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; } |