From be7eed1ae1733a9e1d45a890e1bd314a2ea19578 Mon Sep 17 00:00:00 2001 From: Vincent Elger Zwanenburg Date: Thu, 17 Jul 2025 23:31:05 +0100 Subject: [PATCH] early return from fetchApiStatus for in-app wifi, fix typo in docstrings --- source/HomeAssistantApp.mc | 11 +++++++++-- source/WifiLteExecutionConfirmDelegate.mc | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/source/HomeAssistantApp.mc b/source/HomeAssistantApp.mc index ceb4348..ba2471c 100644 --- a/source/HomeAssistantApp.mc +++ b/source/HomeAssistantApp.mc @@ -575,20 +575,27 @@ class HomeAssistantApp extends Application.AppBase { // (:glance) function fetchApiStatus() as Void { + var phoneConnected = System.getDeviceSettings().phoneConnected; + var connectionAvailable = System.getDeviceSettings().connectionAvailable; + // System.println("API URL = " + Settings.getApiUrl()); if (Settings.getApiUrl().equals("")) { mApiStatus = WatchUi.loadResource($.Rez.Strings.Unconfigured) as Lang.String; WatchUi.requestUpdate(); } else { - if (! System.getDeviceSettings().phoneConnected) { + if (! mIsGlance && Settings.getWifiLteExecutionEnabled() && (! phoneConnected || ! connectionAvailable)) { + // System.println("HomeAssistantApp fetchApiStatus(): In-app Wifi mode (No Phone and Internet connection), early return."); + return; + } else if (! phoneConnected) { // System.println("HomeAssistantApp fetchApiStatus(): No Phone connection, skipping API call."); mApiStatus = WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String; if (mIsGlance) { WatchUi.requestUpdate(); } else { + System.println("we here"); ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoPhone) as Lang.String); } - } else if (! System.getDeviceSettings().connectionAvailable) { + } else if (! connectionAvailable) { // System.println("HomeAssistantApp fetchApiStatus(): No Internet connection, skipping API call."); mApiStatus = WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String; if (mIsGlance) { diff --git a/source/WifiLteExecutionConfirmDelegate.mc b/source/WifiLteExecutionConfirmDelegate.mc index 1901403..a2cdd8e 100644 --- a/source/WifiLteExecutionConfirmDelegate.mc +++ b/source/WifiLteExecutionConfirmDelegate.mc @@ -27,7 +27,7 @@ class WifiLteExecutionConfirmDelegate extends WatchUi.ConfirmationDelegate { //! - url: (For type `"entity"`) The full Home Assistant entity API URL. //! - callback: (For type `"entity"`) A callback method (Method) to handle the response. //! - data: (Optional) A dictionary of data to send with the request. - //! = exit: Boolean: true to exit after running command. + //! - exit: Boolean: if set to true: exit after running command. function initialize(cOptions as { :type as Lang.String, :service as Lang.String or Null,