From dae52a22d7db549662e1947b4bbf5f0aff742b42 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Tue, 21 Jan 2020 21:19:11 +0100 Subject: [PATCH] Update converters. --- lib/extension/homeassistant.js | 5 +++++ lib/util/utils.js | 2 +- npm-shrinkwrap.json | 18 +++++++++--------- package.json | 2 +- test/entityPublish.test.js | 13 +++++++++++++ test/stub/data.js | 3 +++ test/stub/zigbeeHerdsman.js | 1 + 7 files changed, 33 insertions(+), 11 deletions(-) diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index a8e634da7..b1ac30a28 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -1164,6 +1164,11 @@ const mapping = { 'GP-WOU019BBDWG': [cfg.switch, cfg.sensor_power], 'AV2010/21A': [cfg.binary_sensor_battery_low, cfg.binary_sensor_contact, cfg.binary_sensor_tamper], 'AL-PIR02': [cfg.binary_sensor_occupancy, cfg.binary_sensor_tamper, cfg.sensor_battery], + 'MKS-CM-W5': [ + switchWithPostfix('l1'), switchWithPostfix('l2'), + switchWithPostfix('l3'), switchWithPostfix('l4'), + ], + 'STS-WTR-250': [cfg.binary_sensor_water_leak, cfg.sensor_battery], }; Object.keys(mapping).forEach((key) => { diff --git a/lib/util/utils.js b/lib/util/utils.js index 7f6c7ec29..619f28669 100644 --- a/lib/util/utils.js +++ b/lib/util/utils.js @@ -28,7 +28,7 @@ function toLocalISOString(dDate) { } const postfixes = [ - 'left', 'right', 'center', 'bottom_left', 'bottom_right', 'l1', 'l2', 'default', + 'left', 'right', 'center', 'bottom_left', 'bottom_right', 'l1', 'l2', 'l3', 'l4', 'default', 'top_left', 'top_right', 'white', 'rgb', 'system', 'top', 'bottom', 'center_left', 'center_right', 'ep1', 'ep2', 'row_1', 'row_2', 'row_3', 'row_4', 'relay', ]; diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 2d8cf5b64..bacbbf594 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -640,9 +640,9 @@ "dev": true }, "@types/istanbul-lib-report": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-1.1.1.tgz", - "integrity": "sha512-3BUTyMzbZa2DtDI2BkERNC6jJw2Mr2Y0oGI7mRxYNBPxppbtEK1F66u3bKwU2g+wxwWI7PAoRpJnOY1grJqzHg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", "dev": true, "requires": { "@types/istanbul-lib-coverage": "*" @@ -1764,9 +1764,9 @@ } }, "es-abstract": { - "version": "1.17.3", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.3.tgz", - "integrity": "sha512-AwiVPKf3sKGMoWtFw0J7Y4MTZ4Iek67k4COWOwHqS8B9TOZ71DCfcoBmdamy8Y6mj4MDz0+VNUpC2HKHFHA3pg==", + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", + "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", "dev": true, "requires": { "es-to-primitive": "^1.2.1", @@ -13526,9 +13526,9 @@ } }, "zigbee-herdsman-converters": { - "version": "12.0.1", - "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-12.0.1.tgz", - "integrity": "sha512-8zYkePs9B+MV1ITPTnGWIkWdIGKOk1bE6T9al6VbKuHGxejotDBEgs8PRV6m9Ueg0Aop+LB+8TCR9Rxk2UvxTQ==", + "version": "12.0.3", + "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-12.0.3.tgz", + "integrity": "sha512-h/yELe1o4Vzu4RrimLFx32M1qVdusBp+c1pgfB8xJ7pjTzH+yuyJj87Msc6dgoe8AJSGI9vSGdrund/cgspW8w==", "dependencies": { "@babel/code-frame": { "version": "7.5.5", diff --git a/package.json b/package.json index 60df7d7df..d0aef5c52 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "semver": "*", "winston": "*", "zigbee-herdsman": "0.12.34", - "zigbee-herdsman-converters": "12.0.1" + "zigbee-herdsman-converters": "12.0.3" }, "devDependencies": { "eslint": "*", diff --git a/test/entityPublish.test.js b/test/entityPublish.test.js index 837d912e0..b6c0ef4fc 100644 --- a/test/entityPublish.test.js +++ b/test/entityPublish.test.js @@ -918,4 +918,17 @@ describe('Entity publish', () => { expect(JSON.parse(MQTT.publish.mock.calls[0][1])).toStrictEqual({position: 100}); expect(MQTT.publish.mock.calls[0][2]).toStrictEqual({"qos": 0, "retain": false}); }); + + it('Should publish to MKS-CM-W5', async () => { + const device = zigbeeHerdsman.devices['MKS-CM-W5']; + const endpoint = device.getEndpoint(1); + await MQTT.events.message('zigbee2mqtt/MKS-CM-W5/l3/set', JSON.stringify({state: 'ON'})); + await flushPromises(); + expect(endpoint.command).toHaveBeenCalledTimes(1); + expect(endpoint.command).toHaveBeenCalledWith("manuSpecificTuyaDimmer", "setData", {data: [1,1], dp: 259, fn: 0, status: 0, transid: 16}, {disableDefaultResponse: true}); + expect(MQTT.publish).toHaveBeenCalledTimes(1); + expect(MQTT.publish.mock.calls[0][0]).toStrictEqual('zigbee2mqtt/MKS-CM-W5'); + expect(JSON.parse(MQTT.publish.mock.calls[0][1])).toStrictEqual({state_l3: 'ON'}); + expect(MQTT.publish.mock.calls[0][2]).toStrictEqual({"qos": 0, "retain": false}); + }); }); diff --git a/test/stub/data.js b/test/stub/data.js index dd6d392dc..ca18ed0b3 100644 --- a/test/stub/data.js +++ b/test/stub/data.js @@ -142,6 +142,9 @@ function writeDefaultConfiguration() { '0x90fd9ffffe4b64ab': { friendly_name: 'SP600_NEW', }, + '0x90fd9ffffe4b64ac': { + friendly_name: 'MKS-CM-W5', + } }, groups: { '1': { diff --git a/test/stub/zigbeeHerdsman.js b/test/stub/zigbeeHerdsman.js index 91e8dd62a..81c027e94 100644 --- a/test/stub/zigbeeHerdsman.js +++ b/test/stub/zigbeeHerdsman.js @@ -138,6 +138,7 @@ const devices = { 'ZNLDP12LM': new Device('Router', '0x90fd9ffffe4b64ax', 33901, 4476, [new Endpoint(1, [0,4,3,5,10,258,13,19,6,1,1030,8,768,1027,1029,1026], [0,3,4,6,8,5], '0x90fd9ffffe4b64ax')], true, "Mains (single phase)", "lumi.light.aqcn02"), 'SP600_OLD': new Device('Router', '0x90fd9ffffe4b64aa', 33901, 4476, [new Endpoint(1, [0,4,3,5,10,258,13,19,6,1,1030,8,768,1027,1029,1026], [0,3,4,6,8,5], '0x90fd9ffffe4b64aa', [], {seMetering: {"multiplier":1,"divisor":10000}})], true, "Mains (single phase)", "SP600", false, 'Salus', '20160120'), 'SP600_NEW': new Device('Router', '0x90fd9ffffe4b64ab', 33901, 4476, [new Endpoint(1, [0,4,3,5,10,258,13,19,6,1,1030,8,768,1027,1029,1026], [0,3,4,6,8,5], '0x90fd9ffffe4b64aa', [], {seMetering: {"multiplier":1,"divisor":10000}})], true, "Mains (single phase)", "SP600", false, 'Salus', '20170220'), + 'MKS-CM-W5': new Device('Router', '0x90fd9ffffe4b64ac', 33901, 4476, [new Endpoint(1, [0,4,3,5,10,258,13,19,6,1,1030,8,768,1027,1029,1026], [0,3,4,6,8,5], '0x90fd9ffffe4b64aa', [], {})], true, "Mains (single phase)", "qnazj70", false), }