Expose water filter expiry date and remaining gallons - #101
JonGilmore merged 3 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches✨ Simplify code
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…r appliances lack these keys
There was a problem hiding this comment.
🧹 Nitpick comments (1)
components/subzero_protocol/protocol.cpp (1)
270-280: 💤 Low valueConsider validating the date format more thoroughly.
The current check
v.size() == 10 && v[4] == '-' && v[7] == '-'accepts any 10-character string with dashes in the right positions (e.g., "ABCD-EF-GH"). While the appliance protocol is controlled and unlikely to send malformed dates, a more robust validation would improve safety.However, given that:
- The input source is a known appliance protocol (not user input)
- Invalid formats pass through unchanged (defensive fallback)
- Test coverage validates the happy path
The current implementation is acceptable for this use case.
Optional enhancement: Add a regex or character-range check to validate YYYY-MM-DD format if you want defense-in-depth.
♻️ Optional: More robust date validation
if (auto raw = opt_str(data["water_filter_end_date"])) { const std::string &v = *raw; - if (v.size() == 10 && v[4] == '-' && v[7] == '-') { + // Validate YYYY-MM-DD format (year, month, day are digits) + if (v.size() == 10 && v[4] == '-' && v[7] == '-' && + std::isdigit(v[0]) && std::isdigit(v[1]) && std::isdigit(v[2]) && std::isdigit(v[3]) && + std::isdigit(v[5]) && std::isdigit(v[6]) && + std::isdigit(v[8]) && std::isdigit(v[9])) { state.water_filter_end_date = v + "T00:00:00+00:00"; } else { state.water_filter_end_date = v; } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@components/subzero_protocol/protocol.cpp` around lines 270 - 280, The current date promotion uses a brittle positional check (v.size()==10 && v[4]=='-' && v[7]=='-') which can accept non-digit characters; update the validation inside the opt_str(data["water_filter_end_date"]) block to ensure the string truly matches YYYY-MM-DD before appending "T00:00:00+00:00" — e.g., replace the simple positional test on v with either a std::regex match for R"(\d{4}-\d{2}-\d{2})" or explicit isdigit checks for v[0..3], v[5..6], v[8..9]; keep the defensive fallback of assigning state.water_filter_end_date = v when the check fails and continue using state.water_filter_end_date = v + "T00:00:00+00:00" when the validation passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@components/subzero_protocol/protocol.cpp`:
- Around line 270-280: The current date promotion uses a brittle positional
check (v.size()==10 && v[4]=='-' && v[7]=='-') which can accept non-digit
characters; update the validation inside the
opt_str(data["water_filter_end_date"]) block to ensure the string truly matches
YYYY-MM-DD before appending "T00:00:00+00:00" — e.g., replace the simple
positional test on v with either a std::regex match for R"(\d{4}-\d{2}-\d{2})"
or explicit isdigit checks for v[0..3], v[5..6], v[8..9]; keep the defensive
fallback of assigning state.water_filter_end_date = v when the check fails and
continue using state.water_filter_end_date = v + "T00:00:00+00:00" when the
validation passes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e840fd32-f11a-446c-989f-a43f194bc20e
📒 Files selected for processing (11)
.github/workflows/ci.ymlcomponents/subzero_appliance/__init__.pycomponents/subzero_appliance/appliance.hcomponents/subzero_protocol/dispatch.hcomponents/subzero_protocol/dispatch_esphome.hcomponents/subzero_protocol/protocol.cppcomponents/subzero_protocol/protocol.htests/cpp/dispatch_test.cpptests/cpp/protocol_test.cpptests/fixtures/fridge_back_2028_d5_full.expected.jsontests/fixtures/fridge_pro3650g_d4_full.expected.json
|
@mwbourgeois Could you comment on what model fridge you have? |
36UFDID |
/My/ fridge exposes these sensors. Totally open to rejecting this PR or modification if they are atypical sensors to be reported.
Summary by CodeRabbit
New Features
Chores