Skip to content

onZclData throws Cannot read properties of undefined (reading 'manufacturerName') #1574

@bobrippling

Description

@bobrippling

On pairing a new device, I saw this as the device left the network prematurely:

warning:         z2m: Device '0x...' left the network
error:         zh:controller:endpoint: Tried to get unknown/deleted device 0x... from endpoint 1.

TypeError: Cannot read properties of undefined (reading 'manufacturerName')
    at Device.onZclData (.../zigbee-herdsman/src/controller/model/device.ts:431:64)
    at Controller.onZclPayload (.../zigbee-herdsman/src/controller/controller.ts:1017:13)

The only reference to manufacturerName in onZclData is on line 417:

const isDefaultResponse = frame.header.isGlobal && frame.command.name === "defaultRsp";
const commandHasResponse = frame.command.response !== undefined;
const disableDefaultResponse = frame.header.frameControl.disableDefaultResponse;
/* v8 ignore next */
const disableTuyaDefaultResponse = endpoint.getDevice().manufacturerName?.startsWith("_TZ") && process.env.DISABLE_TUYA_DEFAULT_RESPONSE;
// Sometimes messages are received twice, prevent responding twice
const alreadyResponded = this._lastDefaultResponseSequenceNumber === frame.header.transactionSequenceNumber;

I'm happy to put a PR together which investigates typing getDevice() to return undefined - it looks like I hit exactly the edge-case mentioned in #1330 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions