Conversation
Root cause: touStatus field was incorrectly using device_bool_to_python converter (1/2 encoding), but the device uses standard 0/1 encoding. Solution: Use Python's built-in bool() which naturally handles 0=False, 1=True encoding. This is simpler than a custom converter. Changes: - models.py: Use BeforeValidator(bool) for TouStatus field - tests: Added TestBuiltinBoolForTouStatus with 15 test cases - docs: Updated quick_reference.rst noting touStatus exception - CHANGELOG.rst: Added Version 7.2.2 entry Device encoding: 0=disabled/False, 1=enabled/True Fixes issue where TOU status always reported False regardless of actual device state. All 378 tests passing.
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 status was always reporting
Falseregardless of actual device state.Root Cause
Version 7.2.1 incorrectly used
device_bool_to_pythonconverter (1/2 encoding) for thetouStatusfield, but the device actually uses standard 0/1 encoding:Solution
Use Python's built-in
bool()which naturally handles 0/1 encoding. This is simpler and clearer than creating a custom converter.Changes
TouStatusto useBeforeValidator(bool)TestBuiltinBoolForTouStatuswith 15 test casestouStatususes 0/1 encoding (exception to standard 1/2)Validation
✅ All 378 tests passing (+1 new test class)
✅ Linting: All checks passed
✅ Type checking: No issues found
Testing
Fixes the issue where TOU status always appeared as False.