Fix transition from device_options not applied. #3922

This commit is contained in:
Koen Kanters 2020-07-19 00:04:39 +02:00
parent 0e0a364da7
commit 1f39ff6f57
2 changed files with 14 additions and 3 deletions

View File

@ -91,11 +91,11 @@ class EntityPublish extends Extension {
definition = resolvedEntity.definition;
target = resolvedEntity.endpoint;
converters = resolvedEntity.definition.toZigbee;
options = resolvedEntity.settings;
options = {...settings.get().device_options, ...resolvedEntity.settings};
} else {
converters = groupConverters;
target = resolvedEntity.group;
options = resolvedEntity.settings;
options = {...settings.get().device_options, ...resolvedEntity.settings};
definition = resolvedEntity.group.members.map((e) => zigbeeHerdsmanConverters.findByDevice(e.getDevice()));
}

View File

@ -618,7 +618,7 @@ describe('Publish', () => {
expect(JSON.parse(MQTT.publish.mock.calls[0][1])).toStrictEqual({state: 'ON', brightness: 100});
});
it('Should use transition when brightness', async () => {
it('Should use transition on brightness command', async () => {
const device = zigbeeHerdsman.devices.bulb_color;
settings.set(['devices', device.ieeeAddr, 'transition'], 20);
const endpoint = device.getEndpoint(1);
@ -629,6 +629,17 @@ describe('Publish', () => {
expect(endpoint.command.mock.calls[0]).toEqual(["genLevelCtrl", "moveToLevelWithOnOff", {level: 20, transtime: 200}, {}]);
});
it('Should use transition from device_options on brightness command', async () => {
const device = zigbeeHerdsman.devices.bulb_color;
settings.set(['device_options'], {transition: 20});
const endpoint = device.getEndpoint(1);
const payload = {brightness: 20};
await MQTT.events.message('zigbee2mqtt/bulb_color/set', JSON.stringify(payload));
await flushPromises();
expect(endpoint.command).toHaveBeenCalledTimes(1);
expect(endpoint.command.mock.calls[0]).toEqual(["genLevelCtrl", "moveToLevelWithOnOff", {level: 20, transtime: 200}, {}]);
});
it('Transition parameter should not influence brightness on state ON', async () => {
// https://github.com/Koenkk/zigbee2mqtt/issues/3563
const device = zigbeeHerdsman.devices.bulb_color;