Conversation
a474c4f to
9f9a3a8
Compare
TOU status was always appearing as OFF regardless of actual state. Root cause: tou_status_to_python converter was using incorrect encoding: - Old (incorrect): 0 = OFF, 1 = ON - Correct: 1 = OFF, 2 = ON (standard OnOffFlag encoding) When device sent 2 (ON), converter returned False. When device sent 1 (OFF), it incorrectly returned True. Changes: - Removed duplicate tou_status_to_python() function - Updated TouStatus type to use device_bool_to_python (same as all OnOffFlag) - Removed redundant TOU status converter tests (already covered by device_bool) - Simplified converters module exports This eliminates code duplication since tou_status uses the same encoding as all other OnOffFlag fields in the device protocol. All 363 tests pass.
9f9a3a8 to
f3bb418
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TOU (Time of Use) status was always appearing as OFF regardless of the actual state.
Root Cause
The
tou_status_to_pythonconverter was using incorrect device protocol encoding:OnOffFlagencoding)When the device sent
2(ON), the converter incorrectly returnedFalse. When the device sent1(OFF), it incorrectly returnedTrue. The values were inverted!Solution
tou_status_to_python()to use the correctOnOffFlagencoding where 1=OFF and 2=ONOnOffFlagencodingTesting
✅ All 378 tests passing
✅ Linting checks passing (ruff)
✅ Type checking passing (mypy on converters.py)
✅ No new errors introduced
The TOU status will now correctly report ON when enabled and OFF when disabled.