Skip to content

Commit

Permalink
Add test for non-use of multi-endpoint state
Browse files Browse the repository at this point in the history
  • Loading branch information
rccoleman authored Jan 26, 2025
1 parent 6ce18aa commit 022df40
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/extensions/groups.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ returnDevices.push(
devices.bulb_color_2.ieeeAddr,
devices.bulb_2.ieeeAddr,
devices.GLEDOPTO_2ID.ieeeAddr,
devices.InovelliVZM31SN.ieeeAddr,
);

describe('Extension: Groups', () => {
Expand Down Expand Up @@ -335,6 +336,31 @@ describe('Extension: Groups', () => {
expect(mockMQTTPublishAsync).toHaveBeenCalledWith('zigbee2mqtt/group_1', stringify({state: 'OFF'}), {retain: false, qos: 0});
});

it('Should publish state change off if all lights within turn off with non default-ep, but device state does not use them', async () => {
const device_1 = devices.bulb_color;
const device_2 = devices.InovelliVZM31SN;
const endpoint_1 = device_1.getEndpoint(1)!;
const endpoint_2 = device_2.getEndpoint(2)!;
const group = groups.group_1;
group.members.push(endpoint_1);
group.members.push(endpoint_2);
settings.set(['groups'], {
1: {friendly_name: 'group_1', retain: false},
});

await mockMQTTEvents.message('zigbee2mqtt/group_1/set', stringify({state: 'ON'}));
await flushPromises();
mockMQTTPublishAsync.mockClear();

await mockMQTTEvents.message('zigbee2mqtt/bulb_color/set', stringify({state: 'OFF'}));
await mockMQTTEvents.message('zigbee2mqtt/wall_switch_double/set', stringify({state_left: 'OFF'}));
await flushPromises();
expect(mockMQTTPublishAsync).toHaveBeenCalledTimes(3);
expect(mockMQTTPublishAsync).toHaveBeenCalledWith('zigbee2mqtt/bulb_color', stringify({state: 'OFF'}), {retain: false, qos: 0});
expect(mockMQTTPublishAsync).toHaveBeenCalledWith('zigbee2mqtt/wall_switch_double', stringify({state_left: 'OFF'}), {retain: false, qos: 0});
expect(mockMQTTPublishAsync).toHaveBeenCalledWith('zigbee2mqtt/group_1', stringify({state: 'OFF'}), {retain: false, qos: 0});
});

it('Should not publish state change off if any lights within are still on when changed via shared group', async () => {
const device_1 = devices.bulb_color;
const device_2 = devices.bulb;
Expand Down

0 comments on commit 022df40

Please sign in to comment.