mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-05-01 13:12:50 +00:00
Bug fix for activity reporting (#167)
Added 'has' clauses around additional ActivityMonitor.Info fields that are not present on all devices. I have also checked the other reporting fields to ensure they are not device dependent.
This commit is contained in:
@ -29,3 +29,4 @@
|
||||
| 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. |
|
||||
| 2.17 | Bug fix for reporting activity metrics that are not found on some devices. |
|
||||
|
@ -150,20 +150,26 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
|
||||
"type" => "sensor",
|
||||
"unique_id" => "heart_rate",
|
||||
"icon" => "mdi:heart-pulse"
|
||||
},
|
||||
{
|
||||
}
|
||||
];
|
||||
|
||||
if (ActivityMonitor.Info has :floorsClimbed) {
|
||||
data.add({
|
||||
"state" => activityInfo.floorsClimbed == null ? "unknown" : activityInfo.floorsClimbed,
|
||||
"type" => "sensor",
|
||||
"unique_id" => "floors_climbed_today",
|
||||
"icon" => "mdi:stairs-up"
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
|
||||
if (ActivityMonitor.Info has :floorsDescended) {
|
||||
data.add({
|
||||
"state" => activityInfo.floorsDescended == null ? "unknown" : activityInfo.floorsDescended,
|
||||
"type" => "sensor",
|
||||
"unique_id" => "floors_descended_today",
|
||||
"icon" => "mdi:stairs-down"
|
||||
});
|
||||
}
|
||||
];
|
||||
|
||||
if (ActivityMonitor.Info has :respirationRate) {
|
||||
data.add({
|
||||
|
@ -251,8 +251,11 @@ class WebhookManager {
|
||||
"unit_of_measurement" => "bpm",
|
||||
"state_class" => "measurement",
|
||||
"disabled" => !Settings.isSensorsLevelEnabled()
|
||||
},
|
||||
{
|
||||
}
|
||||
];
|
||||
|
||||
if (ActivityMonitor.Info has :floorsClimbed) {
|
||||
sensors.add({
|
||||
"name" => "Floors climbed today",
|
||||
"state" => activityInfo.floorsClimbed == null ? "unknown" : activityInfo.floorsClimbed,
|
||||
"type" => "sensor",
|
||||
@ -260,8 +263,11 @@ class WebhookManager {
|
||||
"icon" => "mdi:stairs-up",
|
||||
"state_class" => "total",
|
||||
"disabled" => !Settings.isSensorsLevelEnabled()
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
|
||||
if (ActivityMonitor.Info has :floorsDescended) {
|
||||
sensors.add({
|
||||
"name" => "Floors descended today",
|
||||
"state" => activityInfo.floorsDescended == null ? "unknown" : activityInfo.floorsDescended,
|
||||
"type" => "sensor",
|
||||
@ -269,9 +275,8 @@ class WebhookManager {
|
||||
"icon" => "mdi:stairs-down",
|
||||
"state_class" => "total",
|
||||
"disabled" => !Settings.isSensorsLevelEnabled()
|
||||
});
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
if (ActivityMonitor.Info has :respirationRate) {
|
||||
sensors.add({
|
||||
@ -289,6 +294,7 @@ class WebhookManager {
|
||||
if (Activity has :getProfileInfo) {
|
||||
var activity = Activity.getProfileInfo().sport;
|
||||
var sub_activity = Activity.getProfileInfo().subSport;
|
||||
|
||||
if ((Activity.getActivityInfo() != null) and
|
||||
((Activity.getActivityInfo().elapsedTime == null) or
|
||||
(Activity.getActivityInfo().elapsedTime == 0))) {
|
||||
|
Reference in New Issue
Block a user