From 731b45c8794e529a7bfb2296a2d4331f46914452 Mon Sep 17 00:00:00 2001 From: Illia Antypenko Date: Fri, 22 Nov 2024 23:29:55 +0100 Subject: [PATCH] Use PoC from upstream of gree-hvac-client to handle new encryption (#175) --- app.json | 31 ------------------- drivers/gree_cooper_hunter_hvac/device.js | 21 ------------- .../driver.compose.json | 31 ------------------- package-lock.json | 4 +-- package.json | 2 +- 5 files changed, 3 insertions(+), 86 deletions(-) diff --git a/app.json b/app.json index d52c92e..63774c7 100644 --- a/app.json +++ b/app.json @@ -1479,37 +1479,6 @@ "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 f4a0b0b..1cbfc88 100644 --- a/drivers/gree_cooper_hunter_hvac/device.js +++ b/drivers/gree_cooper_hunter_hvac/device.js @@ -82,7 +82,6 @@ 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); @@ -104,7 +103,6 @@ class GreeHVACDevice extends Homey.Device { pollingInterval: POLLING_INTERVAL, pollingTimeout: POLLING_TIMEOUT, connectTimeout: CONNECT_TIMEOUT, - encryptionVersion, }); this._registerClientListeners(); @@ -676,28 +674,9 @@ class GreeHVACDevice extends Homey.Device { } } - if (changedKeys.indexOf('encryption_mode') > -1) { - this.log('Changing the encryption mode setting from', oldSettings.encryption_mode, 'to', newSettings.encryption_mode); - this.homey.setTimeout(this.reconnect.bind(this), 1000); - } - 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; - } - } - reconnect() { this.log('Reconnecting to the HVAC'); this._markOffline(); diff --git a/drivers/gree_cooper_hunter_hvac/driver.compose.json b/drivers/gree_cooper_hunter_hvac/driver.compose.json index 0f02fee..a73f2d6 100644 --- a/drivers/gree_cooper_hunter_hvac/driver.compose.json +++ b/drivers/gree_cooper_hunter_hvac/driver.compose.json @@ -106,37 +106,6 @@ "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/package-lock.json b/package-lock.json index 6b7337d..72c74ff 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/encryption", + "gree-hvac-client": "github:aivus/gree-hvac-client#com.gree/public-aes-gcm-poc", "homey-log": "^2.1.0" }, "devDependencies": { @@ -10535,7 +10535,7 @@ }, "gree-hvac-client": { "version": "git+ssh://git@github.com/aivus/gree-hvac-client.git#7d51627adb76ba50b48fa4f9cd494741c3f2e409", - "from": "gree-hvac-client@github:aivus/gree-hvac-client#com.gree/encryption", + "from": "gree-hvac-client@github:aivus/gree-hvac-client#com.gree/public-aes-gcm-poc", "requires": { "clone": "^2.1.2", "object-diff": "^0.0.4" diff --git a/package.json b/package.json index 74aa3d0..0290a10 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/encryption", + "gree-hvac-client": "github:aivus/gree-hvac-client#com.gree/public-aes-gcm-poc", "homey-log": "^2.1.0" }, "devDependencies": {