Skip to content

Fix Core Room Size encoding and decoded value round-trip#46

Open
EdenNelson wants to merge 1 commit into
tuct:mainfrom
EdenNelson:fix/core-room-size-round-trip
Open

Fix Core Room Size encoding and decoded value round-trip#46
EdenNelson wants to merge 1 commit into
tuct:mainfrom
EdenNelson:fix/core-room-size-round-trip

Conversation

@EdenNelson

Copy link
Copy Markdown
Contributor

Fix Core-series Room Size encode/decode round-tripping so decoded status values publish the intended room-size value instead of truncating down at range edges.

Fixes #45

Summary

  • Add shared Core room-size helpers for the 10.764 * 3.15 factor.
  • Encode Core Room Size raw values with round(m² * 10.764 * 3.15).
  • Decode Core Room Size status values with the same factor and round before publishing.
  • Preserve float values in publish_number(...) instead of narrowing decoded number state to uint32_t.
  • Document Core status rounding in LEVOIT_UART.md.

Validation

  • git diff --check passed.
  • Editor diagnostics reported no errors in the changed source/header files.
  • Sample math checks passed:
    • 9 m² -> raw=305 -> low=0x31 high=0x01 -> decoded=9
    • 38 m² -> raw=1288 -> low=0x08 high=0x05 -> decoded=38
  • ESPHome Core400S local compile passed.
  • Core400S live testing was performed from EdenNelson/levoit@integration/core400s-auto-profile-stack:
    • 38 m² published as 38.00, sent raw 1288 (0x08 0x05), and MCU status echoed 0x08 0x05 without the previous 37.00 bounce.
    • 9 m² status echo showed raw 305 (0x31 0x01), which now decodes to 9 with the rounded Core status path; the previous bad behavior was 8.00.

Scope

This PR only changes Core room-size encoding/decoding and the numeric publish path needed to avoid truncating decoded number values. It does not add remembered Room Size persistence, fan mode mechanics, diagnostics, raw sensors, or unrelated model changes.

Disclosure

This PR was prepared with GitHub Copilot/AI assistance and human-in-the-loop review. Live payload/status validation was performed by a human on a Core400S using air-purifier-office.yaml.

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.

Fix Core Room Size encoding and decoded value round-trip

1 participant