ikalchev / HAP-python

A python implementation of the HomeKit Accessory Protocol (HAP)
Other
619 stars 118 forks source link

Fix hashing of accessories to not include the value #464

Closed bdraco closed 11 months ago

bdraco commented 11 months ago

Needs https://github.com/ikalchev/HAP-python/pull/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.

codecov[bot] commented 11 months ago

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 commented 11 months ago

Leaving as draft until parent merges

bdraco commented 11 months ago

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

bdraco commented 11 months ago

Fixing conflicts...

bdraco commented 11 months ago

Retesting

bdraco commented 11 months ago

All good