Log zigbee publish errors to MQTT. #1123

This commit is contained in:
Koen Kanters
2019-02-20 17:57:28 +01:00
parent 14f5c4d3c9
commit ec0ee53c7a
2 changed files with 17 additions and 1 deletions
+11
View File
@@ -102,6 +102,15 @@ class DevicePublish {
return {type: type, ID: ID, postfix: postfix};
}
handlePublishError(entity, message, error) {
const meta = {
entity,
message: message.toString(),
};
this.mqtt.log('zigbee_publish_error', error.toString(), meta);
}
handlePublished(entity, topic, converter, converted) {
if (entity.type === 'device' && topic.type === 'set') {
// Devices do not report when they go off, this ensures state (on/off) is always in sync.
@@ -216,6 +225,8 @@ class DevicePublish {
(error, rsp) => {
if (!error) {
this.handlePublished(entity, topic, converter, converted);
} else {
this.handlePublishError(entity, message, error);
}
}
);
+6 -1
View File
@@ -95,8 +95,13 @@ class MQTT {
this.client.publish(topic, payload, options, callback);
}
log(type, message) {
log(type, message, meta=null) {
const payload = {type: type, message: message};
if (meta) {
payload.meta = meta;
}
this.publish('bridge/log', JSON.stringify(payload), {retain: false});
}
}