From cfae1bf3b051d9aa0f7c2b8a6942485cb1d04d4e Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Tue, 10 Sep 2019 19:42:04 +0200 Subject: [PATCH] Default transition for groups. https://github.com/Koenkk/zigbee2mqtt/issues/1948 --- lib/extension/entityPublish.js | 1 + test/entityPublish.test.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/extension/entityPublish.js b/lib/extension/entityPublish.js index ecc3c49a..fd70ed96 100644 --- a/lib/extension/entityPublish.js +++ b/lib/extension/entityPublish.js @@ -87,6 +87,7 @@ class EntityPublish { } else { converters = groupConverters; target = entity.group; + options = entity.settings; } // Convert the MQTT message to a Zigbee message. diff --git a/test/entityPublish.test.js b/test/entityPublish.test.js index 4c2cac48..368f463f 100644 --- a/test/entityPublish.test.js +++ b/test/entityPublish.test.js @@ -556,6 +556,18 @@ describe('Entity publish', () => { expect(endpoint.read.mock.calls[1]).toEqual(["lightingColorCtrl", ["currentX", "currentY", "colorTemperature"]]); }); + it('Should use transition when brightness with group', async () => { + const group = zigbeeHerdsman.groups.group_1; + settings.set(['groups', '1', 'transition'], 20); + await MQTT.events.message('zigbee2mqtt/group_1/set', JSON.stringify({brightness: 100})); + await flushPromises(); + expect(group.command).toHaveBeenCalledTimes(1); + expect(group.command).toHaveBeenCalledWith("genLevelCtrl", "moveToLevelWithOnOff", {level: 100, transtime: 200}, {}); + expect(MQTT.publish).toHaveBeenCalledTimes(1); + expect(MQTT.publish.mock.calls[0][0]).toStrictEqual('zigbee2mqtt/group_1'); + expect(JSON.parse(MQTT.publish.mock.calls[0][1])).toStrictEqual({state: 'ON', brightness: 100}); + }); + it('Should use transition when brightness', async () => { const device = zigbeeHerdsman.devices.bulb_color; settings.set(['devices', device.ieeeAddr, 'transition'], 20);