mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-16 18:39:09 -07:00
Reenable joining after 200 seconds. https://github.com/Koenkk/zigbee2mqtt/issues/1429 #1445
This commit is contained in:
parent
68d2d0a73d
commit
ba1eca82eb
@ -45,6 +45,7 @@ class Zigbee {
|
||||
this.onMessage = this.onMessage.bind(this);
|
||||
this.onError = this.onError.bind(this);
|
||||
this.messageHandler = null;
|
||||
this.permitJoinTimer = null;
|
||||
|
||||
this.queue = new ZigbeeQueue();
|
||||
}
|
||||
@ -130,6 +131,10 @@ class Zigbee {
|
||||
}
|
||||
|
||||
stop(callback) {
|
||||
if (this.permitJoinTimer) {
|
||||
clearInterval(this.permitJoinTimer);
|
||||
}
|
||||
|
||||
this.queue.stop();
|
||||
|
||||
// Backup coordinator
|
||||
@ -176,6 +181,24 @@ class Zigbee {
|
||||
logger.info('Zigbee: disabling joining new devices.');
|
||||
}
|
||||
|
||||
// In zigbee 3.0 a network automatically closes after 254 seconds.
|
||||
// As a workaround, we enable joining again.
|
||||
if (this.permitJoinTimer) {
|
||||
clearInterval(this.permitJoinTimer);
|
||||
}
|
||||
|
||||
if (permit) {
|
||||
this.permitJoinTimer = setInterval(() => {
|
||||
this.shepherd.permitJoin(255, (error) => {
|
||||
if (error) {
|
||||
logger.error('Failed to reenable joining');
|
||||
} else {
|
||||
logger.info('Succesfully reenabled joining');
|
||||
}
|
||||
});
|
||||
}, utils.secondsToMilliseconds(200));
|
||||
}
|
||||
|
||||
this.shepherd.permitJoin(permit ? 255 : 0, (error) => {
|
||||
if (error) {
|
||||
logger.info(error);
|
||||
|
Loading…
Reference in New Issue
Block a user