Report -1 instead of null for no activity

This commit is contained in:
Joseph Abbey
2024-01-28 13:05:34 +00:00
parent 9f759b1dad
commit 6fc639f17f
2 changed files with 8 additions and 4 deletions

View File

@ -103,13 +103,15 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
}
];
if (Activity has :getProfileInfo) {
var activity = Activity.getProfileInfo().sport;
var sub_activity = Activity.getProfileInfo().subSport;
data.add({
"state" => Activity.getProfileInfo().sport,
"state" => activity ? activity : -1,
"type" => "sensor",
"unique_id" => "activity"
});
data.add({
"state" => Activity.getProfileInfo().subSport,
"state" => sub_activity ? sub_activity : -1,
"type" => "sensor",
"unique_id" => "sub_activity"
});

View File

@ -183,9 +183,10 @@ class WebhookManager {
case 1:
// System.println("WebhookManager onReturnRegisterWebhookSensor(): Registering next sensor: Activity");
if (Activity has :getProfileInfo) {
var activity = Activity.getProfileInfo().sport;
registerWebhookSensor({
"name" => "Activity",
"state" => Activity.getProfileInfo().sport,
"state" => activity ? activity : -1,
"type" => "sensor",
"unique_id" => "activity",
"disabled" => false
@ -195,9 +196,10 @@ class WebhookManager {
case 2:
// System.println("WebhookManager onReturnRegisterWebhookSensor(): Registering next sensor: Activity");
if (Activity has :getProfileInfo) {
var sub_activity = Activity.getProfileInfo().subSport;
registerWebhookSensor({
"name" => "Sub-activity",
"state" => Activity.getProfileInfo().subSport,
"state" => sub_activity ? sub_activity : -1,
"type" => "sensor",
"unique_id" => "sub_activity",
"disabled" => false