diff --git a/lib/zigbee.js b/lib/zigbee.js index e99d276db..6d6b159fa 100644 --- a/lib/zigbee.js +++ b/lib/zigbee.js @@ -9,7 +9,7 @@ const objectAssignDeep = require('object-assign-deep'); const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters'); const postfixes = utils.getPostfixes(); -const keyEndpointByNumber = new RegExp(`.*/([0-9].*)$`); +const keyEndpointByNumber = new RegExp(`.*/([0-9]*)$`); const herdsmanSettings = { network: { diff --git a/test/entityPublish.test.js b/test/entityPublish.test.js index 3eadab267..d344f0cb4 100644 --- a/test/entityPublish.test.js +++ b/test/entityPublish.test.js @@ -493,6 +493,16 @@ describe('Entity publish', () => { expect(endpoint.command).toHaveBeenCalledWith("genOnOff", "on", {}, {}); }); + it('Should parse set with number at the end of friendly_name and postfix', async () => { + const device = zigbeeHerdsman.devices.QBKG03LM; + settings.set(['devices', device.ieeeAddr, 'friendly_name'], 'ground_floor/kitchen/wall_switch/2'); + const endpoint = device.getEndpoint(2); + await MQTT.events.message('zigbee2mqtt/ground_floor/kitchen/wall_switch/2/left/set', JSON.stringify({state: 'ON'})); + await flushPromises(); + expect(endpoint.command).toHaveBeenCalledTimes(1); + expect(endpoint.command).toHaveBeenCalledWith("genOnOff", "on", {}, {}); + }); + it('Should not publish messages to zigbee devices when payload is invalid', async () => { const device = zigbeeHerdsman.devices.QBKG03LM; const endpoint = device.getEndpoint(2);