diff --git a/nodes/shepherd.js b/nodes/shepherd.js index 7ee57bf..a45b1ab 100644 --- a/nodes/shepherd.js +++ b/nodes/shepherd.js @@ -619,18 +619,21 @@ module.exports = function (RED) { this.proxy.emit('ready'); this.status = 'connected'; this.proxy.emit('nodeStatus', {fill: 'green', shape: 'dot', text: 'connected'}); - this.herdsman.supportsLED().then(supportsLED => { - if (supportsLED === true) { - this.herdsman.setLED(this.led === 'enabled').then(() => { - this.debug(`setLED successfully set ${this.led}`); - }).catch(error => { - this.error(`setLED failed to set ${this.led} ${error.message}`); - }); - } else if (this.led === 'enabled') { - this.error('Setting LED not supported on this adapter. To avoid this message at startup, set CC2531 LED to \'disabled\' in controller node'); - } - }); - + + if (this.herdsman.supportsLED !== undefined) + { + this.herdsman.supportsLED().then(supportsLED => { + if (supportsLED === true) { + this.herdsman.setLED(this.led === 'enabled').then(() => { + this.debug(`setLED successfully set ${this.led}`); + }).catch(error => { + this.error(`setLED failed to set ${this.led} ${error.message}`); + }); + } else if (this.led === 'enabled') { + this.error('Setting LED not supported on this adapter. To avoid this message at startup, set CC2531 LED to \'disabled\' in controller node'); + } + }); + } this.checkOverdueInterval = setInterval(() => { this.checkOverdue(); }, 60 * 1000); @@ -653,9 +656,12 @@ module.exports = function (RED) { this.status = error.message; this.proxy.emit('nodeStatus', {fill: 'red', shape: 'ring', text: error.message + ', retrying'}); this.error(error.message); - setTimeout(() => { - this.connect(); - }, 10000); + + this.herdsman.stop().finally().then( () => { + setTimeout(() => { + this.connect(); + }, 10000); + }); }).finally(() => { this.connecting = false; });