Repository navigation
fix(meter-pro): validate display setting input types - #622
Conversation
Enum setters now accept the enum or its integer value and raise SwitchbotOperationError for anything else, bool setters reject non-bool values, unknown zone icons are kept as raw ints, the calibration tenths byte is range-checked in full, and the weather opcodes are grouped again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
|
Thanks for following up on #621. I merged the latest
I verified normal display and calibration readback on both Meter Pro models through ESPHome. The two edge cases are covered by regression tests with simulated responses. |
|
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
PR Review — fix(meter-pro): validate display setting input typesMerge-ready. The input validation is correct and tested on every setter, and the wire format is unchanged. What works well:
Remaining nit (non-blocking):
✅ Resolved since last review (2)Previously-flagged issues verified fixed
🟢 Suggestions
1. Bool and enum validation still raise errors in two different ways
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
Summary
Follow-up to #621, addressing the non-blocking points left in its last automated review.
set_display_zone,set_zone_iconsandset_date_formataccept the enum or its integer value. These setters andset_weathershare the same enum validation. An invalid type or unknown value raisesSwitchbotOperationError.set_battery_icon,set_temperature_unitandset_button_functionsreject non-bool values ("false",0.0,1…) before anything is sent, so a config value can no longer silently send the opposite setting.0x00) and keep (0x0F) returnNone. Other unknown icon codes are returned as raw integers for diagnostics.0x15reads as.5. Low-nibble values0xA–0xFare rejected.COMMAND_GET_WEATHER/COMMAND_SET_WEATHERare grouped with the other opcodes again.No wire format changes.
Tests
0x0Fkeep value and calibration responses with a nonzero upper nibble.I prepared this with an AI coding assistant; I'm the person responsible for this PR and will follow up on review.
🤖 Generated with Claude Code