zigpy / zha

Zigbee Home Automation
Apache License 2.0
10 stars 4 forks source link

Implement external state restoration #58

Closed puddly closed 2 weeks ago

puddly commented 3 weeks ago

A few platforms in ZHA uses instance attributes and complex logic to derive their state, relying on Home Assistant to persist it and restore it after startup:

In the future, we need to explore a way to store this extra state. I think zigpy can provide a hook. Alternatively, we can invert the storage logic and have ZHA implement a database driver for zigpy.

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 97.61905% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.25%. Comparing base (6794a64) to head (b8d5c57). Report is 1 commits behind head on dev.

Files Patch % Lines
zha/application/platforms/number/__init__.py 66.66% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #58 +/- ## ========================================== + Coverage 95.00% 95.25% +0.25% ========================================== Files 61 61 Lines 9306 9335 +29 ========================================== + Hits 8841 8892 +51 + Misses 465 443 -22 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

puddly commented 2 weeks ago

I've foregone using the ZCL cache and instead just implement restore_external_state_attributes for the required entities. This makes this PR much simpler.