Skip to content

Commit

Permalink
Update converters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed May 18, 2020
1 parent 134f671 commit ad9421a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
19 changes: 18 additions & 1 deletion lib/extension/homeassistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ const mapping = {
'ZM-CSW032-D': [cfg.cover_position],
'LH-32ZB': [cfg.sensor_humidity, cfg.sensor_temperature, cfg.sensor_battery],
'511.201': [cfg.light_brightness],
'ZNCLDJ12LM': [cfg.cover_position],
'ZNCLDJ12LM': [cfg.cover_position, cfg.sensor_battery],
'046677552343': [cfg.switch],
'3115331PH': [cfg.light_brightness_colortemp_colorxy],
'ZWLD-100': [cfg.binary_sensor_water_leak, cfg.binary_sensor_battery_low, cfg.sensor_battery],
Expand Down Expand Up @@ -1640,6 +1640,23 @@ const mapping = {
'ZS110050078': [cfg.binary_sensor_contact, cfg.binary_sensor_battery_low],
'HGZB-DLC4-N15B': [cfg.light_brightness_colortemp_colorxy],
'ECW-100-A03': [switchEndpoint('top'), switchEndpoint('center'), switchEndpoint('bottom')],
'4098430P7': [cfg.light_brightness_colortemp],
'PQC19-DY01': [cfg.light_brightness],
'DIYRuZ_FreePad': [cfg.sensor_action, cfg.sensor_battery],
'ST20': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery],
'ST21': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery],
'T30W3Z': [switchEndpoint('top'), switchEndpoint('center'), switchEndpoint('bottom')],
'T21W2Z': [switchEndpoint('top'), switchEndpoint('bottom')],
'T21W1Z': [cfg.switch],
'W40CZ': [cfg.cover_position],
'R11W2Z': [switchEndpoint('l1'), switchEndpoint('l2')],
'R20W2Z': [switchEndpoint('l1'), switchEndpoint('l2')],
'SW21': [cfg.binary_sensor_water_leak, cfg.binary_sensor_battery_low],
'SE21': [cfg.sensor_action],
'4052899926127': [cfg.light_brightness],
'GL-B-001ZS': [cfg.light_brightness_colortemp_colorxy],
'LH-990ZB': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low],
'HO-09ZB': [cfg.binary_sensor_contact, cfg.binary_sensor_battery_low],
};

/**
Expand Down
6 changes: 3 additions & 3 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"semver": "*",
"winston": "*",
"zigbee-herdsman": "0.12.90",
"zigbee-herdsman-converters": "12.0.88"
"zigbee-herdsman-converters": "12.0.90"
},
"devDependencies": {
"eslint": "*",
Expand Down
19 changes: 19 additions & 0 deletions test/publish.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const data = require('./stub/data');
const logger = require('./stub/logger');
const zigbeeHerdsman = require('./stub/zigbeeHerdsman');
const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters');
const MQTT = require('./stub/mqtt');
const settings = require('../lib/util/settings');
const Controller = require('../lib/controller');
Expand Down Expand Up @@ -48,6 +49,8 @@ describe('Publish', () => {
Object.values(zigbeeHerdsman.groups).forEach((g) => {
g.command.mockClear();
});

zigbeeHerdsmanConverters.toZigbeeConverters.__clearStore__();
});

it('Should publish messages to zigbee devices', async () => {
Expand Down Expand Up @@ -586,6 +589,22 @@ describe('Publish', () => {
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;
const endpoint = device.getEndpoint(1);
await MQTT.events.message('zigbee2mqtt/bulb_color/set', JSON.stringify({"state": "ON", "brightness": 50}));
await flushPromises();
await MQTT.events.message('zigbee2mqtt/bulb_color/set', JSON.stringify({"state": "ON"}));
await flushPromises();
await MQTT.events.message('zigbee2mqtt/bulb_color/set', JSON.stringify({"state": "ON", "transition": 1}));
await flushPromises();
expect(endpoint.command).toHaveBeenCalledTimes(3);
expect(endpoint.command.mock.calls[0]).toEqual(["genLevelCtrl", "moveToLevelWithOnOff", {level: 50, transtime: 0}, {}]);
expect(endpoint.command.mock.calls[1]).toEqual(["genOnOff", "on", {}, {}]);
expect(endpoint.command.mock.calls[2]).toEqual(["genLevelCtrl", "moveToLevelWithOnOff", {level: 50, transtime: 10}, {}]);
});

it('Should use transition when color temp', async () => {
const device = zigbeeHerdsman.devices.bulb_color;
settings.set(['devices', device.ieeeAddr, 'transition'], 20);
Expand Down

0 comments on commit ad9421a

Please sign in to comment.