diff --git a/lib/zigbee.js b/lib/zigbee.js index 15eb821a..81180682 100644 --- a/lib/zigbee.js +++ b/lib/zigbee.js @@ -28,12 +28,25 @@ class Zigbee { this.shepherd.start((error) => { if (error) { - logger.error('Error while starting zigbee-shepherd!'); + logger.warn('Error while starting zigbee-shepherd, attemping to fix...'); + this.shepherd.controller._znp.close((() => null)); + logger.info(`Starting zigbee-shepherd`); + + setTimeout(() => { + this.shepherd.start((error) => { + if (error) { + logger.error('Error while starting zigbee-shepherd!'); + callback(error); + } else { + logger.info('zigbee-shepherd started'); + callback(null); + } + }); + }, 5 * 1000); } else { logger.info('zigbee-shepherd started'); + callback(null); } - - callback(error); }); // Register callbacks.