From c433bd513134d4bac37d181fe38abc89c7fd4683 Mon Sep 17 00:00:00 2001 From: Hugo Freire Date: Sun, 9 Dec 2018 11:50:33 +0100 Subject: [PATCH] fix: workaround for lifx's client that binds to UPD socket on init method --- src/clicks/lights/lifx-wrapper.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/clicks/lights/lifx-wrapper.js b/src/clicks/lights/lifx-wrapper.js index a4dbe500..33b95857 100644 --- a/src/clicks/lights/lifx-wrapper.js +++ b/src/clicks/lights/lifx-wrapper.js @@ -29,12 +29,6 @@ class LifxWrapper extends EventEmitter { this._client = new Client() - this._client.init(_.get(this._options, 'lifx')) - - this._client.on('light-new', (light) => this.emit('LightDiscovered', light)) - this._client.on('light-online', (light) => this.emit('LightOnline', light)) - this._client.on('light-offline', (light) => this.emit('LightOffline', light)) - Health.addCheck('lifx', async () => { if (!this._client) { throw new Error('Unable to connect to lifx lights') @@ -43,6 +37,12 @@ class LifxWrapper extends EventEmitter { } start () { + this._client.init(_.get(this._options, 'lifx')) + + this._client.on('light-new', (light) => this.emit('LightDiscovered', light)) + this._client.on('light-online', (light) => this.emit('LightOnline', light)) + this._client.on('light-offline', (light) => this.emit('LightOffline', light)) + this._client.startDiscovery() }