From a0fe746c1d75b8084d890615b031206176bb0796 Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Thu, 21 Mar 2024 09:15:47 +0000 Subject: [PATCH] Amended update method to entire rounds A single larger delay is now inserted once between entire rounds of status updates, --- README.md | 2 +- resources/settings/properties.xml | 11 +++++------ resources/strings/strings.xml | 2 +- source/HomeAssistantApp.mc | 4 ++-- source/Settings.mc | 8 +------- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f539b53..f037f7f 100644 --- a/README.md +++ b/README.md @@ -240,7 +240,7 @@ You may choose to cache your menu definition on your device in order to reduce t The application uses vibration to confirm the action has been requested, as opposed to the 'toast' appears to show the action has been successfully executed. This is enabled by default but may be turned off if you do not desire this behaviour. -The application timeout prevents the HomeAssistant App running on your watch when you have forgotten to close it. It prevents the refreshing of the menu statuses and therefore excessive wear on your battery level. For those users who prefer to keep the application open all the time for continuous use, they can reduce the battery wear by increasing the "poll delay". This inserts a user configurable number of milliseconds between each item's update check, hence reducing the API access activity. This also reduces the responsive of the statuses displayed when HA devices are switched externally, i.e. by another Home Assistant client, then the watch menu display will not update as quickly. Therefore if you only use the HomeAssistant App briefly now and then, keep this setting at the default 0 seconds. NB. There's a minimum of 50 ms in ConnectIQ timers, so anything less and the value here is forced to 0 ms which turns this feature off completely. +The application timeout prevents the HomeAssistant App running on your watch when you have forgotten to close it. It prevents the refreshing of the menu statuses and therefore excessive wear on your battery level. For those users who prefer to keep the application open all the time for continuous use, they can reduce the battery wear by increasing the "poll delay". This inserts a user configurable number of seconds between each round of item update checks, hence reducing the API access activity. This also reduces the responsive of the statuses displayed when HA devices are switched externally, i.e. by another Home Assistant client, then the watch menu display will not update as quickly. Therefore if you only use the HomeAssistant App briefly now and then, keep this setting at the default 0 seconds. NB. To be clear, all items are updated then a configurable delay is inserted before the next round of all item updates. There is a second timeout value for confirmation views. This is intended for use with more sensitive toggles so that the confirmation view is not left open and forgotten and then confirmed accidentally without you noticing. **We cannot advise you this is safe, be careful what you toggle with the watch application!** diff --git a/resources/settings/properties.xml b/resources/settings/properties.xml index fdb6637..37f156a 100644 --- a/resources/settings/properties.xml +++ b/resources/settings/properties.xml @@ -50,12 +50,11 @@ 0 0 diff --git a/resources/strings/strings.xml b/resources/strings/strings.xml index 1382201..3289a53 100644 --- a/resources/strings/strings.xml +++ b/resources/strings/strings.xml @@ -48,7 +48,7 @@ Should the application clear the existing cache next time it is started? Should the application provide feedback via vibrations? Timeout in seconds. Exit the application after this period of inactivity to save the device battery. - Additional poll delay (in milliseconds). Adds a delay between the status update of menu items. + Additional poll delay (in seconds). Adds a delay between the status update of all menu items. After this time (in seconds), a confirmation dialog for an action is automatically closed and the action is cancelled. Set to 0 to disable the timeout. Left (off) or Right (on) Menu Alignment. Left to right diff --git a/source/HomeAssistantApp.mc b/source/HomeAssistantApp.mc index 983df25..aa701c3 100644 --- a/source/HomeAssistantApp.mc +++ b/source/HomeAssistantApp.mc @@ -261,7 +261,7 @@ class HomeAssistantApp extends Application.AppBase { // Start the continuous update process that continues for as long as the application is running. // The chain of functions from 'updateNextMenuItem()' calls 'updateNextMenuItem()' on completion. if (mItemsToUpdate.size() > 0) { - updateNextMenuItem(); + updateNextMenuItemInt(); } } @@ -396,7 +396,7 @@ class HomeAssistantApp extends Application.AppBase { function updateNextMenuItem() as Void { var delay = Settings.getPollDelay(); - if (delay >= 50) { // Minimum 50 ms delay for Timers + if ((delay > 0) and (mNextItemToUpdate == 0)) { mUpdateTimer.start(method(:updateNextMenuItemInt), delay, false); } else { updateNextMenuItemInt(); diff --git a/source/Settings.mc b/source/Settings.mc index b354fdd..5197298 100644 --- a/source/Settings.mc +++ b/source/Settings.mc @@ -63,12 +63,6 @@ class Settings { mIsBatteryLevelEnabled = Properties.getValue("enable_battery_level"); mBatteryRefreshRate = Properties.getValue("battery_level_refresh_rate"); - // There's a minimum of 50 ms on Timer.Timers, so reset to 0 if too small. - if (mPollDelay < 50) { // milliseconds - mPollDelay = 0; - Properties.setValue("poll_delay", mPollDelay); - } - if (System has :ServiceDelegate) { mHasService = true; } @@ -147,7 +141,7 @@ class Settings { } static function getPollDelay() as Lang.Number { - return mPollDelay; + return mPollDelay * 1000; // Convert to milliseconds } static function getConfirmTimeout() as Lang.Number {