Skip to content

Commit

Permalink
Update zbDeviceEvent.js
Browse files Browse the repository at this point in the history
Bugfix - random crashes with onEvent
  • Loading branch information
asgothian committed Jan 10, 2025
1 parent 070b1ce commit 245404d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/zbDeviceEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,'{}');

Check failure on line 50 in lib/zbDeviceEvent.js

View workflow job for this annotation

GitHub Actions / check-and-lint

Expected indentation of 16 spaces but found 17
}
catch (error) {
this.log.error(`onEvent for ${JSON.stringify(device)} failed with error ${error.message}`);
}
}
}
}
Expand Down

0 comments on commit 245404d

Please sign in to comment.