From 029e994f8dd6f3d048a7c56c3da60976c040d26b Mon Sep 17 00:00:00 2001 From: Illia Antypenko Date: Thu, 23 Mar 2023 21:48:26 +0100 Subject: [PATCH 1/3] Move polling interval and polling timeout values from constants to settings --- app.json | 24 +++++++++++++++++++ drivers/gree_cooper_hunter_hvac/device.js | 28 ++++++++++++++++------- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/app.json b/app.json index db19762..69885c9 100644 --- a/app.json +++ b/app.json @@ -1221,6 +1221,30 @@ } ], "settings": [ + { + "id": "polling_interval", + "type": "number", + "value": 3500, + "min": 100, + "label": { + "en": "Polling interval" + }, + "hint": { + "en": "Interval between polling status from HVAC (ms)" + } + }, + { + "id": "polling_timeout", + "type": "number", + "value": 3000, + "min": 100, + "label": { + "en": "Polling timeout" + }, + "hint": { + "en": "Timeout for the response from the HVAC during polling process (ms)" + } + }, { "id": "enable_debug", "type": "checkbox", diff --git a/drivers/gree_cooper_hunter_hvac/device.js b/drivers/gree_cooper_hunter_hvac/device.js index 021e7c7..4ba0277 100644 --- a/drivers/gree_cooper_hunter_hvac/device.js +++ b/drivers/gree_cooper_hunter_hvac/device.js @@ -8,12 +8,6 @@ const { compareBoolProperties } = require('../../utils'); // Interval between trying to found HVAC in network (ms) const LOOKING_FOR_DEVICE_TIME_INTERVAL = 5000; -// Interval between polling status from HVAC (ms) -const POLLING_INTERVAL = 3500; - -// Timeout for response from the HVAC during polling process (ms) -const POLLING_TIMEOUT = 3000; - class GreeHVACDevice extends Homey.Device { /** @@ -92,8 +86,8 @@ class GreeHVACDevice extends Homey.Device { this._client = new HVAC.Client({ debug: settings.enable_debug, host: hvac.remoteInfo.address, - pollingInterval: POLLING_INTERVAL, - pollingTimeout: POLLING_TIMEOUT, + pollingInterval: settings.polling_interval, + pollingTimeout: settings.polling_timeout, }); this._registerClientListeners(); @@ -511,6 +505,24 @@ class GreeHVACDevice extends Homey.Device { } } + if (changedKeys.indexOf('polling_interval') > -1) { + console.log('Changing the "polling_interval" settings from', oldSettings.polling_interval, 'to', newSettings.polling_interval); + if (this._client) { + this._markOffline(); + this._tryToDisconnect(); + this._startLookingForDevice(); + } + } + + if (changedKeys.indexOf('polling_timeout') > -1) { + console.log('Changing the "polling_timeout" settings from', oldSettings.polling_timeout, 'to', newSettings.polling_timeout); + if (this._client) { + this._markOffline(); + this._tryToDisconnect(); + this._startLookingForDevice(); + } + } + return Promise.resolve(); } From c11a6c05c4deeb557607c177bc80607e2aebcfbd Mon Sep 17 00:00:00 2001 From: Illia Antypenko Date: Thu, 23 Mar 2023 22:40:03 +0100 Subject: [PATCH 2/3] Add units for new settings --- app.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app.json b/app.json index 69885c9..dc88cb8 100644 --- a/app.json +++ b/app.json @@ -1226,11 +1226,12 @@ "type": "number", "value": 3500, "min": 100, + "units": { "en": "ms" }, "label": { "en": "Polling interval" }, "hint": { - "en": "Interval between polling status from HVAC (ms)" + "en": "Interval between polling status from HVAC" } }, { @@ -1238,11 +1239,12 @@ "type": "number", "value": 3000, "min": 100, + "units": { "en": "ms" }, "label": { "en": "Polling timeout" }, "hint": { - "en": "Timeout for the response from the HVAC during polling process (ms)" + "en": "Timeout for the response from the HVAC during polling process" } }, { From 491f88ea081207df7c373c05b3f3adb19454e00f Mon Sep 17 00:00:00 2001 From: Illia Antypenko Date: Mon, 10 Jun 2024 23:10:05 +0200 Subject: [PATCH 3/3] Add default values to descriptions --- app.json | 8 ++++---- drivers/gree_cooper_hunter_hvac/device.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app.json b/app.json index dc88cb8..71cc4fb 100644 --- a/app.json +++ b/app.json @@ -1231,7 +1231,7 @@ "en": "Polling interval" }, "hint": { - "en": "Interval between polling status from HVAC" + "en": "Interval between polling status from HVAC. Default value 3500" } }, { @@ -1244,7 +1244,7 @@ "en": "Polling timeout" }, "hint": { - "en": "Timeout for the response from the HVAC during polling process" + "en": "Timeout for the response from the HVAC during polling process. Default value 3000" } }, { @@ -1252,10 +1252,10 @@ "type": "checkbox", "value": false, "label": { - "en": "Debug" + "en": "Verbose logging" }, "hint": { - "en": "Enable debug in case the application is crashing. It allows developer to investigate the issue" + "en": "Enable verbose logging in case the application is crashing. It allows developer to investigate the issue" } } ], diff --git a/drivers/gree_cooper_hunter_hvac/device.js b/drivers/gree_cooper_hunter_hvac/device.js index 4ba0277..18e4f07 100644 --- a/drivers/gree_cooper_hunter_hvac/device.js +++ b/drivers/gree_cooper_hunter_hvac/device.js @@ -79,7 +79,7 @@ class GreeHVACDevice extends Homey.Device { return; } - this.log('[find devices]', 'Connecting to device with mac:', hvac.message.mac); + this.log('[find devices]', 'Connecting to device with mac:', hvac.message.mac, 'using next settings:', settings); this._stopLookingForDevice();