Skip to content

Commit

Permalink
Log more to MQTT. Koenkk#1075
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Feb 13, 2019
1 parent f0e4604 commit cb3610b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/extension/bind.js
Expand Up @@ -109,6 +109,11 @@ class Bind {
`Successfully ${topic.type === 'bind' ? 'bound' : 'unbound'} cluster '${cluster}' from ` +
`${sourceEntity.ID}' to '${targetEntity.ID}'`
);

this.mqtt.log(
`device_${topic.type}`,
{from: sourceEntity.ID, to: targetEntity.ID, cluster: cluster}
);
}

queueCallback();
Expand Down
2 changes: 2 additions & 0 deletions lib/extension/bridgeConfig.js
Expand Up @@ -84,6 +84,7 @@ class BridgeConfig {

if (settings.changeFriendlyName(json.old, json.new)) {
logger.info(`Successfully renamed - ${json.old} to ${json.new} `);
this.mqtt.log('device_renamed', {from: json.old, to: json.new});
} else {
logger.error(`Failed to renamed - ${json.old} to ${json.new}`);
return;
Expand Down Expand Up @@ -131,6 +132,7 @@ class BridgeConfig {

onMQTTConnected() {
this.mqtt.subscribe(`${settings.get().mqtt.base_topic}/bridge/config/+`);
this.publish();
}

onMQTTMessage(topic, message) {
Expand Down
8 changes: 8 additions & 0 deletions lib/extension/groups.js
Expand Up @@ -80,6 +80,14 @@ class Groups {
logger.error(`Failed to ${topic.type} ${ieeeAddr} from ${topic.friendly_name}`);
} else {
logger.info(`Successfully ${topic.type} ${ieeeAddr} to ${topic.friendly_name}`);

// Log to MQTT
const log = {device: message};
if (['remove', 'add'].includes(topic.type)) {
log.group = topic.friendly_name;
}

this.mqtt.log(log);
}
};

Expand Down

0 comments on commit cb3610b

Please sign in to comment.