early return from fetchApiStatus for in-app wifi, fix typo in docstrings

This commit is contained in:
Vincent Elger Zwanenburg
2025-07-17 23:31:05 +01:00
parent 576f8c4a64
commit be7eed1ae1
2 changed files with 10 additions and 3 deletions

View File

@ -575,20 +575,27 @@ class HomeAssistantApp extends Application.AppBase {
// //
(:glance) (:glance)
function fetchApiStatus() as Void { function fetchApiStatus() as Void {
var phoneConnected = System.getDeviceSettings().phoneConnected;
var connectionAvailable = System.getDeviceSettings().connectionAvailable;
// System.println("API URL = " + Settings.getApiUrl()); // System.println("API URL = " + Settings.getApiUrl());
if (Settings.getApiUrl().equals("")) { if (Settings.getApiUrl().equals("")) {
mApiStatus = WatchUi.loadResource($.Rez.Strings.Unconfigured) as Lang.String; mApiStatus = WatchUi.loadResource($.Rez.Strings.Unconfigured) as Lang.String;
WatchUi.requestUpdate(); WatchUi.requestUpdate();
} else { } 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."); // System.println("HomeAssistantApp fetchApiStatus(): No Phone connection, skipping API call.");
mApiStatus = WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String; mApiStatus = WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String;
if (mIsGlance) { if (mIsGlance) {
WatchUi.requestUpdate(); WatchUi.requestUpdate();
} else { } else {
System.println("we here");
ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoPhone) as Lang.String); 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."); // System.println("HomeAssistantApp fetchApiStatus(): No Internet connection, skipping API call.");
mApiStatus = WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String; mApiStatus = WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String;
if (mIsGlance) { if (mIsGlance) {

View File

@ -27,7 +27,7 @@ class WifiLteExecutionConfirmDelegate extends WatchUi.ConfirmationDelegate {
//! - url: (For type `"entity"`) The full Home Assistant entity API URL. //! - url: (For type `"entity"`) The full Home Assistant entity API URL.
//! - callback: (For type `"entity"`) A callback method (Method<data as Dictionary>) to handle the response. //! - callback: (For type `"entity"`) A callback method (Method<data as Dictionary>) to handle the response.
//! - data: (Optional) A dictionary of data to send with the request. //! - 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 { function initialize(cOptions as {
:type as Lang.String, :type as Lang.String,
:service as Lang.String or Null, :service as Lang.String or Null,