-
Notifications
You must be signed in to change notification settings - Fork 123
Improvements 7 - Config class #120
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
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #120 +/- ##
==========================================
+ Coverage 50.82% 51.04% +0.21%
==========================================
Files 14 15 +1
Lines 1332 1340 +8
Branches 140 140
==========================================
+ Hits 677 684 +7
Misses 642 642
- Partials 13 14 +1
|
|
@ikalchev What do you think about marking these methods as Would be open to deleting them directly as well. |
ikalchev
left a comment
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.
Looks good, minor comments
pyhap/accessory.py
Outdated
| if self.mac or self._pincode: | ||
| self.driver.config.set_values(mac=self.mac, pincode=self._pincode) | ||
|
|
||
| def add_paired_client(self, client_uuid, client_public): |
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.
I think it's safe to remove add/remove_paired, I don't think it will break someone
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.
I removed them and acc.config_version, acc.pincode and acc.paired as well, since they are all mainly used locally.
pyhap/config.py
Outdated
| self.private_key = sk | ||
| self.public_key = vk | ||
|
|
||
| @property |
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.
Is there really any value in making this a @Property instead of initialising it in the init? For me this just adds overhead
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.
Removed all properties and moved that to init as suggested. Removed set_values as well.
pyhap/config.py
Outdated
| self._setup_id = util.generate_setup_id() | ||
| return self._setup_id | ||
|
|
||
| def set_values(self, *, address=None, config_version=None, mac=None, |
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.
Do we need this? Can't we make all fields "public" by removing the underscore and the @ property - after all, this is a data class
pyhap/config.py
Outdated
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class Config: |
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.
nit: What do you think about State instead (config implies something that does not change at runtime)
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.
State is better. I've changed it.
|
What do you think about caching Anyway, I won't be holding back the merge because of the above, we can do it at a later point if we decide. |
|
I don't think that's really necessary. We would just increase the referrence count unnecessarily and decrease readability. The most of the |
* Merge master back into dev (#111) * Fix typo in log message (#112) * Fix typo in SDS011 * Documentation improvements for version 2.0.0 (#114) * Replace event_loop with loop (#107) * Changelog update (#116) * Added entry for event loop change * Additional changes * Small changes - Accessory (#117) * Improved bridge.to_HAP * Updated changelog * Fix another typo in SDS011 which prevented pm10 from getting updates. * Added getter_callback to Characteristic #78 * Fix typo bridge.to_HAP (#119) * Adding Code Style Checker (#118) * Add basis for style checker * Fixed lint errors * Updated changelog * Improvements 7 - Config class (#120) Added a State class which keeps Accessory runtime properties such as port, address, paired clients, etc. This state is stored and managed by the driver. * Remove the pyhap.accessories package. (#115) * Remove the pyhap.accessories package. All accessories are temporarily moved to the root accessories folder. These will be moved into separate repositories as appropriate. pyhap.accessories is now an implicit namespace package. See pyhap/accessories/README.md for how others can share their accessories as HAP-python subpackages. * Release v2.1.0.
Note: This PR is based on #118 to avoid merge conflicts. I will rebase it as soon as the other one is merged. Until then the last commit contains the changes for this PR.Description
This is a follow up to #105. Currently (semi-)static information are distributed across multiple classes which makes it more difficult to track which are used and when. Eg. the private and public key are generated for every accessory even if it's bridged.
Changes
Confighelper classaccessory_driverandaccessoryto it, inclusive the pairing methodsaccessory_driver, since it has been deprecated foraccessoriesdeprecatedencoderandAccessoryMDNSServiceInfo