New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: sleeplog: Expose more statistics #1517
Comments
This shouldn't be a big deal. For the first two values I can simply add
To determine the other three values it is necessary to do little calculations over the logged data. I assume you want to use this data on a watch face and therefore it could be the best approach to add these values as properties of sleeplog, too. There are a few ways at wich point to calculate the values:
My preferred way would be the second one: On every new log entry. It's easy to implement and the fact that the logfile needs to be loaded already makes it less power consuming. The more tricky question is how the last three values should be calculated. The total values are heavily depending on the used time span. I would suggest to use the same preferences as used for the app, wich would result in the following values for your requested values:
Or do you want to have the sum of all logged awake / sleeping periods? I'm actually working on a more detailed sleep detection with a light and deep sleep phase and some code improvements. Therefore I need to make a lot of changes to the code and it will be no problem to implement these ideas. Thanks for your suggestions, those are some great ideas. |
Thanks for answering.
Fine for me. I guess it would be the best if the values via the "API" match the ones being shown in the app.
if you could integrate some parts of this would be great :) |
@myxor I hope you don't mind my piggybacking here, but I am excited to hear that @storm64 is working on the detailed sleep detection; it's something I was hoping for. I can open a separate issue if that would be better. @storm64, while you're working on that do you think you could add a debug option to log more details, rather than just the state changes? I was thinking that could be helpful for when a user is trying to dial in their personal thresholds for more accurate classification of the states. I found that I had to connect to my watch with the IDE and dump the |
@GrandVizierOlaf sure that is fine. @storm64 i am really looking forward to your rework of the sleeplog app. |
I'm happy to here that you are having fun with the app. @GrandVizierOlaf: I stepped on the same problem while trying to figure out why no sleeping is recognized on @juanjgit's watch. To tell you more about what I am working on, here a list of the major changes:
At last I want to share a thought related to the future of ESS mode: For comparison I installed the sleeplog app twice, each app using one mode (ESS/PSM). (I installed the second instance by replacing "sleeplog" with "sleeptest".) |
@storm64 that all sounds fantastic. Let me know if you need any help testing it. When you mention "the last day" with regards to Reading through it again reminds me of an issue I ran into yesterday and a potential solution; the ambient temperature was 81°F (27 C) and my watch was unplugged and charging, but was detected as worn. I bumped the temperature threshold, but it gets above body temperature here in the summer and I worry that it will mess with the detection then. One potential shortcut is to check if the watch is charging and, if it is, know that it is not worn. You could also check the HRM stats every so often and see if that gives more accurate worn/not worn than the temperature. |
Yes indeed it looks like this could be enough to toggle the quiet mode! |
I would stay with the same day periods as in the app. The duration is fixed to 24 hours. Start and end time is set by the "Break ToD" value in settings. As a result "the last day" is the period from second last to last time of day equal to "Break ToD". @GrandVizierOlaf, I was unsatisfied with the "not wearing" check from the beginning. Checking for the charging status is a good idea and for checking the status if not charging I might have found a solution with minimal HRM up time:
|
@storm64 any news on the sleeplog rework? :) |
I'm on 80% for "public" testing. For now the last part to rewrite is the app.js for displaying the logged data. |
I am proud to present the new sleeplog app: version 0.10 🎉 ✨ 🎊 Sorry that it took so long but hopefully most of the early bugs are sorted out and the app should be ready to be use and get tested! I would love to hear about your impressions and like to know your choice of thresholds, to set the default values as optimized as possible. The last piece of work is to rewrite the README.md to show how to use it and show the restrictions and possibilities.
|
Thank you @storm64, i will try it out the next days (nights). |
The solutions with the new app:
For now I forgot about this but would like to implement it.
Have you tried if And how should it be triggered:
In my opinion I would prefer a option in the settings (showing if qmsched is installed) like
|
@gfwilliams I'm working on sending the sleep state to gadgetbridge and found the following two java files that might be interesting for this: .../model/ActivityKind.java defining the different kinds of activities.
and .../service/devices/banglejs/BangleJSDeviceSupport.java handling the communication with Bangle.js. 372 case "act": {
373 BangleJSActivitySample sample = new BangleJSActivitySample();
- 374 sample.setTimestamp((int) (GregorianCalendar.getInstance().getTimeInMillis() / 1000L));
+ int ts = GregorianCalendar.getInstance().getTimeInMillis() / 1000L;
375 int hrm = 0;
376 int steps = 0;
+ int activity = BangleJSSampleProvider.TYPE_NOT_MEASURED;
+ if (json.has("ts")) ts = json.getLong("ts") / 1000L;
377 if (json.has("hrm")) hrm = json.getInt("hrm");
378 if (json.has("stp")) steps = json.getInt("stp");
- 379 int activity = BangleJSSampleProvider.TYPE_ACTIVITY;
- 380 /*if (json.has("act")) {
+ if (json.has("act")) {
381 String actName = "TYPE_" + json.getString("act").toUpperCase();
382 try {
383 Field f = ActivityKind.class.getField(actName);
384 try {
385 activity = f.getInt(null);
386 } catch (IllegalAccessException e) {
387 LOG.info("JSON activity '"+actName+"' not readable");
388 }
389 } catch (NoSuchFieldException e) {
390 LOG.info("JSON activity '"+actName+"' not found");
391 }
- 392 }*/
+ }
+ sample.setTimestamp(ts);
- 393 sample.setRawKind(activity);
394 sample.setHeartRate(hrm);
395 sample.setSteps(steps);
+ sample.setRawKind(activity);
396 try (DBHandler dbHandler = GBApplication.acquireDB()) {
397 Long userId = getUser(dbHandler.getDaoSession()).getId();
398 Long deviceId = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession()).getId();
399 BangleJSSampleProvider provider = new BangleJSSampleProvider(getDevice(), dbHandler.getDaoSession());
400 sample.setDeviceId(deviceId);
401 sample.setUserId(userId);
402 provider.addGBActivitySample(sample);
403 } catch (Exception ex) {
404 LOG.warn("Error saving activity: " + ex.getLocalizedMessage());
405 }
406 // push realtime data
407 if (realtimeHRM || realtimeStep) {
408 Intent intent = new Intent(DeviceService.ACTION_REALTIME_SAMPLES)
409 .putExtra(DeviceService.EXTRA_REALTIME_SAMPLE, sample);
410 LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
411 }
412 } break; The according code snippet to trigger a status change inside sleeplog would be as following:
I am not sure if this works as easy es I might think/hope, especially the behavior from gadgetbridge receiving two separate actions (one with steps+hrm and one with the activity), but this could be altered within Bangle itself if neccessary. I would really like to here your thoughts and am excited to take the sleeplog app a step further. |
Yes, this looks promising - and the code is already there, just disabled? However is the timestamp thing really required? Can't we just send the update when the activity type actually changes? |
Due to the fact that i need to evaluate the movement collected over the last 10 minutes, a status change had occurred 10 minutes ago. This is taken into account in the sleeplog app and to use the same base of data, I would recommend to hand over the corrected timestamp. |
Ok, thanks. I guess it also has the benefit that maybe the Bangle can 'catch up' if it's been disconnected from Gadgetbridge for a while |
@storm64 just wanted to let you know that i saw this exception happening today a few times:
|
Sry, that this took me so long, but the module not found error should be fixed with the new beta04. |
[sleeplog] New version as mentioned in #1517
Hi @myxor, just wanted to remind you of my question:
Have you tried if And how should it be triggered:
In my opinion I would prefer a option in the settings (showing if qmsched is installed) like
|
This sounds to me as the best approach as well.
I did not yet try it but from my view on the qmsched code this looks correct. |
I think we can close this issue now, if there's nothing else outstanding? |
Looks good - we can always reopen if there is something specific |
I would like to collect a list of possible further statistics data which the sleeplog app could deliver in future:
This could be done via the already existing
global.sleeplog
object.Pinging @storm64 as creator of sleeplog.
Open for discussion and ideas.
The text was updated successfully, but these errors were encountered: