Fix for update before Webhook ID (re-)created.

This commit is contained in:
Philip Abbey
2025-08-15 17:04:54 +01:00
parent 756647d156
commit 7d77a79ad8
2 changed files with 40 additions and 19 deletions

View File

@@ -311,7 +311,7 @@ class HomeAssistantApp extends Application.AppBase {
private function buildMenu(menu as Lang.Dictionary) { private function buildMenu(menu as Lang.Dictionary) {
mHaMenu = new HomeAssistantView(menu, null); mHaMenu = new HomeAssistantView(menu, null);
mQuitTimer.begin(); mQuitTimer.begin();
if (!Settings.getWebhookId().equals("")) { if (!Settings.getWebhookId().equals("") && !Settings.getClearWebhookId()) {
startUpdates(); startUpdates();
} // If not, this will be done via a chain in Settings.webhook() and mWebhookManager.requestWebhookId() that registers the sensors. } // If not, this will be done via a chain in Settings.webhook() and mWebhookManager.requestWebhookId() that registers the sensors.
} }
@@ -399,6 +399,10 @@ class HomeAssistantApp extends Application.AppBase {
case 200: case 200:
status = WatchUi.loadResource($.Rez.Strings.Available) as Lang.String; status = WatchUi.loadResource($.Rez.Strings.Available) as Lang.String;
// System.println("mItemsToUpdate: " + mItemsToUpdate); // System.println("mItemsToUpdate: " + mItemsToUpdate);
if (data == null) {
// Simulation and real device behave differently, hence 2nd NoJson error message for "data == null".
ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoJson) as Lang.String);
} else {
if (mItemsToUpdate != null) { if (mItemsToUpdate != null) {
for (var i = 0; i < mItemsToUpdate.size(); i++) { for (var i = 0; i < mItemsToUpdate.size(); i++) {
var item = mItemsToUpdate[i]; var item = mItemsToUpdate[i];
@@ -415,6 +419,7 @@ class HomeAssistantApp extends Application.AppBase {
updateMenuItems(); updateMenuItems();
} }
} }
}
break; break;
default: default:
@@ -816,7 +821,7 @@ class HomeAssistantApp extends Application.AppBase {
mGlanceTimer = null; mGlanceTimer = null;
fetchMenuConfig(); fetchMenuConfig();
fetchApiStatus(); fetchApiStatus();
if (Settings.getWebhookId() != null && !Settings.getWebhookId().equals("")) { if (!Settings.getWebhookId().equals("") && !Settings.getClearWebhookId()) {
fetchGlanceContent(); fetchGlanceContent();
} }
} }

View File

@@ -141,16 +141,24 @@ class Settings {
//! @return The API Key //! @return The API Key
// //
static function getApiKey() as Lang.String { static function getApiKey() as Lang.String {
if (mApiKey == null) {
return "";
} else {
return mApiKey; return mApiKey;
} }
}
//! Get the Webhook ID supplied as part of the Settings. //! Get the Webhook ID supplied as part of the Settings.
//! //!
//! @return The Webhook ID //! @return The Webhook ID
// //
static function getWebhookId() as Lang.String { static function getWebhookId() as Lang.String {
if (mWebhookId == null) {
return "";
} else {
return mWebhookId; return mWebhookId;
} }
}
//! Set the Webhook ID supplied as part of the Settings. //! Set the Webhook ID supplied as part of the Settings.
//! //!
@@ -173,16 +181,24 @@ class Settings {
//! @return The API URL //! @return The API URL
// //
static function getApiUrl() as Lang.String { static function getApiUrl() as Lang.String {
if (mApiUrl == null) {
return "";
} else {
return mApiUrl; return mApiUrl;
} }
}
//! Get the menu configuration URL supplied as part of the Settings. //! Get the menu configuration URL supplied as part of the Settings.
//! //!
//! @return The menu configuration URL //! @return The menu configuration URL
// //
static function getConfigUrl() as Lang.String { static function getConfigUrl() as Lang.String {
if (mConfigUrl == null) {
return "";
} else {
return mConfigUrl; return mConfigUrl;
} }
}
//! Get the menu cache Boolean option supplied as part of the Settings. //! Get the menu cache Boolean option supplied as part of the Settings.
//! //!