diff --git a/resources/settings/properties.xml b/resources/settings/properties.xml
index dc45c29..3c75f7a 100644
--- a/resources/settings/properties.xml
+++ b/resources/settings/properties.xml
@@ -51,11 +51,6 @@
-->
3
-
-
-
@@ -89,4 +84,4 @@
-->
-
+
\ No newline at end of file
diff --git a/resources/settings/settings.xml b/resources/settings/settings.xml
index 5e9d6d6..e3b7c73 100644
--- a/resources/settings/settings.xml
+++ b/resources/settings/settings.xml
@@ -65,17 +65,6 @@
-
-
- @Strings.SettingsMenuItemStyleIcons
- @Strings.SettingsMenuItemStyleText
-
-
-
-
+
\ No newline at end of file
diff --git a/resources/strings/strings.xml b/resources/strings/strings.xml
index 8be67ce..736ca22 100644
--- a/resources/strings/strings.xml
+++ b/resources/strings/strings.xml
@@ -13,52 +13,52 @@
-->
- HomeAssistant
-
-
-
-
- Sure?
- Confirmed
- No Phone connection
- No Internet connection
- No Response, check Internet connection
- No API key in the application settings
- No API URL in the application settings
- No configuration URL in the application settings
- API calls too rapid. Please slow down your requests.
- URL not found. Potential API URL error in settings.
- URL not found. Potential Configuration URL error in settings.
- No JSON returned from HTTP request.
- HTTP request returned error code =
- API URL must not have a trailing slash '/'
- Failed to register Webhook
- Failed to render template
- Available
- Checking...
- Unavailable
- Unconfigured
- Cached
-
+ HomeAssistant
+ Sure?
+ Confirmed
+ No Phone connection
+ No Internet connection
+ No Response, check Internet connection
+ No API key in the application settings
+ No API URL in the application settings
+ No configuration URL in the application settings
+ API calls too rapid. Please slow down your requests.
+ URL not found. Potential API URL error in settings.
+ URL not found. Potential Configuration URL error in settings.
+ No JSON returned from HTTP request.
+ HTTP request returned error code =
+ API URL must not have a trailing slash '/'
+ Failed to register Webhook
+ Failed to render template
+ Available
+ Checking...
+ Unavailable
+ Unconfigured
+ Cached
+
-
- Select...
- API Key for HomeAssistant.
- Long-Lived Access Token.
- URL for HomeAssistant API.
- URL for menu configuration (JSON).
- Should the application cache the menu configuration?
- Should the application clear the existing cache next time it is started?
- Timeout in seconds. Exit the application after this period of inactivity to save the device battery.
- 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
- Right to Left
- (Widget only) Automatically start the application from the widget without waiting for a tap.
- Enable the background service to send the clock battery level to Home Assistant.
- The refresh rate (in minutes) at which the background service should repeat sending the battery level.
- (Read only) The Webhook ID created by the watch for battery level updates. You might require this for debugging.
-
+
+ Select...
+ API Key for HomeAssistant.
+ Long-Lived Access Token.
+ URL for HomeAssistant API.
+ URL for menu configuration (JSON).
+ Should the application cache the menu configuration?
+ Should the application clear the existing cache next time it is
+ started?
+ Timeout in seconds. Exit the application after this period of
+ inactivity to save the device battery.
+ 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
+ Right to Left
+ (Widget only) Automatically start the application from the widget
+ without waiting for a tap.
+ Enable the background service to send the clock battery
+ level to Home Assistant.
+ The refresh rate (in minutes) at which the background
+ service should repeat sending the battery level.
+ (Read only) The Webhook ID created by the watch for battery level updates.
+ You might require this for debugging.
+
\ No newline at end of file
diff --git a/source/HomeAssistantIconMenuItem.mc b/source/HomeAssistantIconMenuItem.mc
deleted file mode 100644
index f3ede7c..0000000
--- a/source/HomeAssistantIconMenuItem.mc
+++ /dev/null
@@ -1,72 +0,0 @@
-//-----------------------------------------------------------------------------------
-//
-// Distributed under MIT Licence
-// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
-//
-//-----------------------------------------------------------------------------------
-//
-// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
-// tested on a Venu 2 device. The source code is provided at:
-// https://github.com/house-of-abbey/GarminHomeAssistant.
-//
-// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
-//
-//
-// Description:
-//
-// Menu button that triggers a service.
-//
-//-----------------------------------------------------------------------------------
-
-using Toybox.Lang;
-using Toybox.WatchUi;
-using Toybox.Graphics;
-
-class HomeAssistantIconMenuItem extends WatchUi.IconMenuItem {
- private var mHomeAssistantService as HomeAssistantService;
- private var mService as Lang.String;
- private var mConfirm as Lang.Boolean;
-
- function initialize(
- label as Lang.String or Lang.Symbol,
- subLabel as Lang.String or Lang.Symbol or Null,
- identifier as Lang.Object or Null,
- service as Lang.String or Null,
- confirm as Lang.Boolean,
- icon as Graphics.BitmapType or WatchUi.Drawable,
- options as {
- :alignment as WatchUi.MenuItem.Alignment
- } or Null,
- haService as HomeAssistantService
- ) {
- WatchUi.IconMenuItem.initialize(
- label,
- subLabel,
- identifier,
- icon,
- options
- );
-
- mHomeAssistantService = haService;
- mIdentifier = identifier;
- mService = service;
- mConfirm = confirm;
- }
-
- function callService() as Void {
- if (mConfirm) {
- WatchUi.pushView(
- new HomeAssistantConfirmation(),
- new HomeAssistantConfirmationDelegate(method(:onConfirm)),
- WatchUi.SLIDE_IMMEDIATE
- );
- } else {
- onConfirm();
- }
- }
-
- function onConfirm() as Void {
- mHomeAssistantService.call(mIdentifier as Lang.String, mService);
- }
-
-}
diff --git a/source/HomeAssistantMenuItem.mc b/source/HomeAssistantMenuItem.mc
index cb55927..ce0330f 100644
--- a/source/HomeAssistantMenuItem.mc
+++ b/source/HomeAssistantMenuItem.mc
@@ -22,7 +22,7 @@ using Toybox.Lang;
using Toybox.WatchUi;
using Toybox.Graphics;
-class HomeAssistantMenuItem extends WatchUi.MenuItem {
+class HomeAssistantMenuItem extends WatchUi.IconMenuItem {
private var mHomeAssistantService as HomeAssistantService;
private var mService as Lang.String;
private var mConfirm as Lang.Boolean;
@@ -33,20 +33,22 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem {
identifier as Lang.Object or Null,
service as Lang.String or Null,
confirm as Lang.Boolean,
+ icon as Graphics.BitmapType or WatchUi.Drawable,
options as {
- :alignment as WatchUi.MenuItem.Alignment,
- :icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol
+ :alignment as WatchUi.MenuItem.Alignment
} or Null,
haService as HomeAssistantService
) {
- WatchUi.MenuItem.initialize(
+ WatchUi.IconMenuItem.initialize(
label,
subLabel,
identifier,
+ icon,
options
);
mHomeAssistantService = haService;
+ mIdentifier = identifier;
mService = service;
mConfirm = confirm;
}
diff --git a/source/HomeAssistantMenuItemFactory.mc b/source/HomeAssistantMenuItemFactory.mc
index a3a141a..2ff7fb0 100644
--- a/source/HomeAssistantMenuItemFactory.mc
+++ b/source/HomeAssistantMenuItemFactory.mc
@@ -60,7 +60,7 @@ class HomeAssistantMenuItemFactory {
function toggle(label as Lang.String or Lang.Symbol, identifier as Lang.Object or Null) as WatchUi.MenuItem {
return new HomeAssistantToggleMenuItem(
label,
- Settings.getMenuStyle() == Settings.MENU_STYLE_TEXT ? RezStrings.getLabelToggle() : null,
+ null,
identifier,
false,
mMenuItemOptions
@@ -91,35 +91,19 @@ class HomeAssistantMenuItemFactory {
service as Lang.String or Null,
confirm as Lang.Boolean
) as WatchUi.MenuItem {
- if (Settings.getMenuStyle() == Settings.MENU_STYLE_TEXT) {
- return new HomeAssistantMenuItem(
- label,
- RezStrings.getMenuItemTap(),
- identifier,
- service,
- confirm,
- mMenuItemOptions,
- mHomeAssistantService
- );
- } else {
- return new HomeAssistantIconMenuItem(
- label,
- null,
- identifier,
- service,
- confirm,
- mTapTypeIcon,
- mMenuItemOptions,
- mHomeAssistantService
- );
- }
+ return new HomeAssistantMenuItem(
+ label,
+ null,
+ identifier,
+ service,
+ confirm,
+ mTapTypeIcon,
+ mMenuItemOptions,
+ mHomeAssistantService
+ );
}
function group(definition as Lang.Dictionary) as WatchUi.MenuItem {
- if (Settings.getMenuStyle() == Settings.MENU_STYLE_TEXT) {
- return new HomeAssistantViewMenuItem(definition);
- } else {
- return new HomeAssistantViewIconMenuItem(definition, mGroupTypeIcon, mMenuItemOptions);
- }
+ return new HomeAssistantViewMenuItem(definition, mGroupTypeIcon, mMenuItemOptions);
}
}
diff --git a/source/HomeAssistantView.mc b/source/HomeAssistantView.mc
index 86d98fe..6103493 100644
--- a/source/HomeAssistantView.mc
+++ b/source/HomeAssistantView.mc
@@ -89,7 +89,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
var lmi = mListMenuItems as Lang.Array;
for(var i = 0; i < mListMenuItems.size(); i++) {
var item = lmi[i];
- if (item instanceof HomeAssistantViewMenuItem || item instanceof HomeAssistantViewIconMenuItem) {
+ if (item instanceof HomeAssistantViewMenuItem) {
fullList.addAll(item.getMenuView().getItemsToUpdate());
}
}
@@ -154,12 +154,6 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
System.println(haItem.getLabel() + " " + haItem.getId());
}
haItem.callService();
- } else if (item instanceof HomeAssistantIconMenuItem) {
- var haItem = item as HomeAssistantIconMenuItem;
- if (Globals.scDebug) {
- System.println(haItem.getLabel() + " " + haItem.getId());
- }
- haItem.callService();
} else if (item instanceof HomeAssistantTemplateMenuItem) {
var haItem = item as HomeAssistantTemplateMenuItem;
if (Globals.scDebug) {
@@ -168,12 +162,6 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
haItem.callService();
} else if (item instanceof HomeAssistantViewMenuItem) {
var haMenuItem = item as HomeAssistantViewMenuItem;
- if (Globals.scDebug) {
- System.println("Menu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
- }
- WatchUi.pushView(haMenuItem.getMenuView(), new HomeAssistantViewDelegate(false), WatchUi.SLIDE_LEFT);
- } else if (item instanceof HomeAssistantViewIconMenuItem) {
- var haMenuItem = item as HomeAssistantViewIconMenuItem;
if (Globals.scDebug) {
System.println("IconMenu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
}
diff --git a/source/HomeAssistantViewIconMenuItem.mc b/source/HomeAssistantViewIconMenuItem.mc
deleted file mode 100644
index 474b8e1..0000000
--- a/source/HomeAssistantViewIconMenuItem.mc
+++ /dev/null
@@ -1,48 +0,0 @@
-//-----------------------------------------------------------------------------------
-//
-// Distributed under MIT Licence
-// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
-//
-//-----------------------------------------------------------------------------------
-//
-// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
-// tested on a Venu 2 device. The source code is provided at:
-// https://github.com/house-of-abbey/GarminHomeAssistant.
-//
-// P A Abbey & J D Abbey & Someone0nEarth, 16 November 2023
-//
-//
-// Description:
-//
-// Menu button with an icon that opens a sub-menu.
-//
-//-----------------------------------------------------------------------------------
-
-using Toybox.Lang;
-using Toybox.WatchUi;
-
-class HomeAssistantViewIconMenuItem extends WatchUi.IconMenuItem {
- private var mMenu as HomeAssistantView;
-
- function initialize(definition as Lang.Dictionary, icon as WatchUi.Drawable, options as {
- :alignment as WatchUi.MenuItem.Alignment
- } or Null) {
- var label = definition.get("name") as Lang.String;
- var identifier = definition.get("entity") as Lang.String;
-
- WatchUi.IconMenuItem.initialize(
- label,
- null,
- identifier,
- icon,
- options
- );
-
- mMenu = new HomeAssistantView(definition, null);
- }
-
- function getMenuView() as HomeAssistantView {
- return mMenu;
- }
-
-}
diff --git a/source/HomeAssistantViewMenuItem.mc b/source/HomeAssistantViewMenuItem.mc
index 1c0ccb7..5b5ef7a 100644
--- a/source/HomeAssistantViewMenuItem.mc
+++ b/source/HomeAssistantViewMenuItem.mc
@@ -9,28 +9,33 @@
// tested on a Venu 2 device. The source code is provided at:
// https://github.com/house-of-abbey/GarminHomeAssistant.
//
-// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
+// P A Abbey & J D Abbey & Someone0nEarth, 16 November 2023
//
//
// Description:
//
-// Menu button that opens a sub-menu.
+// Menu button with an icon that opens a sub-menu.
//
//-----------------------------------------------------------------------------------
using Toybox.Lang;
using Toybox.WatchUi;
-class HomeAssistantViewMenuItem extends WatchUi.MenuItem {
+class HomeAssistantViewMenuItem extends WatchUi.IconMenuItem {
private var mMenu as HomeAssistantView;
- function initialize(definition as Lang.Dictionary) {
- // definitions.get(...) are Strings here as they have been checked by HomeAssistantView first
- WatchUi.MenuItem.initialize(
- definition.get("name") as Lang.String,
- RezStrings.getMenuItemMenu(),
- definition.get("entity") as Lang.String,
- null
+ function initialize(definition as Lang.Dictionary, icon as WatchUi.Drawable, options as {
+ :alignment as WatchUi.MenuItem.Alignment
+ } or Null) {
+ var label = definition.get("name") as Lang.String;
+ var identifier = definition.get("entity") as Lang.String;
+
+ WatchUi.IconMenuItem.initialize(
+ label,
+ null,
+ identifier,
+ icon,
+ options
);
mMenu = new HomeAssistantView(definition, null);
diff --git a/source/RezStrings.mc b/source/RezStrings.mc
index 05d55cf..3a03eaf 100644
--- a/source/RezStrings.mc
+++ b/source/RezStrings.mc
@@ -27,8 +27,6 @@ class RezStrings {
(:glance)
private static var strAppName as Lang.String or Null;
- private static var strMenuItemTap as Lang.String or Null;
- private static var strMenuItemMenu as Lang.String or Null;
private static var strConfirm as Lang.String or Null;
private static var strExecuted as Lang.String or Null;
(:glance)
@@ -61,7 +59,6 @@ class RezStrings {
private static var strCached as Lang.String or Null;
(:glance)
private static var strGlanceMenu as Lang.String or Null;
- private static var strLabelToggle as Lang.Dictionary or Null;
// Can't initialise a constant directly, have to be initialised via a function
// for 'WatchUi.loadResource' to be available.
@@ -84,8 +81,6 @@ class RezStrings {
// for 'WatchUi.loadResource' to be available.
static function update() {
strAppName = WatchUi.loadResource($.Rez.Strings.AppName);
- strMenuItemTap = WatchUi.loadResource($.Rez.Strings.MenuItemTap);
- strMenuItemMenu = WatchUi.loadResource($.Rez.Strings.MenuItemMenu);
strConfirm = WatchUi.loadResource($.Rez.Strings.Confirm);
strExecuted = WatchUi.loadResource($.Rez.Strings.Executed);
strNoPhone = WatchUi.loadResource($.Rez.Strings.NoPhone);
@@ -108,24 +103,12 @@ class RezStrings {
strUnconfigured = WatchUi.loadResource($.Rez.Strings.Unconfigured);
strCached = WatchUi.loadResource($.Rez.Strings.Cached);
strGlanceMenu = WatchUi.loadResource($.Rez.Strings.GlanceMenu);
- strLabelToggle = {
- :enabled => WatchUi.loadResource($.Rez.Strings.MenuItemOn) as Lang.String,
- :disabled => WatchUi.loadResource($.Rez.Strings.MenuItemOff) as Lang.String
- };
}
static function getAppName() as Lang.String {
return strAppName;
}
- static function getMenuItemTap() as Lang.String {
- return strMenuItemTap;
- }
-
- static function getMenuItemMenu() as Lang.String {
- return strMenuItemMenu;
- }
-
static function getConfirm() as Lang.String {
return strConfirm;
}
@@ -214,8 +197,4 @@ class RezStrings {
return strGlanceMenu;
}
- static function getLabelToggle() as Lang.Dictionary {
- return strLabelToggle;
- }
-
}
diff --git a/source/Settings.mc b/source/Settings.mc
index 443c8ce..d381660 100644
--- a/source/Settings.mc
+++ b/source/Settings.mc
@@ -28,9 +28,6 @@ using Toybox.Time;
(:glance, :background)
class Settings {
- public static const MENU_STYLE_ICONS = 0;
- public static const MENU_STYLE_TEXT = 1;
-
private static var mApiKey as Lang.String = "";
private static var mWebhookId as Lang.String = "";
private static var mApiUrl as Lang.String = "";
@@ -39,7 +36,6 @@ class Settings {
private static var mClearCache as Lang.Boolean = false;
private static var mAppTimeout as Lang.Number = 0; // seconds
private static var mConfirmTimeout as Lang.Number = 3; // seconds
- private static var mMenuStyle as Lang.Number = MENU_STYLE_ICONS;
private static var mMenuAlignment as Lang.Number = WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT;
private static var mIsWidgetStartNoTap as Lang.Boolean = false;
private static var mIsBatteryLevelEnabled as Lang.Boolean = false;
@@ -60,7 +56,6 @@ class Settings {
mClearCache = Properties.getValue("clear_cache");
mAppTimeout = Properties.getValue("app_timeout");
mConfirmTimeout = Properties.getValue("confirm_timeout");
- mMenuStyle = Properties.getValue("menu_theme");
mMenuAlignment = Properties.getValue("menu_alignment");
mIsWidgetStartNoTap = Properties.getValue("widget_start_no_tap");
mIsBatteryLevelEnabled = Properties.getValue("enable_battery_level");
@@ -143,10 +138,6 @@ class Settings {
return mConfirmTimeout * 1000; // Convert to milliseconds
}
- static function getMenuStyle() as Lang.Number {
- return mMenuStyle; // Either MENU_STYLE_ICONS or MENU_STYLE_TEXT
- }
-
static function getMenuAlignment() as Lang.Number {
return mMenuAlignment; // Either WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_RIGHT or WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT
}