Largely cosmetic

Removed debug that escaped.
Belt & braces field to prevent the update chain being started twice.
This commit is contained in:
Philip Abbey
2024-07-26 18:23:22 +01:00
parent 9eed5affdc
commit a213c6851e
3 changed files with 14 additions and 14 deletions

View File

@ -39,6 +39,7 @@ class HomeAssistantApp extends Application.AppBase {
private var mIsGlance as Lang.Boolean = false; private var mIsGlance as Lang.Boolean = false;
private var mIsApp as Lang.Boolean = false; // Or Widget private var mIsApp as Lang.Boolean = false; // Or Widget
private var mIsInitUpdateCompl as Lang.Boolean = false; private var mIsInitUpdateCompl as Lang.Boolean = false;
private var mUpdating as Lang.Boolean = false; // Don't start a second chain of updates
function initialize() { function initialize() {
AppBase.initialize(); AppBase.initialize();
@ -262,11 +263,12 @@ class HomeAssistantApp extends Application.AppBase {
} }
function startUpdates() { function startUpdates() {
if (mHaMenu != null) { if (mHaMenu != null and !mUpdating) {
mItemsToUpdate = mHaMenu.getItemsToUpdate(); mItemsToUpdate = mHaMenu.getItemsToUpdate();
// Start the continuous update process that continues for as long as the application is running. // Start the continuous update process that continues for as long as the application is running.
// The chain of functions from 'updateNextMenuItem()' calls 'updateNextMenuItem()' on completion. // The chain of functions from 'updateNextMenuItem()' calls 'updateNextMenuItem()' on completion.
if (mItemsToUpdate.size() > 0) { if (mItemsToUpdate.size() > 0) {
mUpdating = true;
updateNextMenuItemInternal(); updateNextMenuItemInternal();
} }
} }

View File

@ -137,7 +137,7 @@ class HomeAssistantTemplateMenuItem extends WatchUi.IconMenuItem {
} else if(label instanceof Lang.String) { } else if(label instanceof Lang.String) {
setSubLabel(label); setSubLabel(label);
} else if(label instanceof Lang.Dictionary) { } else if(label instanceof Lang.Dictionary) {
System.println("HomeAssistantTemplateMenuItem onReturnGetState() label = " + label); // System.println("HomeAssistantTemplateMenuItem onReturnGetState() label = " + label);
if (label.get("error") != null) { if (label.get("error") != null) {
setSubLabel($.Rez.Strings.TemplateError); setSubLabel($.Rez.Strings.TemplateError);
} else { } else {
@ -165,8 +165,6 @@ class HomeAssistantTemplateMenuItem extends WatchUi.IconMenuItem {
// System.println("HomeAssistantTemplateMenuItem getState(): No Internet connection, skipping API call."); // System.println("HomeAssistantTemplateMenuItem getState(): No Internet connection, skipping API call.");
ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoInternet) as Lang.String + "."); ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoInternet) as Lang.String + ".");
getApp().setApiStatus(WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String); getApp().setApiStatus(WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String);
} else if (Settings.getWebhookId().equals("")) {
getApp().updateNextMenuItem();
} else { } else {
// https://developers.home-assistant.io/docs/api/native-app-integration/sending-data/#render-templates // https://developers.home-assistant.io/docs/api/native-app-integration/sending-data/#render-templates
var url = Settings.getApiUrl() + "/webhook/" + Settings.getWebhookId(); var url = Settings.getApiUrl() + "/webhook/" + Settings.getWebhookId();