-
Notifications
You must be signed in to change notification settings - Fork 27
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
Compute primary entities #298
base: dev
Are you sure you want to change the base?
Conversation
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.
Copilot reviewed 5 out of 12 changed files in this pull request and generated no suggestions.
Files not reviewed (7)
- zha/application/platforms/init.py: Evaluated as low risk
- zha/application/platforms/binary_sensor/init.py: Evaluated as low risk
- zha/application/platforms/climate/init.py: Evaluated as low risk
- zha/application/platforms/cover/init.py: Evaluated as low risk
- zha/application/platforms/fan/init.py: Evaluated as low risk
- zha/application/platforms/light/init.py: Evaluated as low risk
- zha/application/platforms/siren.py: Evaluated as low risk
Comments skipped due to low confidence (2)
zha/zigbee/device.py:1092
- Ensure
info_object
exists before attempting to delete it to avoid potential AttributeError.
def _compute_primary_entity(self) -> None:
zha/application/gateway.py:357
- Ensure that the new behavior introduced by '_compute_primary_entity' is covered by tests to verify correct computation and assignment of the primary entity.
device._compute_primary_entity()
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #298 +/- ##
==========================================
+ Coverage 96.33% 96.36% +0.02%
==========================================
Files 61 61
Lines 9397 9460 +63
==========================================
+ Hits 9053 9116 +63
Misses 344 344 ☔ 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.
Copilot reviewed 5 out of 12 changed files in this pull request and generated no suggestions.
Files not reviewed (7)
- zha/application/platforms/init.py: Evaluated as low risk
- zha/application/platforms/light/init.py: Evaluated as low risk
- zha/application/platforms/climate/init.py: Evaluated as low risk
- zha/application/platforms/fan/init.py: Evaluated as low risk
- zha/application/platforms/cover/init.py: Evaluated as low risk
- zha/application/platforms/siren.py: Evaluated as low risk
- zha/application/platforms/lock/init.py: Evaluated as low risk
cef382c
to
e42993a
Compare
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.
This looks like a nice approach in general
Feel free to update the weights however you see fit, I think I picked defaults that fixed most of the devices I saw in my own home and a few more from memory. |
Primary entities are picked with a simple weighting system that only picks a clear winner: if there are any ties, no primary entity is chosen.
"Control" entities are given a higher priority than sensors and some sensors internally are given higher priority than others:
For the most part it works for me for the vast majority of entities.
This approach does suffer from a few problems. Some devices have unnecessary entities created solely to control/be controlled by other devices.
For example, my blinds have an OnOff cluster:
And my water leak sensor has an
Opening
cluster:I think we should provide an API within quirks v2 to remove entities instead of disabling clusters.