Fix topic postfix detection having number. #2309

This commit is contained in:
Koenkk
2019-11-11 17:36:33 +01:00
parent 3dbf454d07
commit e2858dc90f
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -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: {
+10
View File
@@ -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);