From 8c5bdbc1f85aec69802270fc49386552f66eaf9d Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Wed, 24 Jun 2026 00:17:26 +0100 Subject: [PATCH 1/5] Non-touch screens cannot use PIN When a menu item requests a PIN on devices without a touch screen, replace the menu item with an info item displaying a message for the user. --- source/HomeAssistantMenuItemFactory.mc | 2 +- source/HomeAssistantView.mc | 48 +++++++++++++++++--------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/source/HomeAssistantMenuItemFactory.mc b/source/HomeAssistantMenuItemFactory.mc index 5060c5c..e53dcf7 100644 --- a/source/HomeAssistantMenuItemFactory.mc +++ b/source/HomeAssistantMenuItemFactory.mc @@ -112,7 +112,7 @@ class HomeAssistantMenuItemFactory { label as Lang.String or Lang.Symbol, entity_id as Lang.String?, template as Lang.String?, - action as Lang.String?, + action as Lang.String?, data as Lang.Dictionary?, options as { :exit as Lang.Boolean, diff --git a/source/HomeAssistantView.mc b/source/HomeAssistantView.mc index 60c8cff..50d8c1a 100644 --- a/source/HomeAssistantView.mc +++ b/source/HomeAssistantView.mc @@ -133,23 +133,39 @@ class HomeAssistantView extends WatchUi.Menu2 { )); } } else if (type.equals("numeric") && action != null) { - if (tap_action != null) { - var picker = tap_action.get("picker") as Lang.Dictionary?; - if (picker != null) { - addItem(HomeAssistantMenuItemFactory.create().numeric( - name, - entity, - content, - action, - data, - picker, - { - :exit => exit, - :confirm => confirm, - :pin => pin - } - )); + if (System.getDeviceSettings().isTouchScreen) { + // Numeric items are only actionable on touch screen devices. + if (tap_action != null) { + var picker = tap_action.get("picker") as Lang.Dictionary?; + if (picker != null) { + addItem(HomeAssistantMenuItemFactory.create().numeric( + name, + entity, + content, + action, + data, + picker, + { + :exit => exit, + :confirm => confirm, + :pin => pin + } + )); + } } + } else { + addItem(HomeAssistantMenuItemFactory.create().tap( + "PIN requires Touchscreen", + null, + null, + null, + data, + { + :exit => false, + :confirm => false, + :pin => false + } + )); } } else if (type.equals("info") && content != null) { // Cannot exit from a non-actionable information only menu item. From 3404c7f6794b155ee6a572228b96c4fe195d53e2 Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Wed, 24 Jun 2026 01:12:20 +0100 Subject: [PATCH 2/5] Update schema for numeric tap_action and HISTORY Add schema metadata and stricter validation for numeric tap_action: include title & description, disallow additionalProperties on the tap_action and its picker properties to better define the number picker payload. Update HISTORY.md with a 3.14 entry documenting numeric items now supporting tap_action.data and the PIN/menu behavior change, and credit the contributor. --- HISTORY.md | 1 + config.schema.json | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index e844011..6f29d3c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -59,3 +59,4 @@ | 3.11 |
Better handling of menus larger than the Glance view can handle. As a result the Glance can no longer verify the availability of the JSON menu as fetching it might cause an _"Error: Out Of Memory Error"_. Provide two user supplied HTTP Headers. Bug fix for the numeric picker. | | 3.12 | Amended GPS accuracy values used by the background service. | | 3.13 | Added support for new devices: `d2mach2pro`, `fr170`, `fr170m`, `fr70`. | +| 3.14 | Numeric items now support `tap_action.data` fields so service call options like `transition` are catered for. See the documentation on [Additional Action Data](https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/examples/Numeric.md#additional-action-data). This features has been provided by [@StumblingGamer](https://github.com/StumblingGamer). Now prevent PIN enabled menu items from being enabled on non-touch screen devices. The PIN must be removed for the menu item to render. | \ No newline at end of file diff --git a/config.schema.json b/config.schema.json index 01f701c..9c6f9eb 100644 --- a/config.schema.json +++ b/config.schema.json @@ -251,7 +251,8 @@ "$ref": "#/$defs/content" }, "tap_action": { - "$ref": "#/$defs/tap_action", + "title": "Tap Action", + "description": "Numeric tap action definition to include the number picker.", "properties": { "action": { "$ref": "#/$defs/action" @@ -294,13 +295,15 @@ "max", "step", "data_attribute" - ] + ], + "additionalProperties": false } }, "required": [ "action", "picker" - ] + ], + "additionalProperties": false }, "enabled": { "$ref": "#/$defs/enabled" From c48d74138ad46ae818ff34b5c896105c5994e99c Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Wed, 24 Jun 2026 01:38:34 +0100 Subject: [PATCH 3/5] Update config.schema.json Numeric's tap_action is different to the tap's, and re-using the $ref caused problems, so properties have been copied. --- config.schema.json | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/config.schema.json b/config.schema.json index 9c6f9eb..9c0dc49 100644 --- a/config.schema.json +++ b/config.schema.json @@ -252,7 +252,7 @@ }, "tap_action": { "title": "Tap Action", - "description": "Numeric tap action definition to include the number picker.", + "description": "Numeric tap action definition to include the number picker. 'confirm', 'pin' and 'exit' fields are optional.", "properties": { "action": { "$ref": "#/$defs/action" @@ -297,6 +297,15 @@ "data_attribute" ], "additionalProperties": false + }, + "confirm": { + "$ref": "#/$defs/confirm" + }, + "pin": { + "$ref": "#/$defs/pin" + }, + "exit": { + "$ref": "#/$defs/exit" } }, "required": [ @@ -990,7 +999,7 @@ "tap_action": { "type": "object", "title": "Tap Action", - "description": "'confirm' and 'pin' fields are optional.", + "description": "'confirm', 'pin' and 'exit' fields are optional.", "properties": { "confirm": { "$ref": "#/$defs/confirm" From e0b5978406ee8388fd9bc4af17bc3bba85c85174 Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Wed, 24 Jun 2026 02:02:18 +0100 Subject: [PATCH 4/5] Update HomeAssistantView.mc Bug fix for numeric picker initialisation when no user defined template is supplied. --- source/HomeAssistantView.mc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source/HomeAssistantView.mc b/source/HomeAssistantView.mc index 50d8c1a..61dac5d 100644 --- a/source/HomeAssistantView.mc +++ b/source/HomeAssistantView.mc @@ -209,11 +209,9 @@ class HomeAssistantView extends WatchUi.Menu2 { } fullList.addAll(item.getMenuView().getItemsToUpdate()); } else if (item instanceof HomeAssistantNumericMenuItem) { - // Numeric items can have an optional template to evaluate - var nmi = item as HomeAssistantNumericMenuItem; - if (nmi.hasTemplate()) { - fullList.add(item); - } + // Numeric items can have an optional template to evaluate, but they must always be included in order + // to initialise the numeric picker's value. + fullList.add(item); } else if (item instanceof HomeAssistantToggleMenuItem) { fullList.add(item); } else if (item instanceof HomeAssistantTapMenuItem) { From 02a9472ac181fe2bee2c168e0518beea1bcb43b7 Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Wed, 24 Jun 2026 02:10:38 +0100 Subject: [PATCH 5/5] Update HISTORY.md --- HISTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 6f29d3c..c231809 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -59,4 +59,4 @@ | 3.11 |
Better handling of menus larger than the Glance view can handle. As a result the Glance can no longer verify the availability of the JSON menu as fetching it might cause an _"Error: Out Of Memory Error"_. Provide two user supplied HTTP Headers. Bug fix for the numeric picker. | | 3.12 | Amended GPS accuracy values used by the background service. | | 3.13 | Added support for new devices: `d2mach2pro`, `fr170`, `fr170m`, `fr70`. | -| 3.14 | Numeric items now support `tap_action.data` fields so service call options like `transition` are catered for. See the documentation on [Additional Action Data](https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/examples/Numeric.md#additional-action-data). This features has been provided by [@StumblingGamer](https://github.com/StumblingGamer). Now prevent PIN enabled menu items from being enabled on non-touch screen devices. The PIN must be removed for the menu item to render. | \ No newline at end of file +| 3.14 | Numeric items now support `tap_action.data` fields so service call options like `transition` are catered for. See the documentation on [Additional Action Data](https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/examples/Numeric.md#additional-action-data). This features has been provided by [@StumblingGamer](https://github.com/StumblingGamer). Now prevent PIN enabled menu items from being enabled on non-touch screen devices. The PIN must be removed for the menu item to function. Fix for initialising numeric pickers with no user defined template. | \ No newline at end of file