From 8c5bdbc1f85aec69802270fc49386552f66eaf9d Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Wed, 24 Jun 2026 00:17:26 +0100 Subject: [PATCH] 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.