mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 13:34:24 +00:00
Retrieve default ep from mapping. #1662
This commit is contained in:
@@ -34,4 +34,45 @@ describe('Utils', () => {
|
||||
expect('EndDevice').toBe(utils.correctDeviceType(device));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Get endpoint by id', () => {
|
||||
it('Pick default ep', () => {
|
||||
const zigbee = {
|
||||
getDevice: (entityID) => {
|
||||
return {modelId: 'TRADFRI on/off switch'};
|
||||
},
|
||||
getEndpoint: (entityID, epId) => {
|
||||
return {epId: epId == null ? 1 : 0};
|
||||
},
|
||||
};
|
||||
const endpoint = utils.getEndpointByEntityID(zigbee, '0x12345678', null);
|
||||
expect(endpoint.epId).toBe(1);
|
||||
});
|
||||
|
||||
it('Pick default ep from mapping when default defined', () => {
|
||||
const zigbee = {
|
||||
getDevice: (entityID) => {
|
||||
return {modelId: 'SML002'};
|
||||
},
|
||||
getEndpoint: (entityID, epId) => {
|
||||
return {epId};
|
||||
},
|
||||
};
|
||||
const endpoint = utils.getEndpointByEntityID(zigbee, '0x12345678', null);
|
||||
expect(endpoint.epId).toBe(2);
|
||||
});
|
||||
|
||||
it('Pick default ep from mapping when not defined', () => {
|
||||
const zigbee = {
|
||||
getDevice: (entityID) => {
|
||||
return {modelId: 'lumi.sensor_86sw2.es1'};
|
||||
},
|
||||
getEndpoint: (entityID, epId) => {
|
||||
return {epId: epId == null ? 1 : 0};
|
||||
},
|
||||
};
|
||||
const endpoint = utils.getEndpointByEntityID(zigbee, '0x12345678', null);
|
||||
expect(endpoint.epId).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user