Skip to content
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

Fix hashing of accessories to not include the value #464

Merged
merged 14 commits into from
Oct 14, 2023

Conversation

bdraco
Copy link
Contributor

@bdraco bdraco commented Oct 11, 2023

Needs #463 merged first

The hash of accessories would include the value which meant that we would increment the c# very frequently which could drain battery and force iCloud to sync over and over. The hash should only include the actual config and not the value. The net result is everything could appear unavailable since the iCloud sync would never finish for some users and the constant get_accessories could overload the system.

HA just added support for reloading accessories which will generate a lot more get requests since the c# value is going to change more frequently.

to_HAP is now cached to handle this.

@bdraco bdraco changed the title Add some more typing characteristics and services Cache construction of to_HAP for Characteristic objects Oct 11, 2023
@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

Merging #464 (6d5b36a) into dev (07df76b) will increase coverage by 0.13%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev     #464      +/-   ##
==========================================
+ Coverage   92.48%   92.62%   +0.13%     
==========================================
  Files          20       20              
  Lines        2223     2263      +40     
  Branches      274      279       +5     
==========================================
+ Hits         2056     2096      +40     
  Misses        123      123              
  Partials       44       44              
Files Coverage Δ
pyhap/accessory.py 97.33% <100.00%> (ø)
pyhap/accessory_driver.py 91.98% <100.00%> (ø)
pyhap/characteristic.py 100.00% <100.00%> (ø)
pyhap/service.py 100.00% <100.00%> (ø)

@bdraco bdraco marked this pull request as ready for review October 11, 2023 19:41
@bdraco bdraco marked this pull request as draft October 12, 2023 04:16
@bdraco
Copy link
Contributor Author

bdraco commented Oct 12, 2023

Leaving as draft until parent merges

@bdraco
Copy link
Contributor Author

bdraco commented Oct 12, 2023

We have a bug here, we need the hash without the value for the c#

@bdraco bdraco changed the title Cache construction of to_HAP for Characteristic objects Fix hashing of accessories to not include the value Oct 12, 2023
@bdraco bdraco marked this pull request as ready for review October 12, 2023 20:27
@bdraco
Copy link
Contributor Author

bdraco commented Oct 14, 2023

Fixing conflicts...

@bdraco
Copy link
Contributor Author

bdraco commented Oct 14, 2023

Retesting

@bdraco
Copy link
Contributor Author

bdraco commented Oct 14, 2023

All good

@ikalchev ikalchev merged commit e077ce5 into ikalchev:dev Oct 14, 2023
10 checks passed
@bdraco bdraco deleted the typing_char_cache branch October 14, 2023 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants