diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index afb9b449f..cf0b2f962 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -1754,7 +1754,7 @@ const mapping = { 'MOSZB-130': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], 'AU-A1ZBRC': [cfg.sensor_action, cfg.sensor_battery], 'AU-A1ZBPIRS': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low, cfg.sensor_illuminance_lux], - 'TS0121': [cfg.switch, cfg.sensor_voltage, cfg.sensor_power, cfg.sensor_current], + 'TS0121_plug': [cfg.switch, cfg.sensor_voltage, cfg.sensor_power, cfg.sensor_current], 'ZK03840': [climate()], 'ZS1100400-IN-V1A02': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], 'MCLH-08': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_eco2, cfg.sensor_voc], @@ -1909,6 +1909,8 @@ const mapping = { 'TPZRCO2HT-Z3': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery, cfg.sensor_co2], '43100': [cfg.switch], '3400-D': [cfg.sensor_action, cfg.sensor_battery], + 'GL-FL-006TZS': [cfg.light_brightness_colortemp_colorxy], + 'TS0121_switch': [cfg.switch], }; const defaultStatusTopic = 'homeassistant/status'; diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 0014b261f..08357e5bd 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -15023,9 +15023,9 @@ } }, "zigbee-herdsman-converters": { - "version": "12.0.170", - "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-12.0.170.tgz", - "integrity": "sha512-sC3GXb2cauXRMR8jFGYDXvFl7yqCt1ufajH+cbKKkZQYSb2RG2w342cNZ9FBIJ1ADQcPxzOU7k4qlPsNtigMpw==", + "version": "12.0.172", + "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-12.0.172.tgz", + "integrity": "sha512-8qwLeCryBFKRS7t4YHQ9bYUjeXnJhdpRUj2CaEW07CSIPWbyuOq29BsupbcgAX6EE56D4NbcKznhm7sT2Ittig==", "requires": { "axios": "^0.20.0", "https-proxy-agent": "^5.0.0", diff --git a/package.json b/package.json index fef85c97a..eb6f309d5 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "winston": "^3.3.3", "winston-syslog": "^2.4.4", "zigbee-herdsman": "0.12.121", - "zigbee-herdsman-converters": "12.0.170" + "zigbee-herdsman-converters": "12.0.172" }, "devDependencies": { "eslint": "*", diff --git a/test/publish.test.js b/test/publish.test.js index c4fcac23a..8e0bce565 100644 --- a/test/publish.test.js +++ b/test/publish.test.js @@ -779,14 +779,23 @@ describe('Publish', () => { expect(MQTT.publish.mock.calls[2]).toEqual(["zigbee2mqtt/bulb_color", stringify({state: 'ON', brightness: 50}), {"qos": 0, "retain": false}, expect.any(Function)]); }); - it('Should turn device off when brightness 0 is send with light_brightness converter', async () => { - const device = zigbeeHerdsman.devices.HGZB04D; + it('Should turn device off when brightness 0 is send with transition', async () => { + const device = zigbeeHerdsman.devices.bulb_color; const endpoint = device.getEndpoint(1); - const payload = {'brightness': 0}; - await MQTT.events.message('zigbee2mqtt/dimmer_wall_switch/set', stringify(payload)); + await MQTT.events.message('zigbee2mqtt/bulb_color/set', stringify({brightness: 50, state: 'ON'})); await flushPromises(); - expect(endpoint.command).toHaveBeenCalledTimes(1); - expect(endpoint.command.mock.calls[0]).toEqual(["genOnOff", "off", {}, {}]); + await MQTT.events.message('zigbee2mqtt/bulb_color/set', stringify({brightness: 0, transition: 3})); + await flushPromises(); + await MQTT.events.message('zigbee2mqtt/bulb_color/set', stringify({state: 'ON'})); + 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(["genLevelCtrl", "moveToLevelWithOnOff", {level: 0, transtime: 30}, {}]); + expect(endpoint.command.mock.calls[2]).toEqual(["genLevelCtrl", "moveToLevelWithOnOff", {level: 50, transtime: 0}, {}]); + expect(MQTT.publish).toHaveBeenCalledTimes(3); + expect(MQTT.publish.mock.calls[0]).toEqual(["zigbee2mqtt/bulb_color", stringify({state: 'ON', brightness: 50}), {"qos": 0, "retain": false}, expect.any(Function)]); + expect(MQTT.publish.mock.calls[1]).toEqual(["zigbee2mqtt/bulb_color", stringify({state: 'OFF', brightness: 0}), {"qos": 0, "retain": false}, expect.any(Function)]); + expect(MQTT.publish.mock.calls[2]).toEqual(["zigbee2mqtt/bulb_color", stringify({state: 'ON', brightness: 50}), {"qos": 0, "retain": false}, expect.any(Function)]); }); it('Should allow to set color via hue and saturation', async () => { diff --git a/test/stub/zigbeeHerdsman.js b/test/stub/zigbeeHerdsman.js index b0d7ac506..4dda843bc 100644 --- a/test/stub/zigbeeHerdsman.js +++ b/test/stub/zigbeeHerdsman.js @@ -128,7 +128,7 @@ const devices = { 'QBKG03LM':new Device('Router', '0x0017880104e45542', 6540,4151, [new Endpoint(1, [0], [], '0x0017880104e45542'), new Endpoint(2, [0, 6], [], '0x0017880104e45542'), new Endpoint(3, [0, 6], [], '0x0017880104e45542')], true, "Mains (single phase)", 'lumi.ctrl_neutral2'), 'GLEDOPTO1112': new Device('Router', '0x0017880104e45543', 6540, 4151, [new Endpoint(11, [0], [], '0x0017880104e45543'), new Endpoint(13, [0], [], '0x0017880104e45543')], true, "Mains (single phase)", 'GL-C-008'), 'GLEDOPTO111213': new Device('Router', '0x0017880104e45544', 6540,4151, [new Endpoint(11, [0], []), new Endpoint(13, [0], []), new Endpoint(12, [0], [])], true, "Mains (single phase)", 'GL-C-008'), - 'HGZB04D': new Device('Router', '0x0017880104e45545', 6540,4151, [new Endpoint(1, [0], [])], true, "Mains (single phase)", 'FB56+ZSC05HG1.0'), + 'HGZB04D': new Device('Router', '0x0017880104e45545', 6540,4151, [new Endpoint(1, [0], [], '0x0017880104e45545')], true, "Mains (single phase)", 'FB56+ZSC05HG1.0'), 'ZNCLDJ11LM': new Device('Router', '0x0017880104e45547', 6540,4151, [new Endpoint(1, [0], []), new Endpoint(2, [0], [])], true, "Mains (single phase)", 'lumi.curtain'), 'HAMPTON99432': new Device('Router', '0x0017880104e45548', 6540,4151, [new Endpoint(1, [0], []), new Endpoint(2, [0], [])], true, "Mains (single phase)", 'HDC52EastwindFan'), 'HS2WD': new Device('Router', '0x0017880104e45549', 6540,4151, [new Endpoint(1, [0], [])], true, "Mains (single phase)", 'WarningDevice'),