361 prevent pin items for non touch screens (#363)

1. Originally intended bug fix:

<img width="577" height="890" alt="image"
src="https://github.com/user-attachments/assets/f04f720d-01f4-43fb-85ef-2b7e2a11099d"
/>

2. Fixes for the schema regarding numeric `tap_action`.
3. Code fix to initialise numeric pickers when no user defined template
is supplied.
4. Amended version history.
This commit is contained in:
Philip Abbey
2026-06-24 18:55:22 +01:00
committed by GitHub
4 changed files with 53 additions and 26 deletions

View File

@@ -59,3 +59,4 @@
| 3.11 | <img src="images/Venu2_glance_default.png" width="200" title="Default Glance"/><br/>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.11 | <img src="images/Venu2_glance_default.png" width="200" title="Default Glance"/><br/>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.12 | Amended GPS accuracy values used by the background service. |
| 3.13 | Added support for new devices: `d2mach2pro`, `fr170`, `fr170m`, `fr70`. | | 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 function. Fix for initialising numeric pickers with no user defined template. |

View File

@@ -251,7 +251,8 @@
"$ref": "#/$defs/content" "$ref": "#/$defs/content"
}, },
"tap_action": { "tap_action": {
"$ref": "#/$defs/tap_action", "title": "Tap Action",
"description": "Numeric tap action definition to include the number picker. 'confirm', 'pin' and 'exit' fields are optional.",
"properties": { "properties": {
"action": { "action": {
"$ref": "#/$defs/action" "$ref": "#/$defs/action"
@@ -294,13 +295,24 @@
"max", "max",
"step", "step",
"data_attribute" "data_attribute"
] ],
"additionalProperties": false
},
"confirm": {
"$ref": "#/$defs/confirm"
},
"pin": {
"$ref": "#/$defs/pin"
},
"exit": {
"$ref": "#/$defs/exit"
} }
}, },
"required": [ "required": [
"action", "action",
"picker" "picker"
] ],
"additionalProperties": false
}, },
"enabled": { "enabled": {
"$ref": "#/$defs/enabled" "$ref": "#/$defs/enabled"
@@ -987,7 +999,7 @@
"tap_action": { "tap_action": {
"type": "object", "type": "object",
"title": "Tap Action", "title": "Tap Action",
"description": "'confirm' and 'pin' fields are optional.", "description": "'confirm', 'pin' and 'exit' fields are optional.",
"properties": { "properties": {
"confirm": { "confirm": {
"$ref": "#/$defs/confirm" "$ref": "#/$defs/confirm"

View File

@@ -112,7 +112,7 @@ class HomeAssistantMenuItemFactory {
label as Lang.String or Lang.Symbol, label as Lang.String or Lang.Symbol,
entity_id as Lang.String?, entity_id as Lang.String?,
template as Lang.String?, template as Lang.String?,
action as Lang.String?, action as Lang.String?,
data as Lang.Dictionary?, data as Lang.Dictionary?,
options as { options as {
:exit as Lang.Boolean, :exit as Lang.Boolean,

View File

@@ -133,23 +133,39 @@ class HomeAssistantView extends WatchUi.Menu2 {
)); ));
} }
} else if (type.equals("numeric") && action != null) { } else if (type.equals("numeric") && action != null) {
if (tap_action != null) { if (System.getDeviceSettings().isTouchScreen) {
var picker = tap_action.get("picker") as Lang.Dictionary?; // Numeric items are only actionable on touch screen devices.
if (picker != null) { if (tap_action != null) {
addItem(HomeAssistantMenuItemFactory.create().numeric( var picker = tap_action.get("picker") as Lang.Dictionary?;
name, if (picker != null) {
entity, addItem(HomeAssistantMenuItemFactory.create().numeric(
content, name,
action, entity,
data, content,
picker, action,
{ data,
:exit => exit, picker,
:confirm => confirm, {
:pin => pin :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) { } else if (type.equals("info") && content != null) {
// Cannot exit from a non-actionable information only menu item. // Cannot exit from a non-actionable information only menu item.
@@ -193,11 +209,9 @@ class HomeAssistantView extends WatchUi.Menu2 {
} }
fullList.addAll(item.getMenuView().getItemsToUpdate()); fullList.addAll(item.getMenuView().getItemsToUpdate());
} else if (item instanceof HomeAssistantNumericMenuItem) { } else if (item instanceof HomeAssistantNumericMenuItem) {
// Numeric items can have an optional template to evaluate // Numeric items can have an optional template to evaluate, but they must always be included in order
var nmi = item as HomeAssistantNumericMenuItem; // to initialise the numeric picker's value.
if (nmi.hasTemplate()) { fullList.add(item);
fullList.add(item);
}
} else if (item instanceof HomeAssistantToggleMenuItem) { } else if (item instanceof HomeAssistantToggleMenuItem) {
fullList.add(item); fullList.add(item);
} else if (item instanceof HomeAssistantTapMenuItem) { } else if (item instanceof HomeAssistantTapMenuItem) {