Skip to content

Add Sleep tracking#52

Open
MessyComposer wants to merge 3 commits intotahnok:mainfrom
MessyComposer:sleep
Open

Add Sleep tracking#52
MessyComposer wants to merge 3 commits intotahnok:mainfrom
MessyComposer:sleep

Conversation

@MessyComposer
Copy link
Copy Markdown

Add support for handling and storing sleep data from "Big Data" packets.
Resolves #20

Copy link
Copy Markdown
Owner

@tahnok tahnok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'm going to give this a spin on my ring, but overall it looks good and I appreciate the tests

SleepType type;
uint8_t minutes;
}
enum SleepType : uint8_t {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pull this into IntEnum like https://github.com/tahnok/colmi_r02_client/blob/firehose/colmi_r02_client/real_time.py#L16 ? I much prefer REM to 4 when looking through stuff

logger.warning("Invalid BigData sleep packet")
return None
data_len = int.from_bytes(packet[2:4], 'little')
crc16 = int.from_bytes(packet[4:6], 'little')
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works fine, no need to change, but have you seen struct ?


UART_SERVICE_V2_UUID = "DE5BF728-D711-4E47-AF26-65E3012A5DC7"
UART_RX_CHAR_V2_UUID = "DE5BF72A-D711-4E47-AF26-65E3012A5DC7"
UART_TX_CHAR_V2_UUID = "DE5BF729-D711-4E47-AF26-65E3012A5DC7"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna have to think about this, it's a bit more complex then I like

@tahnok
Copy link
Copy Markdown
Owner

tahnok commented Aug 27, 2025

Tested last night and it recorded some sleep!

tahnok pushed a commit that referenced this pull request Dec 25, 2025
Converts the SleepType enum from comment-based documentation to a
proper Python IntEnum for better code readability and type safety.

Changes:
- Add SleepType IntEnum with values: NODATA(0), ERROR(1), LIGHT(2),
  DEEP(3), REM(4), AWAKE(5)
- Update SleepPeriod.type field to use SleepType instead of int
- Update parse_bigdata_sleep_response to convert packet bytes to
  SleepType enum values
- Update all tests to use SleepType enum instead of magic numbers
- Update docstring to reference SleepType enum

This makes debugging easier as logs will show "REM" instead of "4",
improving code maintainability per PR #52 feedback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sleep tracking

2 participants