mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-05-01 05:02:34 +00:00
Initial solution
This commit is contained in:
@ -240,7 +240,9 @@ 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 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. 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!**
|
||||
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.
|
||||
|
||||
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!**
|
||||
|
||||
There is a toggle setting for "text alignment" that provides finer adjustment for right-to-left languages. Perhaps this could be made automatic based on device language?
|
||||
|
||||
|
@ -22,37 +22,47 @@
|
||||
<property id="api_url" type="string"></property>
|
||||
|
||||
<!--
|
||||
Best be a public URL in order to work away from your
|
||||
home LAN and have a trusted HTTPS certificate
|
||||
Best be a public URL in order to work away from your home LAN and have a
|
||||
trusted HTTPS certificate.
|
||||
-->
|
||||
<property id="config_url" type="string"></property>
|
||||
|
||||
<!-- Decide if the menu configuration should be cached. -->
|
||||
<!--
|
||||
Decide if the menu configuration should be cached.
|
||||
-->
|
||||
<property id="cache_config" type="boolean">false</property>
|
||||
|
||||
<!--
|
||||
Clear the menu configuration on next application start,
|
||||
and refetch, then set this back to false
|
||||
Clear the menu configuration on next application start, and refetch, then
|
||||
set this back to false.
|
||||
-->
|
||||
<property id="clear_cache" type="boolean">false</property>
|
||||
|
||||
<!--
|
||||
Enable notification via vibrations, typically for confirmation of actions
|
||||
Enable notification via vibrations, typically for confirmation of actions.
|
||||
-->
|
||||
<property id="enable_vibration" type="boolean">true</property>
|
||||
|
||||
<!--
|
||||
Application timeout in seconds, except 0 for no
|
||||
timeout (default). After this amount of elapsed
|
||||
time with no activity, exit the application.
|
||||
Application timeout in seconds, except 0 for no timeout (default). After
|
||||
this amount of elapsed time with no activity, exit the application.
|
||||
-->
|
||||
<property id="app_timeout" type="number">0</property>
|
||||
|
||||
<!--
|
||||
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.
|
||||
The default value is 3 seconds.
|
||||
Poll delay adds a user configurable delay (in milliseconds) to the status
|
||||
updates of each item in the watch menu that might be amended externally
|
||||
from the watch. A user has requested that it is possible to add this delay
|
||||
for an "always open" mode of operation, which then drains the watch battery
|
||||
from the additional API access activity. A Timer must have a minimum 50 ms
|
||||
value specified, so any value < 50 will be forced to 0.
|
||||
-->
|
||||
<property id="poll_delay" type="number">0</property>
|
||||
|
||||
<!--
|
||||
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. The default value is 3 seconds.
|
||||
-->
|
||||
<property id="confirm_timeout" type="number">3</property>
|
||||
|
||||
@ -62,7 +72,8 @@
|
||||
<property id="menu_alignment" type="number">1</property>
|
||||
|
||||
<!--
|
||||
Enable the background service to send the clock battery level to Home Assistant.
|
||||
Enable the background service to send the clock battery level to Home
|
||||
Assistant.
|
||||
-->
|
||||
<property id="enable_battery_level" type="boolean">false</property>
|
||||
|
||||
@ -73,11 +84,10 @@
|
||||
<property id="battery_level_refresh_rate" type="number">15</property>
|
||||
|
||||
<!--
|
||||
The webhook ID is the last part of the webhook URL.
|
||||
It is secret and should not be shared.
|
||||
It will not be set in settings but will be
|
||||
generated by the application and stored in
|
||||
properties, but read only for trouble shooting.
|
||||
The webhook ID is the last part of the webhook URL. It is secret and
|
||||
should not be shared. It will not be set in settings but will be
|
||||
generated by the application and stored in properties, but read only
|
||||
for trouble shooting.
|
||||
-->
|
||||
<property id="webhook_id" type="string"></property>
|
||||
|
||||
|
@ -65,6 +65,13 @@
|
||||
<settingConfig type="numeric" min="0" />
|
||||
</setting>
|
||||
|
||||
<setting
|
||||
propertyKey="@Properties.poll_delay"
|
||||
title="@Strings.SettingsPollDelay"
|
||||
>
|
||||
<settingConfig type="numeric" min="0" />
|
||||
</setting>
|
||||
|
||||
<setting
|
||||
propertyKey="@Properties.confirm_timeout"
|
||||
title="@Strings.SettingsConfirmTimeout"
|
||||
|
@ -48,6 +48,7 @@
|
||||
<string id="SettingsClearCache">Should the application clear the existing cache next time it is started?</string>
|
||||
<string id="SettingsVibration">Should the application provide feedback via vibrations?</string>
|
||||
<string id="SettingsAppTimeout">Timeout in seconds. Exit the application after this period of inactivity to save the device battery.</string>
|
||||
<string id="SettingsPollDelay">Additional poll delay (in milliseconds). Adds a delay between the status update of menu items.</string>
|
||||
<string id="SettingsConfirmTimeout">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.</string>
|
||||
<string id="SettingsTextAlign">Left (off) or Right (on) Menu Alignment.</string>
|
||||
<string id="LeftToRight">Left to right</string>
|
||||
|
@ -31,7 +31,8 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
private var mMenuStatus as Lang.String or Null;
|
||||
private var mHaMenu as HomeAssistantView or Null;
|
||||
private var mQuitTimer as QuitTimer or Null;
|
||||
private var mTimer as Timer.Timer or Null;
|
||||
private var mGlanceTimer as Timer.Timer or Null;
|
||||
private var mUpdateTimer as Timer.Timer or Null;
|
||||
// Array initialised by onReturnFetchMenuConfig()
|
||||
private var mItemsToUpdate as Lang.Array<HomeAssistantToggleMenuItem or HomeAssistantTemplateMenuItem> or Null;
|
||||
private var mNextItemToUpdate as Lang.Number = 0; // Index into the above array
|
||||
@ -87,11 +88,11 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
|
||||
// Return the initial view of your application here
|
||||
function getInitialView() as Lang.Array<WatchUi.Views or WatchUi.InputDelegates>? {
|
||||
mIsApp = true;
|
||||
mQuitTimer = new QuitTimer();
|
||||
// RezStrings.update();
|
||||
mApiStatus = WatchUi.loadResource($.Rez.Strings.Checking) as Lang.String;
|
||||
mMenuStatus = WatchUi.loadResource($.Rez.Strings.Checking) as Lang.String;
|
||||
mIsApp = true;
|
||||
mQuitTimer = new QuitTimer();
|
||||
mUpdateTimer = new Timer.Timer();
|
||||
mApiStatus = WatchUi.loadResource($.Rez.Strings.Checking) as Lang.String;
|
||||
mMenuStatus = WatchUi.loadResource($.Rez.Strings.Checking) as Lang.String;
|
||||
Settings.update();
|
||||
|
||||
if (Settings.getApiKey().length() == 0) {
|
||||
@ -393,15 +394,24 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
WatchUi.pushView(mHaMenu, new HomeAssistantViewDelegate(true), WatchUi.SLIDE_IMMEDIATE);
|
||||
}
|
||||
|
||||
function updateNextMenuItem() as Void {
|
||||
var delay = Settings.getPollDelay();
|
||||
if (delay >= 50) { // Minimum 50 ms delay for Timers
|
||||
mUpdateTimer.start(method(:updateNextMenuItemInt), delay, false);
|
||||
} else {
|
||||
updateNextMenuItemInt();
|
||||
}
|
||||
}
|
||||
|
||||
// We need to spread out the API calls so as not to overload the results queue and cause Communications.BLE_QUEUE_FULL
|
||||
// (-101) error. This function is called by a timer every Globals.menuItemUpdateInterval ms.
|
||||
function updateNextMenuItem() as Void {
|
||||
function updateNextMenuItemInt() as Void {
|
||||
var itu = mItemsToUpdate as Lang.Array<HomeAssistantToggleMenuItem>;
|
||||
if (itu != null) {
|
||||
itu[mNextItemToUpdate].getState();
|
||||
mNextItemToUpdate = (mNextItemToUpdate + 1) % itu.size();
|
||||
// } else {
|
||||
// System.println("HomeAssistantApp updateNextMenuItem(): No menu items to update");
|
||||
// System.println("HomeAssistantApp updateNextMenuItemInt(): No menu items to update");
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,13 +425,14 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
mMenuStatus = WatchUi.loadResource($.Rez.Strings.Checking) as Lang.String;
|
||||
updateStatus();
|
||||
Settings.update();
|
||||
mTimer = new Timer.Timer();
|
||||
mTimer.start(method(:updateStatus), Globals.scApiBackoff, true);
|
||||
mGlanceTimer = new Timer.Timer();
|
||||
mGlanceTimer.start(method(:updateStatus), Globals.scApiBackoff, true);
|
||||
return [new HomeAssistantGlanceView(self)];
|
||||
}
|
||||
|
||||
// Required for the Glance update timer.
|
||||
function updateStatus() as Void {
|
||||
mGlanceTimer = null;
|
||||
fetchMenuConfig();
|
||||
fetchApiStatus();
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ class Settings {
|
||||
private static var mClearCache as Lang.Boolean = false;
|
||||
private static var mVibrate as Lang.Boolean = false;
|
||||
private static var mAppTimeout as Lang.Number = 0; // seconds
|
||||
private static var mPollDelay as Lang.Number = 0; // milliseconds
|
||||
private static var mConfirmTimeout as Lang.Number = 3; // seconds
|
||||
private static var mMenuAlignment as Lang.Number = WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT;
|
||||
private static var mIsBatteryLevelEnabled as Lang.Boolean = false;
|
||||
@ -56,11 +57,18 @@ class Settings {
|
||||
mClearCache = Properties.getValue("clear_cache");
|
||||
mVibrate = Properties.getValue("enable_vibration");
|
||||
mAppTimeout = Properties.getValue("app_timeout");
|
||||
mPollDelay = Properties.getValue("poll_delay");
|
||||
mConfirmTimeout = Properties.getValue("confirm_timeout");
|
||||
mMenuAlignment = Properties.getValue("menu_alignment");
|
||||
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;
|
||||
}
|
||||
@ -138,6 +146,10 @@ class Settings {
|
||||
return mAppTimeout * 1000; // Convert to milliseconds
|
||||
}
|
||||
|
||||
static function getPollDelay() as Lang.Number {
|
||||
return mPollDelay;
|
||||
}
|
||||
|
||||
static function getConfirmTimeout() as Lang.Number {
|
||||
return mConfirmTimeout * 1000; // Convert to milliseconds
|
||||
}
|
||||
@ -153,4 +165,5 @@ class Settings {
|
||||
Background.deleteTemporalEvent();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user