Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
bd077aa
Add sleep summary logging and notification functions
RKBoss6 Sep 15, 2025
5c10d3f
Create module.js
RKBoss6 Sep 15, 2025
4d331f5
Implement sleep summary display with custom layout
RKBoss6 Sep 15, 2025
a183ad2
Add metadata.json for Sleep Summary app
RKBoss6 Sep 15, 2025
52ba8df
Add files via upload
RKBoss6 Sep 15, 2025
62f32e0
Update metadata.json
RKBoss6 Sep 15, 2025
133cedd
Add README for sleepsummary module
RKBoss6 Sep 15, 2025
274ec8b
Add settings management for Sleep Summary app
RKBoss6 Sep 15, 2025
91111db
Add author field to metadata.json
RKBoss6 Sep 15, 2025
b8fc56f
Format README settings section with bold text
RKBoss6 Sep 15, 2025
a05a70c
Merge branch 'espruino:master' into Sleep-Summary
RKBoss6 Sep 15, 2025
d915f16
Add timeSinceAwake setting to sleep summary
RKBoss6 Sep 15, 2025
e9b659f
Add files via upload
RKBoss6 Sep 16, 2025
e3fea03
Add app icon entry to metadata.json
RKBoss6 Sep 16, 2025
9cce58e
Add appicon.js for sleep summary app
RKBoss6 Sep 16, 2025
3215939
Fix formatting in metadata.json
RKBoss6 Sep 16, 2025
7a1e0f0
Implement time conversion functions in app.js
RKBoss6 Sep 16, 2025
3c17a70
Refactor getMsPastMidnight and update sleep calculations
RKBoss6 Sep 16, 2025
2d5543a
Add condition to check awakeSince is not zero
RKBoss6 Sep 16, 2025
d115a2e
Revise ideal deep sleep and sleep time thresholds
RKBoss6 Sep 16, 2025
f818d22
Refactor UI setup for sleep summary app
RKBoss6 Sep 16, 2025
6bb869a
Add dependencies and provides_modules to metadata
RKBoss6 Sep 16, 2025
4ddf56a
Merge branch 'espruino:master' into Sleep-Summary
RKBoss6 Sep 17, 2025
beb5279
Merge branch 'espruino:master' into Sleep-Summary
RKBoss6 Sep 25, 2025
4b51a92
Merge branch 'espruino:master' into Sleep-Summary
RKBoss6 Oct 9, 2025
bcd5f02
Update settings.js
RKBoss6 Oct 9, 2025
427a194
Refactor sleep summary logging and awake checks
RKBoss6 Oct 9, 2025
655e175
Refactor sleep summary module for settings and scores
RKBoss6 Oct 9, 2025
951f60b
Merge branch 'espruino:master' into Sleep-Summary
RKBoss6 Nov 11, 2025
2beb5c2
Refactor sleep data handling and caching
RKBoss6 Nov 11, 2025
1ac451c
Refactor boot.js for improved readability and structure
RKBoss6 Nov 11, 2025
3c1c8af
Refactor draw function to use new summary data
RKBoss6 Nov 11, 2025
be6a712
Add getSleepData export and update cached wake time
RKBoss6 Nov 11, 2025
9e19e44
Create ChangeLog
RKBoss6 Nov 11, 2025
418e57c
Add nicer-looking progress bar and dynamic colors
RKBoss6 Nov 12, 2025
73b006e
Refactor showSummary function and remove formatTime
RKBoss6 Nov 12, 2025
b40f94c
Implement sleep summary message display
RKBoss6 Nov 12, 2025
1800614
Add sleepsummarydatacache.json to metadata
RKBoss6 Nov 12, 2025
44c5f37
Fix variable name for wakeUpTime in message logic
RKBoss6 Nov 12, 2025
476fedd
Rename wkUpTime to wakeUpTime in cached data
RKBoss6 Nov 12, 2025
d20130e
Fix color codes and update wakeup time label
RKBoss6 Nov 12, 2025
bf9c751
Update module.js
RKBoss6 Nov 12, 2025
88f2cec
Remove call to showSummary function
RKBoss6 Nov 12, 2025
c35dbcc
Update module.js
RKBoss6 Nov 12, 2025
151a1ab
Fix missing newline at end of boot.js
RKBoss6 Nov 12, 2025
49ab46e
Merge branch 'espruino:master' into Sleep-Summary
RKBoss6 Nov 17, 2025
55dd2a1
Fix date retrieval in checkIfAwake function
RKBoss6 Nov 24, 2025
b1c71ba
Refactor sleep summary module for better data handling
RKBoss6 Nov 24, 2025
a49b344
Add different pages and a summary text
RKBoss6 Nov 24, 2025
1053ac5
Fix missing newline at end of module.js
RKBoss6 Nov 24, 2025
d598f8d
Fix syntax errors in boot.js
RKBoss6 Nov 24, 2025
4a073b8
Update README with app details and features
RKBoss6 Nov 24, 2025
4ee3660
Merge branch 'espruino:master' into Sleep-Summary
RKBoss6 Feb 12, 2026
def2d97
rework show message for better accuracy, add new settings for it, cle…
RKBoss6 Apr 27, 2026
667930b
Message now works, revamped UI, changed app for ease of use, fixed lo…
RKBoss6 May 4, 2026
c9c2948
added screenshot for wakeup message
RKBoss6 May 4, 2026
fd3fa92
try to fix lint issues
RKBoss6 May 4, 2026
eb962a4
add getSleepScores
RKBoss6 May 5, 2026
595897e
Merge branch 'espruino:master' into Sleep-Summary
RKBoss6 May 6, 2026
bd66cdd
Added clockinfo, new icon, bug fixes, organized settings menus
RKBoss6 May 8, 2026
389c9a2
Update README.md
RKBoss6 May 8, 2026
202804a
fixed more bugs and tweaked icon slightly
RKBoss6 May 8, 2026
b99cf1a
fixed metadata tag error, cleared up readme
RKBoss6 May 9, 2026
310d7df
remove cached data as well in deletedata
RKBoss6 May 9, 2026
c028134
update readme with up-to-date features, and clockinfo docs
RKBoss6 May 9, 2026
a00373f
fix undefined vars
RKBoss6 May 9, 2026
2397a27
fix some bugs, run everything through a formatter
RKBoss6 May 9, 2026
8e1d119
fix file ending errors
RKBoss6 May 9, 2026
731b58d
added a setting for logging
RKBoss6 May 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/sleepsummary/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.01: New app!
88 changes: 88 additions & 0 deletions apps/sleepsummary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Sleep Summary
Provides the module `sleepsummary`, which collects sleep data from `Sleep Log`, and generates a sleep score for you each day, based on average wakeup times, duration and more. The scores will generally trend higher in the first week that you use the module, however, the most accurate scores come the longer you use the module.

