diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 4b0c0170..79a59684 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -677,6 +677,12 @@ const mapping = { 'YMF40': [configurations.lock], 'V3-BTZB': [configurations.lock], '3RSS008Z': [configurations.switch, configurations.sensor_battery], + '99432': [configurations.fan], + '511.10': [configurations.light_brightness], + 'IM6001-MPP01': [ + configurations.sensor_temperature, configurations.binary_sensor_contact, configurations.sensor_battery, + ], + 'HLC821-Z-SC': [configurations.light_brightness], }; Object.keys(mapping).forEach((key) => { diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 975b0581..8c4ff402 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -434,9 +434,9 @@ } }, "@types/istanbul-lib-coverage": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.0.tgz", - "integrity": "sha512-eAtOAFZefEnfJiRFQBGw1eYqa5GTLCZ1y86N0XSI/D6EB+E8z6VPV/UL7Gi5UEclFqoQk+6NRqEDsfmDLXn8sg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", + "integrity": "sha512-hRJD2ahnnpLgsj6KWMYSrmXkM3rm2Dl1qkx6IOFD5FnuNPXJIG5L0dhgKXCYTRMGzU4n0wImQ/xfmRc4POUFlg==", "dev": true }, "@types/jest": { @@ -479,9 +479,9 @@ "dev": true }, "acorn-globals": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.3.1.tgz", - "integrity": "sha512-gJSiKY8dBIjV/0jagZIFBdVMtfQyA5QHCvAT48H2q8REQoW8Fs5AOjqBql1LgSXgrMWdevcE+8cdZ33NtVbIBA==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.3.2.tgz", + "integrity": "sha512-BbzvZhVtZP+Bs1J1HcwrQe8ycfO0wStkSGxuul3He3GkHOIZ6eTqOkPuw9IP1X3+IkOo4wiJmwkobzXYz4wewQ==", "dev": true, "requires": { "acorn": "^6.0.1", @@ -677,9 +677,9 @@ } }, "babel-plugin-istanbul": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-5.1.2.tgz", - "integrity": "sha512-U3ZVajC+Z69Gim7ZzmD4Wcsq76i/1hqDamBfowc1tWzWjybRy70iWfngP2ME+1CrgcgZ/+muIbPY/Yi0dxdIkQ==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-5.1.3.tgz", + "integrity": "sha512-IFyehbvRRwdBlI1lDp+FaMsWNnEndEk7065IB8NhzBX+ZKLPwPodgk4I5Gobw/8SNUUzso2Dv3hbqRh88eiSCQ==", "dev": true, "requires": { "find-up": "^3.0.0", @@ -2473,9 +2473,9 @@ "dev": true }, "eslint-plugin-jest": { - "version": "22.4.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-22.4.1.tgz", - "integrity": "sha512-gcLfn6P2PrFAVx3AobaOzlIEevpAEf9chTpFZz7bYfc7pz8XRv7vuKTIE4hxPKZSha6XWKKplDQ0x9Pq8xX2mg==", + "version": "22.5.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-22.5.1.tgz", + "integrity": "sha512-c3WjZR/HBoi4GedJRwo2OGHa8Pzo1EbSVwQ2HFzJ+4t2OoYM7Alx646EH/aaxZ+9eGcPiq0FT0UGkRuFFx2FHg==", "dev": true }, "eslint-scope": { @@ -4915,18 +4915,18 @@ } }, "mime-db": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.39.0.tgz", - "integrity": "sha512-DTsrw/iWVvwHH+9Otxccdyy0Tgiil6TWK/xhfARJZF/QFhwOgZgOIvA2/VIGpM8U7Q8z5nDmdDWC6tuVMJNibw==", + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", "dev": true }, "mime-types": { - "version": "2.1.23", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.23.tgz", - "integrity": "sha512-ROk/m+gMVSrRxTkMlaQOvFmFmYDc7sZgrjjM76abqmd2Cc5fCV7jAMA5XUccEtJ3cYiYdgixUVI+fApc2LkXlw==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "dev": true, "requires": { - "mime-db": "~1.39.0" + "mime-db": "1.40.0" } }, "mimic-fn": { @@ -5811,9 +5811,9 @@ "dev": true }, "resolve": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", - "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz", + "integrity": "sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -5888,9 +5888,9 @@ } }, "rxjs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", - "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.1.tgz", + "integrity": "sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg==", "dev": true, "requires": { "tslib": "^1.9.0" @@ -6596,9 +6596,9 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, "uglify-js": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.5.tgz", - "integrity": "sha512-e58FqZzPwaLODQetDQKlvErZaGkh1UmzP8YwU0aG65NLourKNtwVyDG8tkIyUU0vqWzxaikSvTaxrCSscmvqvQ==", + "version": "3.5.8", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.8.tgz", + "integrity": "sha512-GFSjB1nZIzoIq70qvDRtWRORHX3vFkAnyK/rDExc0BN7r9+/S+Voz3t/fwJuVfjppAMz+ceR2poE7tkhvnVwQQ==", "dev": true, "optional": true, "requires": { @@ -6801,9 +6801,9 @@ "dev": true }, "websocket-stream": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/websocket-stream/-/websocket-stream-5.4.0.tgz", - "integrity": "sha512-7I4o+mmi0slEI7sUjbhYmhbP2O5qXeEV2fOs+oaRJ/Y/4+JgkTsIXvU6QqTN2i4vinxs4NOq2OwhHsLK3x0pWA==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/websocket-stream/-/websocket-stream-5.5.0.tgz", + "integrity": "sha512-EXy/zXb9kNHI07TIMz1oIUIrPZxQRA8aeJ5XYg5ihV8K4kD1DuA+FY6R96HfdIHzlSzS8HiISAfrm+vVQkZBug==", "requires": { "duplexify": "^3.5.1", "inherits": "^2.0.1", @@ -7066,9 +7066,9 @@ } }, "zigbee-shepherd-converters": { - "version": "8.1.3", - "resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-8.1.3.tgz", - "integrity": "sha512-6vfqrMjmrQP4w9GNcjC2AnHmxEFDatYp1w6ZGT3gGosl894Ko/eIbRltr/gM53obRH2jfQsDO60S1V8ZCshp8A==", + "version": "8.1.4", + "resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-8.1.4.tgz", + "integrity": "sha512-PMfKmRB/v/wc9gPci5OnDFNSExwlYj9eblSoY34xO7ltgdSgfStnM5RZsxGciZZDoaqWGFGtDMNIeIGVzkpB2A==", "requires": { "chai": "*", "debounce": "*", diff --git a/package.json b/package.json index 992411cd..3a829068 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "zcl-id": "git+https://github.com/Koenkk/zcl-id.git#4fa75c92424cd070a3bf6e1f4640b1e3ad8f802d", "ziee": "*", "zigbee-shepherd": "git+https://github.com/Koenkk/zigbee-shepherd.git#30d08aacf50327dc1e2c3f146076b9efb8581192", - "zigbee-shepherd-converters": "8.1.3", + "zigbee-shepherd-converters": "8.1.4", "zive": "*" }, "devDependencies": { diff --git a/test/homeassistant.test.js b/test/homeassistant.test.js index 5965a8d4..cf490518 100644 --- a/test/homeassistant.test.js +++ b/test/homeassistant.test.js @@ -4,6 +4,7 @@ const settings = require('../lib/util/settings'); const WSDCGQ11LM = devices.find((d) => d.model === 'WSDCGQ11LM'); const SV01 = devices.find((d) => d.model === 'SV01'); +const FAN99432 = devices.find((d) => d.model === '99432'); describe('HomeAssistant extension', () => { let homeassistant = null; @@ -440,6 +441,41 @@ describe('HomeAssistant extension', () => { expect(mqtt.publish.mock.calls[4][4]).toBe('homeassistant'); }); + it('Should discover devices with fan', () => { + let payload = null; + jest.spyOn(settings, 'getDevice').mockReturnValue({friendly_name: 'my_device'}); + + homeassistant.discover('0x12345678', FAN99432, false); + expect(mqtt.publish).toHaveBeenCalledTimes(2); + + // 1 + payload = { + name: 'my_device_fan', + state_topic: 'zigbee2mqtt/my_device', + state_value_template: '{{ value_json.fan_state }}', + command_topic: 'zigbee2mqtt/my_device/set/fan_state', + speed_state_topic: 'zigbee2mqtt/my_device', + speed_value_template: '{{ value_json.fan_mode }}', + speed_command_topic: 'zigbee2mqtt/my_device/set/fan_mode', + unique_id: '0x12345678_fan_zigbee2mqtt', + speeds: ['off', 'low', 'medium', 'high', 'on', 'auto', 'smart'], + device: { + 'identifiers': 'zigbee2mqtt_0x12345678', + 'name': 'my_device', + 'sw_version': 'Zigbee2mqtt test', + 'manufacturer': 'Hampton Bay', + 'model': 'Universal wink enabled white ceiling fan premier remote control (99432)', + }, + availability_topic: 'zigbee2mqtt/bridge/state', + json_attributes_topic: 'zigbee2mqtt/my_device', + }; + + expect(JSON.parse(mqtt.publish.mock.calls[0][1])).toStrictEqual(payload); + expect(mqtt.publish.mock.calls[0][2]).toStrictEqual({retain: true, qos: 0}); + expect(mqtt.publish.mock.calls[0][3]).toBeNull(); + expect(mqtt.publish.mock.calls[0][4]).toBe('homeassistant'); + }); + it('Should discover devices with cover_position', () => { let payload = null; jest.spyOn(settings, 'getDevice').mockReturnValue({friendly_name: 'my_device'});