From 3064bf8b841bb0e7588ac4d9ce6a4b67bae386bc Mon Sep 17 00:00:00 2001 From: Illia Antypenko Date: Fri, 20 Sep 2024 23:40:00 +0200 Subject: [PATCH] Add support of new encryption methods --- .eslintrc.json | 10 +++---- app.json | 33 ++++++++++++++++++++++- drivers/gree_cooper_hunter_hvac/device.js | 16 +++++++++++ package-lock.json | 8 +++--- package.json | 2 +- 5 files changed, 58 insertions(+), 11 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5a37580..8863857 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,9 +1,9 @@ { "extends": "athom", "rules": { - "no-use-before-define": ["error", { "functions": false }], - "no-console": "off", - "node/no-unpublished-require": ["error", { "allowModules": ["homey"]}], - "indent": ["error", 4] + "no-use-before-define": ["error", { "functions": false }], + "no-console": "off", + "node/no-unpublished-require": ["error", { "allowModules": ["homey"]}], + "indent": ["error", 4, { "SwitchCase": 1 }] } -} \ No newline at end of file +} diff --git a/app.json b/app.json index 8d78649..48a8431 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,6 @@ { "id": "com.gree", - "version": "0.8.1", + "version": "0.9.0", "compatibility": ">=12.0.1", "sdk": 3, "brandColor": "#ff732e", @@ -1705,6 +1705,37 @@ "hint": { "en": "Enable debug in case the application is crashing. It allows developer to investigate the issue" } + }, + { + "id": "encryption_mode", + "type": "dropdown", + "value": "auto", + "label": { + "en": "Encryption mode" + }, + "hint": { + "en": "Encryption mode used by the HVAC. Most recent firmwares use V2" + }, + "values": [ + { + "id": "auto", + "label": { + "en": "Autodetect (not implemented yet, V1 used instead)" + } + }, + { + "id": "v1", + "label": { + "en": "V1 (HVAC Firmware versions <1.21)" + } + }, + { + "id": "v2", + "label": { + "en": "V2 (HVAC Firmware versions >=1.21)" + } + } + ] } ], "images": { diff --git a/drivers/gree_cooper_hunter_hvac/device.js b/drivers/gree_cooper_hunter_hvac/device.js index 931bde4..0db9663 100644 --- a/drivers/gree_cooper_hunter_hvac/device.js +++ b/drivers/gree_cooper_hunter_hvac/device.js @@ -78,6 +78,7 @@ class GreeHVACDevice extends Homey.Device { const deviceData = this.getData(); const settings = this.getSettings(); + const encryptionVersion = this.mapEncryptionModeSetting(settings.encryption_mode); this.log('[find devices]', 'Finding device with mac:', deviceData.mac); @@ -97,6 +98,7 @@ class GreeHVACDevice extends Homey.Device { host: hvac.remoteInfo.address, pollingInterval: POLLING_INTERVAL, pollingTimeout: POLLING_TIMEOUT, + encryptionVersion, }); this._registerClientListeners(); @@ -649,6 +651,20 @@ class GreeHVACDevice extends Homey.Device { return Promise.resolve(); } + mapEncryptionModeSetting(encryptionMode) { + switch (encryptionMode) { + // not implemented yet + case 'auto': + case 'v1': + default: + // AES-ECB + return 1; + case 'v2': + // AES-GCM + return 2; + } + } + } module.exports = GreeHVACDevice; diff --git a/package-lock.json b/package-lock.json index c27f48a..3d5a8c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "license": "GPL-3.0-or-later", "dependencies": { - "gree-hvac-client": "github:aivus/gree-hvac-client#com.gree/master", + "gree-hvac-client": "github:aivus/gree-hvac-client#com.gree/encryption", "homey-log": "^2.1.0" }, "devDependencies": { @@ -3199,7 +3199,7 @@ }, "node_modules/gree-hvac-client": { "version": "0.0.0-development", - "resolved": "git+ssh://git@github.com/aivus/gree-hvac-client.git#5607ac8fd288e0e2060c13701178cb6a0b1bf3bf", + "resolved": "git+ssh://git@github.com/aivus/gree-hvac-client.git#7d51627adb76ba50b48fa4f9cd494741c3f2e409", "license": "GPL-3.0", "dependencies": { "clone": "^2.1.2", @@ -9737,8 +9737,8 @@ "dev": true }, "gree-hvac-client": { - "version": "git+ssh://git@github.com/aivus/gree-hvac-client.git#5607ac8fd288e0e2060c13701178cb6a0b1bf3bf", - "from": "gree-hvac-client@github:aivus/gree-hvac-client#com.gree/master", + "version": "git+ssh://git@github.com/aivus/gree-hvac-client.git#7d51627adb76ba50b48fa4f9cd494741c3f2e409", + "from": "gree-hvac-client@github:aivus/gree-hvac-client#com.gree/encryption", "requires": { "clone": "^2.1.2", "object-diff": "^0.0.4" diff --git a/package.json b/package.json index 745ccef..6c6ce72 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "homepage": "https://github.com/aivus/com.gree#readme", "dependencies": { - "gree-hvac-client": "github:aivus/gree-hvac-client#com.gree/master", + "gree-hvac-client": "github:aivus/gree-hvac-client#com.gree/encryption", "homey-log": "^2.1.0" }, "devDependencies": {