The module also comes with an app to see detailed statistics of your sleep compared to your averages prior, and a clock info for quick access to your score.

All data is stored only on your device.

Note: For the best experience, it is highly recommended to ensure your sleep from `sleeplog` is accurate. If not, follow the tuning guides in the sleeplog readme to ensure you have accurate data, and thus an accurate and well-timed sleep score and message.

## App
This module provides an app where you can see in-depth details about your sleep. There are two pages:
1. Sleep score and description
2. Detailed stats about all scores, and time asleep and wakeup time.

Swipe left or right to navigate between the two pages.

## Clock Info
This module also provides a clock info for access to your score on the clock face. The clockInfo will show your score of the day, and at midnight, will show `--/100` until a new sleep score comes in when you wake up. When the sleep score for the day is ready, a notification-style bubble will show in the clockinfo image, alerting you that a new score is ready.

## Formula

The module takes in the following data points:
- How long you slept compared to your usual sleep time
- Sleep duration compared to ideal duration set in settings
- Deep sleep length compared to ideal deep sleep set in settings
- When you woke up compared to your usual wake up time

The module then averages those individual scores with weights added to get a score out of 100.

## Settings
- <b>Use True Sleep</b> - Whether or not to use True Sleep from sleeplog (deep + light sleep combined). If not checked, uses consecutive sleep instead
- <b>Show Message</b> - Whether or not to show a good morning message / prompt when you wake up (this may not be exactly when you wake up, depending on how accurate your settings for Sleeplog are)
- <b>Ideal Deep Sleep</b> - How much deep sleep per night should qualify as a deep sleep score of 95 (more than this gives you 100)
- <b>Ideal Sleep Time</b> - How much sleep per night should qualify as a sleep duration score of 95 (more than this gives you 100)
- <b>Logging Enabled</b> - Whether or not to log triggers from sleeplog and the relavant state changes from boot.js.
- <b>Min Consec Sleep</b> - The minimum consecutive sleep (in minutes) required before the module considers you to have properly woken up
- <b>Message Delay</b> - How long after waking the module waits to confirm you are actually awake before showing the prompt.

