Skip to content

Commit

Permalink
Merge pull request #2356 from asgothian/master
Browse files Browse the repository at this point in the history
Update zbDeviceEvent.js
  • Loading branch information
asgothian authored Jan 10, 2025
2 parents e1024ce + 9adebc5 commit 2f5bb8d
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,'{}');
}
catch (error) {
this.log.error(`onEvent for ${JSON.stringify(device)} failed with error ${error.message}`);
}
}
}
}
Expand Down

0 comments on commit 2f5bb8d

Please sign in to comment.