mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-16 18:39:09 -07:00
Allow joining through specified device.
This commit is contained in:
parent
da06e87276
commit
bf85ea1494
@ -396,7 +396,16 @@ class Controller {
|
||||
const option = topic.split('/').slice(-1)[0];
|
||||
|
||||
if (option === 'permit_join') {
|
||||
this.zigbee.permitJoin(message.toString().toLowerCase() === 'true');
|
||||
const msg = message.toString().toLowerCase();
|
||||
let type = 'all';
|
||||
let join = msg === 'true';
|
||||
|
||||
if (!['true', 'false'].includes(msg)) {
|
||||
join = true;
|
||||
type = parseInt(msg);
|
||||
}
|
||||
|
||||
this.zigbee.permitJoin(join, type);
|
||||
} else if (option === 'log_level') {
|
||||
const level = message.toString().toLowerCase();
|
||||
if (allowedLogLevels.includes(level)) {
|
||||
|
@ -113,14 +113,14 @@ class Zigbee {
|
||||
logger.error(message);
|
||||
}
|
||||
|
||||
permitJoin(permit) {
|
||||
permitJoin(permit, type='all') {
|
||||
if (permit) {
|
||||
logger.info('Zigbee: allowing new devices to join.');
|
||||
logger.info(`Zigbee: allowing new devices to join. (${type})`);
|
||||
} else {
|
||||
logger.info('Zigbee: disabling joining new devices.');
|
||||
logger.info(`Zigbee: disabling joining new devices. (${type})`);
|
||||
}
|
||||
|
||||
this.shepherd.permitJoin(permit ? 255 : 0, (error) => {
|
||||
this.shepherd.permitJoin(permit ? 255 : 0, type, (error) => {
|
||||
if (error) {
|
||||
logger.info(error);
|
||||
}
|
||||
@ -190,13 +190,13 @@ class Zigbee {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info(`Zigbee publish to '${deviceID}', ${cid} - ${cmd}
|
||||
- ${JSON.stringify(zclData)} - ${JSON.stringify(cfg)} - ${ep}`);
|
||||
logger.info(`Zigbee publish to '${deviceID}', ${cid} - ${cmd}` +
|
||||
`- ${JSON.stringify(zclData)} - ${JSON.stringify(cfg)} - ${ep}`);
|
||||
|
||||
const callback_ = (error) => {
|
||||
if (error) {
|
||||
logger.error(
|
||||
`Zigbee publish to '${deviceID}', ${cid} - ${cmd} - ${JSON.stringify(zclData)}
|
||||
`Zigbee publish to '${deviceID}', ${cid} - ${cmd} - ${JSON.stringify(zclData)}
|
||||
- ${JSON.stringify(cfg)} - ${ep} ` +
|
||||
`failed with error ${error}`);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user