mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 23:00:55 +00:00
Log zigbee publish errors to MQTT. #1123
This commit is contained in:
@@ -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
@@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user