mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-27 21:20:03 +00:00
Added <operation>_failed logging (#2636)
* Added <operation>_failed logging for external tools (like Zigbee2MqttAssistant), this will allow the tool to know when an operation is failed. https://github.com/Koenkk/zigbee2mqtt/issues/2223 * Added _failed logging to binding operations too * Added _failed to group operations
This commit is contained in:
committed by
Koen Kanters
parent
8a72916d7d
commit
cabb1f3979
@@ -279,6 +279,8 @@ class BridgeConfig extends BaseExtension {
|
||||
|
||||
if (!entity) {
|
||||
logger.error(`Cannot ${lookup[action][2]}, device '${message}' does not exist`);
|
||||
|
||||
this.mqtt.log(`device_${lookup[action][0]}_failed`, message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -306,6 +308,8 @@ class BridgeConfig extends BaseExtension {
|
||||
logger.error(`Failed to ${lookup[action][2]} ${entity.settings.friendlyName} (${error})`);
|
||||
// eslint-disable-next-line
|
||||
logger.error(`See https://www.zigbee2mqtt.io/information/mqtt_topics_and_message_structure.html#zigbee2mqttbridgeconfigremove for more info`);
|
||||
|
||||
this.mqtt.log(`device_${lookup[action][0]}_failed`, message);
|
||||
}
|
||||
|
||||
if (action === 'ban') {
|
||||
|
||||
@@ -63,6 +63,10 @@ class DeviceBind extends BaseExtension {
|
||||
`Failed to ${type} cluster '${cluster}' from '${sourceName}' to ` +
|
||||
`'${targetName}' (${error})`,
|
||||
);
|
||||
this.mqtt.log(
|
||||
`device_${type}_failed`,
|
||||
{from: sourceName, to: targetName, cluster},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +142,9 @@ class Groups extends BaseExtension {
|
||||
|
||||
if (!group || group.type !== 'group') {
|
||||
logger.error(`Group '${topicMatch[1]}' does not exist`);
|
||||
this.mqtt.log(
|
||||
`device_group_${type}_failed`,
|
||||
{friendly_name: message, group: topicMatch[1], error: 'group doesn\'t exists'});
|
||||
return;
|
||||
}
|
||||
} else if (topic.match(topicRegexRemoveAll)) {
|
||||
@@ -153,6 +156,9 @@ class Groups extends BaseExtension {
|
||||
const entity = this.zigbee.resolveEntity(message);
|
||||
if (!entity || !entity.type === 'device') {
|
||||
logger.error(`Device '${message}' does not exist`);
|
||||
this.mqtt.log(
|
||||
`device_group_${type}_failed`,
|
||||
{friendly_name: message, group: topicMatch[1], error: 'entity doesn\'t exists'});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -368,8 +368,9 @@ describe('Bridge config', () => {
|
||||
MQTT.events.message('zigbee2mqtt/bridge/config/remove', 'bulb_color');
|
||||
await flushPromises();
|
||||
expect(device.removeFromNetwork).toHaveBeenCalledTimes(1);
|
||||
expect(MQTT.publish).toHaveBeenCalledTimes(1);
|
||||
expect(settings.getDevice('bulb_color')).toStrictEqual({"ID": "0x000b57fffec6a5b3", "friendlyName": "bulb_color", "friendly_name": "bulb_color", "retain": false})
|
||||
expect(MQTT.publish).toHaveBeenCalledTimes(0);
|
||||
expect(MQTT.publish).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('Should handle when ban fails', async () => {
|
||||
@@ -381,8 +382,9 @@ describe('Bridge config', () => {
|
||||
MQTT.events.message('zigbee2mqtt/bridge/config/ban', 'bulb_color');
|
||||
await flushPromises();
|
||||
expect(device.removeFromNetwork).toHaveBeenCalledTimes(1);
|
||||
expect(MQTT.publish).toHaveBeenCalledTimes(1);
|
||||
expect(settings.getDevice('bulb_color')).toStrictEqual({"ID": "0x000b57fffec6a5b3", "friendlyName": "bulb_color", "friendly_name": "bulb_color", "retain": false})
|
||||
expect(MQTT.publish).toHaveBeenCalledTimes(0);
|
||||
expect(MQTT.publish).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('Should allow to touchlink factory reset (OK)', async () => {
|
||||
|
||||
Reference in New Issue
Block a user