From 9ebb1b96ddb5ebde909d31d5483bbed99efb00c8 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Tue, 15 Oct 2019 09:42:28 -0500 Subject: [PATCH] Group device staying off when already off (#2140) * Fix devices within a group staying off if they are off when the group state changes * Group test cleanups --- lib/extension/groups.js | 2 +- test/group.test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/extension/groups.js b/lib/extension/groups.js index 185c6acd2..40d6c5399 100644 --- a/lib/extension/groups.js +++ b/lib/extension/groups.js @@ -75,7 +75,7 @@ class Groups extends BaseExtension { const payload = {}; properties.forEach((prop) => { - if (data.to.hasOwnProperty(prop) && (!data.from || data.from[prop] != data.to[prop])) { + if (data.to.hasOwnProperty(prop)) { payload[prop] = data.to[prop]; } }); diff --git a/test/group.test.js b/test/group.test.js index 64240e653..908c0c5f2 100644 --- a/test/group.test.js +++ b/test/group.test.js @@ -389,8 +389,8 @@ describe('Groups', () => { await flushPromises(); expect(MQTT.publish).toHaveBeenCalledTimes(3); expect(MQTT.publish).toHaveBeenCalledWith("zigbee2mqtt/bulb_color", '{"state":"OFF"}', {"retain": false, qos: 0}, expect.any(Function)); - expect(MQTT.publish).toHaveBeenCalledWith("zigbee2mqtt/bulb", '{"state":"OFF\","brightness":50,"color_temp":370,"linkquality":99}', {"retain": true, qos: 0}, expect.any(Function)); - expect(MQTT.publish).toHaveBeenCalledWith("zigbee2mqtt/group_1", '{"state":"OFF"}', {"retain": false, qos: 0}, expect.any(Function)); + expect(MQTT.publish).toHaveBeenCalledWith("zigbee2mqtt/bulb", '{"state":"OFF","brightness":50,"color_temp":370,"linkquality":99}', {"retain": true, qos: 0}, expect.any(Function)); + expect(MQTT.publish).toHaveBeenCalledWith("zigbee2mqtt/group_1", '{"state":"OFF","brightness":50,"color_temp":370}', {"retain": false, qos: 0}, expect.any(Function)); }); it('Should publish state change off even when missing current state', async () => {