mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 05:24:29 +00:00
Publish bridge config. https://github.com/Koenkk/zigbee2mqtt/issues/626
This commit is contained in:
@@ -30,7 +30,7 @@ class BridgeConfig {
|
||||
}
|
||||
|
||||
permitJoin(topic, message) {
|
||||
this.zigbee.permitJoin(message.toString().toLowerCase() === 'true');
|
||||
this.zigbee.permitJoin(message.toString().toLowerCase() === 'true', () => this.publish());
|
||||
}
|
||||
|
||||
logLevel(topic, message) {
|
||||
@@ -42,6 +42,8 @@ class BridgeConfig {
|
||||
} else {
|
||||
logger.error(`Could not set log level to '${level}'. Allowed level: '${allowedLogLevels.join(',')}'`);
|
||||
}
|
||||
|
||||
this.publish();
|
||||
}
|
||||
|
||||
devices(topic, message) {
|
||||
@@ -136,6 +138,16 @@ class BridgeConfig {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
publish() {
|
||||
const topic = `${settings.get().mqtt.base_topic}/bridge/config`;
|
||||
const payload = {
|
||||
log_level: logger.transports.console.level,
|
||||
permit_join: this.zigbee.getPermitJoin(),
|
||||
};
|
||||
|
||||
this.mqtt.publish(topic, JSON.stringify(payload), {retain: true, qos: 0}, null);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BridgeConfig;
|
||||
|
||||
+9
-1
@@ -95,7 +95,7 @@ class Zigbee {
|
||||
logger.error(message);
|
||||
}
|
||||
|
||||
permitJoin(permit) {
|
||||
permitJoin(permit, callback) {
|
||||
if (permit) {
|
||||
logger.info('Zigbee: allowing new devices to join.');
|
||||
} else {
|
||||
@@ -106,9 +106,17 @@ class Zigbee {
|
||||
if (error) {
|
||||
logger.info(error);
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getPermitJoin() {
|
||||
return this.shepherd.controller._permitJoinTime === 255;
|
||||
}
|
||||
|
||||
getAllClients() {
|
||||
return this.getDevices().filter((device) => device.type !== 'Coordinator');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user