From 66bae3ac575ccc5e1b52f9f4ece3875903bdfd51 Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Sat, 13 Dec 2025 16:29:18 +0000 Subject: [PATCH] Add error handling for empty menu data New string resource for menu definition errors and updates HomeAssistantApp to show an error message when the menu data is empty. --- resources/strings/strings.xml | 1 + source/HomeAssistantApp.mc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/resources/strings/strings.xml b/resources/strings/strings.xml index 3dad734..8cd73d8 100644 --- a/resources/strings/strings.xml +++ b/resources/strings/strings.xml @@ -32,6 +32,7 @@ No configuration URL in the application settings. No Internet connection. No JSON returned from HTTP request. + Menu definition error, check the instructions. No Phone connection. No phone connection, no cached menu. No Response, check Internet connection diff --git a/source/HomeAssistantApp.mc b/source/HomeAssistantApp.mc index 4fd0318..87aef09 100644 --- a/source/HomeAssistantApp.mc +++ b/source/HomeAssistantApp.mc @@ -218,6 +218,8 @@ class HomeAssistantApp extends Application.AppBase { } else { if (data == null) { ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoJson) as Lang.String); + } else if (data.size() == 0) { + ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoMenu) as Lang.String); } else { buildMenu(data); WatchUi.switchToView(mHaMenu, new HomeAssistantViewDelegate(false), WatchUi.SLIDE_IMMEDIATE);