From 45b9f14f7be50f89239fac4657049bb7b6bccb0d Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 26 Mar 2025 09:38:09 +0000 Subject: [PATCH] sleeplog 0.19: Write sleep state into health event's .activity field --- apps/sleeplog/ChangeLog | 1 + apps/sleeplog/boot.js | 5 ++++- apps/sleeplog/metadata.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/sleeplog/ChangeLog b/apps/sleeplog/ChangeLog index de0ce30cd..9c83460ce 100644 --- a/apps/sleeplog/ChangeLog +++ b/apps/sleeplog/ChangeLog @@ -14,3 +14,4 @@ 0.16: Only write logs if we have a non-empty log to write 0.17: Minor code improvements 0.18: Add back as a function to prevent translation making it a menu entry +0.19: Write sleep state into health event's .activity field diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index d74db7357..b67907f76 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -25,7 +25,7 @@ if (global.sleeplog.conf.enabled) { start: function() { // add kill and health listener E.on('kill', global.sleeplog.saveStatus); - Bangle.on('health', global.sleeplog.health); + Bangle.prependListener('health', global.sleeplog.health); // restore saved status this.restoreStatus(); @@ -176,6 +176,9 @@ if (global.sleeplog.conf.enabled) { // set status global.sleeplog.setStatus(data); } + // update activity in the 'health' event for when it's logged/sent to Gadgetbridge + if (data.status==3) data.activity="LIGHT_SLEEP"; + if (data.status==4) data.activity="DEEP_SLEEP"; }, // check wearing status either based on HRM or temperature as set in settings diff --git a/apps/sleeplog/metadata.json b/apps/sleeplog/metadata.json index 455900694..ff3d5a18f 100644 --- a/apps/sleeplog/metadata.json +++ b/apps/sleeplog/metadata.json @@ -2,7 +2,7 @@ "id":"sleeplog", "name":"Sleep Log", "shortName": "SleepLog", - "version": "0.18", + "version": "0.19", "description": "Log and view your sleeping habits. This app is using the built in movement calculation.", "icon": "app.png", "type": "app",