From 245404db1afd89633d1cd980baf13e1921eceec6 Mon Sep 17 00:00:00 2001 From: asgothian <45667167+asgothian@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:04:01 +0100 Subject: [PATCH 1/2] Update zbDeviceEvent.js Bugfix - random crashes with onEvent --- lib/zbDeviceEvent.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/zbDeviceEvent.js b/lib/zbDeviceEvent.js index e6e1a3b1..7c0948c5 100644 --- a/lib/zbDeviceEvent.js +++ b/lib/zbDeviceEvent.js @@ -36,11 +36,22 @@ class DeviceEvent extends BaseExtension { async callOnEvent(device, type, data, mappedDevice) { if (!mappedDevice) { - mappedDevice = await zigbeeHerdsmanConverters.findByDevice(device); + try { + mappedDevice = await zigbeeHerdsmanConverters.findByDevice(device); + } + catch (error) { + this.log.error(`onEvent: unable to find mapped device for ${JSON.stringify(device)} `); + return; + } } if (mappedDevice && mappedDevice.onEvent) { - mappedDevice.onEvent(type, data, device,mappedDevice.options,'{}'); + try { + mappedDevice.onEvent(type, data, device,mappedDevice.options,'{}'); + } + catch (error) { + this.log.error(`onEvent for ${JSON.stringify(device)} failed with error ${error.message}`); + } } } } From 9adebc517e3a24dea8f4debbd7103350c3f62216 Mon Sep 17 00:00:00 2001 From: asgothian <45667167+asgothian@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:06:08 +0100 Subject: [PATCH 2/2] Update zbDeviceEvent.js lint --- lib/zbDeviceEvent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zbDeviceEvent.js b/lib/zbDeviceEvent.js index 7c0948c5..47d7e21a 100644 --- a/lib/zbDeviceEvent.js +++ b/lib/zbDeviceEvent.js @@ -47,7 +47,7 @@ class DeviceEvent extends BaseExtension { if (mappedDevice && mappedDevice.onEvent) { try { - mappedDevice.onEvent(type, data, device,mappedDevice.options,'{}'); + mappedDevice.onEvent(type, data, device,mappedDevice.options,'{}'); } catch (error) { this.log.error(`onEvent for ${JSON.stringify(device)} failed with error ${error.message}`);