Skip to content

Commit

Permalink
Add support of new encryption methods
Browse files Browse the repository at this point in the history
  • Loading branch information
aivus committed Sep 20, 2024
1 parent 36dbcc3 commit 3064bf8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
10 changes: 5 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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 }]
}
}
}
33 changes: 32 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "com.gree",
"version": "0.8.1",
"version": "0.9.0",
"compatibility": ">=12.0.1",
"sdk": 3,
"brandColor": "#ff732e",
Expand Down Expand Up @@ -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": {
Expand Down
16 changes: 16 additions & 0 deletions drivers/gree_cooper_hunter_hvac/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -97,6 +98,7 @@ class GreeHVACDevice extends Homey.Device {
host: hvac.remoteInfo.address,
pollingInterval: POLLING_INTERVAL,
pollingTimeout: POLLING_TIMEOUT,
encryptionVersion,
});

this._registerClientListeners();
Expand Down Expand Up @@ -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;
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 3064bf8

Please sign in to comment.