## Development
To use the module, do `require("sleepsummary")` followed by any function from the list below.

- `require("sleepsummary").recordData();` - Records current sleep data into the rolling averages, then recalculates and caches today's scores. It is best to only do this once a day, and is already automatically handled by the module.

- `require("sleepsummary").getSummaryData();` - Returns the following:
- `avgSleepTime` - The average time you sleep for, in **minutes**
- `totalCycles` - How many sleep cycles to date the module has tracked
- `avgWakeUpTime` - The average time you wake up, in **ms past midnight**
- `dateLastRecorded` - A datetime string of when the module last recorded sleep information (`YYYY-MM-DD HH:MM:SS`)
- `scoreLastUpdated` - A date string (`YYYY-MM-DD`) of the last day a score was calculated and shown
- `wakeUpTime` - Today's wake-up time, in **ms past midnight**
- `overallSleepScore` - Today's cached overall sleep score (0–100)
- `deepSleepScore` - Today's cached deep sleep score (0–100)
- `wkUpSleepScore` - Today's cached wake-up consistency score (0–100)
- `durationSleepScore` - Today's cached sleep duration score (0–100)
- `consecSleep` - Today's consecutive sleep, in **minutes**
- `trueSleep` - Today's true sleep (deep + light), in **minutes**
- `sleepDuration` - Today's sleep duration in **minutes**, using either true sleep or consecutive sleep depending on the Use True Sleep setting

**Note:** *If needed, pass `true` to force a recalculation before getting the data: `require("sleepsummary").getSummaryData(true);`*

- `require("sleepsummary").getSleepData();` - Returns the following about this night's sleep (most data comes directly from `require("sleeplog").getStats(Date.now(), 24*60*60*1000)`):
- `calculatedAt` - When the data was calculated
- `deepSleep` - Time spent in deep sleep, in **minutes**
- `lightSleep` - Time spent in light sleep, in **minutes**
- `awakeSleep` - Time spent awake during sleep periods, in **minutes**
- `consecSleep` - Consecutive sleep duration, in **minutes**
- `trueSleep` - True sleep (deep + light), in **minutes**
- `totalSleep` - Total sleep in **minutes**, using consecutive or true sleep depending on the Use True Sleep setting
- `awakeTime` - Time spent awake
- `notWornTime` - Time the watch was detected as not worn
- `unknownTime` - Time spent in an unknown state
- `logDuration` - Total time spent logging
- `firstDate` - Unix timestamp of the first log entry in the stats
- `lastDate` - Unix timestamp of the last log entry in the stats
- `awakeSince` - Wake-up time in **ms past midnight**

- `require("sleepsummary").getSleepScores();` - Returns the following sleep scores for today:
- `durationScore` - Sleep duration compared to ideal duration set in settings
- `deepSleepScore` - Deep sleep length compared to ideal deep sleep set in settings
- `avgWakeUpScore` - Wake-up time compared to your average (0 if no average recorded yet)
- `avgSleepTimeScore` - Sleep duration compared to your average (0 if no average recorded yet)
- `overallScore` - The overall sleep score, calculated as a weighted average of all the other scores

- `require("sleepsummary").deleteData();` - Deletes all learned averages and cached scores. The module will automatically relearn the next time `recordData()` is called.


## Creator
RKBoss6
Loading
Loading