mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-22 10:39:58 +00:00
Fix crash when converter throws exception. https://github.com/Koenkk/zigbee2mqtt/issues/9133
This commit is contained in:
@@ -85,7 +85,7 @@ export default class Receive extends Extension {
|
||||
return true;
|
||||
}
|
||||
|
||||
@bind onDeviceMessage(data: eventdata.DeviceMessage): void {
|
||||
@bind async onDeviceMessage(data: eventdata.DeviceMessage): Promise<void> {
|
||||
/* istanbul ignore next */
|
||||
if (!data.device) return;
|
||||
|
||||
@@ -147,12 +147,18 @@ export default class Receive extends Extension {
|
||||
|
||||
const meta = {device: data.device.zh, logger, state: this.state.get(data.device)};
|
||||
let payload: KeyValue = {};
|
||||
converters.forEach((converter) => {
|
||||
const converted = converter.convert(data.device.definition, data, publish, data.device.settings, meta);
|
||||
if (converted) {
|
||||
payload = {...payload, ...converted};
|
||||
for (const converter of converters) {
|
||||
try {
|
||||
const converted = await converter.convert(
|
||||
data.device.definition, data, publish, data.device.settings, meta);
|
||||
if (converted) {
|
||||
payload = {...payload, ...converted};
|
||||
}
|
||||
} catch (error) {
|
||||
// istanbul ignore next
|
||||
logger.error(`Exception while calling fromZigbee converter: ${error.message}}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Object.keys(payload).length) {
|
||||
publish(payload);
|
||||
|
||||
Vendored
+1
-1
@@ -91,7 +91,7 @@ declare global {
|
||||
cluster: string,
|
||||
type: string[] | string,
|
||||
convert: (model: Definition, msg: KeyValue, publish: (payload: KeyValue) => void, options: KeyValue,
|
||||
meta: {state: KeyValue, logger: Logger, device: zh.Device}) => KeyValue,
|
||||
meta: {state: KeyValue, logger: Logger, device: zh.Device}) => Promise<KeyValue>,
|
||||
}
|
||||
|
||||
interface DefinitionExposeFeature {name: string, endpoint?: string,
|
||||
|
||||
Reference in New Issue
Block a user