mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-17 11:58:30 +00:00
Update BackgroundServiceDelegate.mc
Amended detection of no activity reporting.
This commit is contained in:
@ -102,16 +102,24 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
|
|||||||
"unique_id" => "battery_is_charging"
|
"unique_id" => "battery_is_charging"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
if (Activity has :getProfileInfo) {
|
if ((Activity has :getActivityInfo) and (Activity has :getProfileInfo)) {
|
||||||
var activity = Activity.getProfileInfo().sport;
|
var activity = Activity.getProfileInfo().sport;
|
||||||
var sub_activity = Activity.getProfileInfo().subSport;
|
var sub_activity = Activity.getProfileInfo().subSport;
|
||||||
|
// We need to check if we are actually tracking any activity
|
||||||
|
if (Activity.getActivityInfo().elapsedTime == 0) {
|
||||||
|
// Indicate no activity with -1, not part of Garmin's activity codes.
|
||||||
|
// https://developer.garmin.com/connect-iq/api-docs/Toybox/Activity.html#Sport-module
|
||||||
|
activity = -1;
|
||||||
|
sub_activity = -1;
|
||||||
|
}
|
||||||
|
System.println("activity = " + activity);
|
||||||
data.add({
|
data.add({
|
||||||
"state" => activity != null ? activity : -1,
|
"state" => activity,
|
||||||
"type" => "sensor",
|
"type" => "sensor",
|
||||||
"unique_id" => "activity"
|
"unique_id" => "activity"
|
||||||
});
|
});
|
||||||
data.add({
|
data.add({
|
||||||
"state" => sub_activity != null ? sub_activity : -1,
|
"state" => sub_activity,
|
||||||
"type" => "sensor",
|
"type" => "sensor",
|
||||||
"unique_id" => "sub_activity"
|
"unique_id" => "sub_activity"
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user