mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-09-12 20:31:31 +00:00
Fix for update before Webhook ID (re-)created.
This commit is contained in:
@@ -311,7 +311,7 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
private function buildMenu(menu as Lang.Dictionary) {
|
||||
mHaMenu = new HomeAssistantView(menu, null);
|
||||
mQuitTimer.begin();
|
||||
if (!Settings.getWebhookId().equals("")) {
|
||||
if (!Settings.getWebhookId().equals("") && !Settings.getClearWebhookId()) {
|
||||
startUpdates();
|
||||
} // If not, this will be done via a chain in Settings.webhook() and mWebhookManager.requestWebhookId() that registers the sensors.
|
||||
}
|
||||
@@ -399,20 +399,25 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
case 200:
|
||||
status = WatchUi.loadResource($.Rez.Strings.Available) as Lang.String;
|
||||
// System.println("mItemsToUpdate: " + mItemsToUpdate);
|
||||
if (mItemsToUpdate != null) {
|
||||
for (var i = 0; i < mItemsToUpdate.size(); i++) {
|
||||
var item = mItemsToUpdate[i];
|
||||
var state = data.get(i.toString());
|
||||
item.updateState(state);
|
||||
if (item instanceof HomeAssistantToggleMenuItem) {
|
||||
(item as HomeAssistantToggleMenuItem).updateToggleState(data.get(i.toString() + "t"));
|
||||
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) {
|
||||
for (var i = 0; i < mItemsToUpdate.size(); i++) {
|
||||
var item = mItemsToUpdate[i];
|
||||
var state = data.get(i.toString());
|
||||
item.updateState(state);
|
||||
if (item instanceof HomeAssistantToggleMenuItem) {
|
||||
(item as HomeAssistantToggleMenuItem).updateToggleState(data.get(i.toString() + "t"));
|
||||
}
|
||||
}
|
||||
var delay = Settings.getPollDelay();
|
||||
if (delay > 0) {
|
||||
mUpdateTimer.start(method(:updateMenuItems), delay, false);
|
||||
} else {
|
||||
updateMenuItems();
|
||||
}
|
||||
}
|
||||
var delay = Settings.getPollDelay();
|
||||
if (delay > 0) {
|
||||
mUpdateTimer.start(method(:updateMenuItems), delay, false);
|
||||
} else {
|
||||
updateMenuItems();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -816,7 +821,7 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
mGlanceTimer = null;
|
||||
fetchMenuConfig();
|
||||
fetchApiStatus();
|
||||
if (Settings.getWebhookId() != null && !Settings.getWebhookId().equals("")) {
|
||||
if (!Settings.getWebhookId().equals("") && !Settings.getClearWebhookId()) {
|
||||
fetchGlanceContent();
|
||||
}
|
||||
}
|
||||
|
@@ -141,7 +141,11 @@ class Settings {
|
||||
//! @return The API Key
|
||||
//
|
||||
static function getApiKey() as Lang.String {
|
||||
return mApiKey;
|
||||
if (mApiKey == null) {
|
||||
return "";
|
||||
} else {
|
||||
return mApiKey;
|
||||
}
|
||||
}
|
||||
|
||||
//! Get the Webhook ID supplied as part of the Settings.
|
||||
@@ -149,7 +153,11 @@ class Settings {
|
||||
//! @return The Webhook ID
|
||||
//
|
||||
static function getWebhookId() as Lang.String {
|
||||
return mWebhookId;
|
||||
if (mWebhookId == null) {
|
||||
return "";
|
||||
} else {
|
||||
return mWebhookId;
|
||||
}
|
||||
}
|
||||
|
||||
//! Set the Webhook ID supplied as part of the Settings.
|
||||
@@ -173,7 +181,11 @@ class Settings {
|
||||
//! @return The API URL
|
||||
//
|
||||
static function getApiUrl() as Lang.String {
|
||||
return mApiUrl;
|
||||
if (mApiUrl == null) {
|
||||
return "";
|
||||
} else {
|
||||
return mApiUrl;
|
||||
}
|
||||
}
|
||||
|
||||
//! Get the menu configuration URL supplied as part of the Settings.
|
||||
@@ -181,7 +193,11 @@ class Settings {
|
||||
//! @return The menu configuration URL
|
||||
//
|
||||
static function getConfigUrl() as Lang.String {
|
||||
return mConfigUrl;
|
||||
if (mConfigUrl == null) {
|
||||
return "";
|
||||
} else {
|
||||
return mConfigUrl;
|
||||
}
|
||||
}
|
||||
|
||||
//! Get the menu cache Boolean option supplied as part of the Settings.
|
||||
|
Reference in New Issue
Block a user