From c38f91f4560c318a1d32943fdd3092d7310de6d3 Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Mon, 19 Aug 2024 12:33:23 +0100 Subject: [PATCH] Fixed merge conflict Fixed a merge conflict made by more recent changes to fix a bug (https://github.com/house-of-abbey/GarminHomeAssistant/pull/164) --- HISTORY.md | 3 ++- source/Settings.mc | 40 ++++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 1e436f5..c0e798d 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -24,7 +24,8 @@ | 2.9 | Added an option to enable confirmation vibration so it can be turned off by request of a user. Removed a redundant setting for the alternative Widget version that was not removed previously, and fixed a bug with dereferencing Null. | | 2.10 | Added a user requested feature to slow down the rate of API calls in order to reduce battery wear for a situation where the application is kept open permanently on the device for convenience. Added 4 new devices. | | 2.11 | Bug fix release for menu caching being turned off and language corrections (Czech & Slovenian). | -| 2.12 | Re-enabled Edge 540 and Edge 840 devices which we are unable to support due to simulator issues, but the Edge 840 device has been confirmed as working by a @Petucky. | +| 2.12 | Re-enabled Edge 540 and Edge 840 devices which we are unable to support due to simulator issues, but the Edge 840 device has been confirmed as working by a [Petucky](https://github.com/Petucky). | | 2.13 | Moved the template status queries to Webhooks in order to fix the situation where an account is a non-privileged user. Added telemetry update on activity completion to make automations more timely at the end of an activity. When using a polling delay, there is no longer a startup delay for status updates and an action will trigger an immediate round of updates. | | 2.14 | Cautionary bug fix for the background service code where refactorisation spoilt some API level guard clauses. | | 2.15 | Better support for templates by isolating erroneous returns and marking the menu item. | +| 2.16 | Bug fix for lack of phone connection when starting the application. Includes new activity reporting features from [KPWhiver](https://github.com/KPWhiver) covering steps, heart rate, floors climbed and descended, and respiration rate. | diff --git a/source/Settings.mc b/source/Settings.mc index c579be3..c5c5f61 100644 --- a/source/Settings.mc +++ b/source/Settings.mc @@ -70,25 +70,29 @@ class Settings { // Manage this inside the application or widget only (not a glance or background service process) if (mIsApp) { if (mHasService) { - mWebhookManager = new WebhookManager(); - if (getWebhookId().equals("")) { - // System.println("Settings update(): Doing full webhook & sensor creation."); - mWebhookManager.requestWebhookId(); - } else { - // System.println("Settings update(): Doing just sensor creation."); - // We already have a Webhook ID, so just enable or disable the sensor in Home Assistant. - mWebhookManager.registerWebhookSensors(); - } - if (mIsSensorsLevelEnabled) { - // Create the timed activity - if ((Background.getTemporalEventRegisteredTime() == null) or - (Background.getTemporalEventRegisteredTime() != (mBatteryRefreshRate * 60))) { - Background.registerForTemporalEvent(new Time.Duration(mBatteryRefreshRate * 60)); // Convert to seconds - Background.registerForActivityCompletedEvent(); + if (System.getDeviceSettings().phoneConnected) { + mWebhookManager = new WebhookManager(); + if (getWebhookId().equals("")) { + // System.println("Settings update(): Doing full webhook & sensor creation."); + mWebhookManager.requestWebhookId(); + } else { + // System.println("Settings update(): Doing just sensor creation."); + // We already have a Webhook ID, so just enable or disable the sensor in Home Assistant. + mWebhookManager.registerWebhookSensors(); } - } else if (Background.getTemporalEventRegisteredTime() != null) { - Background.deleteTemporalEvent(); - Background.deleteActivityCompletedEvent(); + if (mIsSensorsLevelEnabled) { + // Create the timed activity + if ((Background.getTemporalEventRegisteredTime() == null) or + (Background.getTemporalEventRegisteredTime() != (mBatteryRefreshRate * 60))) { + Background.registerForTemporalEvent(new Time.Duration(mBatteryRefreshRate * 60)); // Convert to seconds + Background.registerForActivityCompletedEvent(); + } + } else if (Background.getTemporalEventRegisteredTime() != null) { + Background.deleteTemporalEvent(); + Background.deleteActivityCompletedEvent(); + } + } else { + ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoPhone) as Lang.String); } } else { // Explicitly disable the background event which persists when the application closes.