mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-15 09:58:45 -07:00
Fix "Cannot read property 'ID' of undefined". https://github.com/Koenkk/zigbee2mqtt/issues/6981
This commit is contained in:
parent
ab0ae8ce91
commit
30efb3e824
@ -188,6 +188,11 @@ class Zigbee extends events.EventEmitter {
|
||||
`Wrong type '${typeof key}'`,
|
||||
);
|
||||
|
||||
const getEndpointName = (endpointNames, endpoint) => {
|
||||
return endpoint ?
|
||||
utils.getKey(endpointNames, endpoint.ID, null, ((v) => v === 'default' ? null : v)) : null;
|
||||
};
|
||||
|
||||
const deviceOptions = settings.get().device_options;
|
||||
if (typeof key === 'string' || typeof key === 'number') {
|
||||
if (typeof key === 'number') {
|
||||
@ -247,7 +252,7 @@ class Zigbee extends events.EventEmitter {
|
||||
return {
|
||||
type: 'device', device, endpoint, settings: {...deviceOptions, ...entity},
|
||||
name: entity.friendlyName, definition,
|
||||
endpointName: utils.getKey(endpointNames, endpoint.ID, null, ((v) => v === 'default' ? null : v)),
|
||||
endpointName: getEndpointName(endpointNames, endpoint),
|
||||
};
|
||||
} else {
|
||||
let group = this.getGroupByID(entity.ID);
|
||||
@ -269,7 +274,7 @@ class Zigbee extends events.EventEmitter {
|
||||
|
||||
return {
|
||||
type: 'device', definition, name, device, endpoint, settings: {...deviceOptions, ...(setting || {})},
|
||||
endpointName: utils.getKey(endpointNames, endpoint.ID, null, ((v) => v === 'default' ? null : v)),
|
||||
endpointName: getEndpointName(endpointNames, endpoint),
|
||||
};
|
||||
} else { // Group
|
||||
const setting = settings.getEntity(key.groupID);
|
||||
|
@ -189,6 +189,7 @@ const devices = {
|
||||
'TS0601_thermostat': TS0601_thermostat,
|
||||
'external_converter_device': new Device('EndDevice', '0x0017880104e45511', 1114, 'external', [new Endpoint(1, [], [], '0x0017880104e45511')], false, null, 'external_converter_device' ),
|
||||
'QS_Zigbee_D02_TRIAC_2C_LN':new Device('Router', '0x0017882194e45543', 6549,4151, [new Endpoint(1, [0], [], '0x0017882194e45543'), new Endpoint(2, [0, 6], [], '0x0017882194e45543')], true, "Mains (single phase)", 'TS110F', false, '_TYZB01_v8gtiaed'),
|
||||
'unknown': new Device('Router', '0x0017980134e45545', 6540,4151, [], true, "Mains (single phase)"),
|
||||
}
|
||||
|
||||
const mock = {
|
||||
|
Loading…
Reference in New Issue
Block a user