-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move responsibility of fixing legacy model values to Model itself #462
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #462 +/- ##
==========================================
+ Coverage 95.17% 95.37% +0.20%
==========================================
Files 8 8
Lines 539 541 +2
Branches 40 40
==========================================
+ Hits 513 516 +3
Misses 17 17
+ Partials 9 8 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
homewizard_energy/models.py (2)
57-60
: Avoid shadowing or re-initializing system if not necessary.Currently,
self.system
might be re-initialized in subsequent steps (lines 65–66 and 71–72). Evaluate if it’s safe to setsystem
here to a defaultSystem()
object at the outset, minimizing further conditionals.
69-74
: Ensure brightness is handled consistently.The conversion
(brightness / 255) * 100
returns a float. Ifstatus_led_brightness_pct
is expected as an integer (0–100), consider rounding or clamping the result.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
homewizard_energy/models.py
(1 hunks)homewizard_energy/v1/__init__.py
(1 hunks)
🔇 Additional comments (3)
homewizard_energy/v1/__init__.py (1)
18-18
: Removal of unused import is consistent with new architecture.The removal of
CombinedModels
from the imports and the associatedcombined
method inHomeWizardEnergyV1
aligns with the updated design, in which theCombinedModels
initialization logic is moved to the class's own__init__
method inmodels.py
.homewizard_energy/models.py (2)
50-56
: Constructor signature aligns with the new design.By injecting
device
,measurement
,state
, andsystem
into theCombinedModels
constructor, you centralize the logic for backward compatibility within the model itself, making it more cohesive and self-contained.
62-68
: Validate the potential conflicts when both measurement.wifi_ssid and system.wifi_ssid exist.If
system
is provided with an existingwifi_ssid
whilemeasurement.wifi_ssid
is also set, ensure there is a clear resolution strategy (which one takes precedence?).
Summary by CodeRabbit
CombinedModels
classcombined
method fromHomeWizardEnergyV1
class