mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-16 19:38:34 +00:00
163 application crashes when started out of bluetooth range (#164)
Test the phone is connected before attempting WebHook HTTP requests.
This commit is contained in:
@ -28,3 +28,4 @@
|
|||||||
| 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.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.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.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. |
|
||||||
|
@ -70,36 +70,40 @@ class Settings {
|
|||||||
// Manage this inside the application or widget only (not a glance or background service process)
|
// Manage this inside the application or widget only (not a glance or background service process)
|
||||||
if (mIsApp) {
|
if (mIsApp) {
|
||||||
if (mHasService) {
|
if (mHasService) {
|
||||||
mWebhookManager = new WebhookManager();
|
if (System.getDeviceSettings().phoneConnected) {
|
||||||
if (getWebhookId().equals("")) {
|
mWebhookManager = new WebhookManager();
|
||||||
// System.println("Settings update(): Doing full webhook & sensor creation.");
|
if (getWebhookId().equals("")) {
|
||||||
mWebhookManager.requestWebhookId();
|
// System.println("Settings update(): Doing full webhook & sensor creation.");
|
||||||
} else {
|
mWebhookManager.requestWebhookId();
|
||||||
// System.println("Settings update(): Doing just sensor creation.");
|
} else {
|
||||||
// We already have a Webhook ID, so just enable or disable the sensor in Home Assistant.
|
// System.println("Settings update(): Doing just sensor creation.");
|
||||||
// Its a multiple step process, hence starting at step 0.
|
// We already have a Webhook ID, so just enable or disable the sensor in Home Assistant.
|
||||||
mWebhookManager.registerWebhookSensor({
|
// Its a multiple step process, hence starting at step 0.
|
||||||
"device_class" => "battery",
|
mWebhookManager.registerWebhookSensor({
|
||||||
"name" => "Battery Level",
|
"device_class" => "battery",
|
||||||
"state" => System.getSystemStats().battery,
|
"name" => "Battery Level",
|
||||||
"type" => "sensor",
|
"state" => System.getSystemStats().battery,
|
||||||
"unique_id" => "battery_level",
|
"type" => "sensor",
|
||||||
"unit_of_measurement" => "%",
|
"unique_id" => "battery_level",
|
||||||
"state_class" => "measurement",
|
"unit_of_measurement" => "%",
|
||||||
"entity_category" => "diagnostic",
|
"state_class" => "measurement",
|
||||||
"disabled" => !Settings.isSensorsLevelEnabled()
|
"entity_category" => "diagnostic",
|
||||||
}, 0);
|
"disabled" => !Settings.isSensorsLevelEnabled()
|
||||||
}
|
}, 0);
|
||||||
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) {
|
if (mIsSensorsLevelEnabled) {
|
||||||
Background.deleteTemporalEvent();
|
// Create the timed activity
|
||||||
Background.deleteActivityCompletedEvent();
|
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 {
|
} else {
|
||||||
// Explicitly disable the background event which persists when the application closes.
|
// Explicitly disable the background event which persists when the application closes.
|
||||||
|
Reference in New Issue
Block a user