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

Implement external state restoration #58

Merged
merged 37 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a87531d
Consolidate init-time state reading for Light entity
puddly Jul 1, 2024
22b85c7
Read the color mode from cache as well
puddly Jul 1, 2024
58f9b63
Remove duplicate `supported_color_modes` variable
puddly Jul 1, 2024
da3c155
Switch `zcl_color_mode_to_entity_color_mode` to a static dictionary
puddly Jul 1, 2024
eafe473
Only set the color mode from the supported color modes if it is uncached
puddly Jul 1, 2024
c54bdda
Update the attribute cache color mode after the color has been succes…
puddly Jul 1, 2024
a8bc97a
Do not persist the color mode for groups
puddly Jul 1, 2024
8585328
Test that the color mode changes
puddly Jul 1, 2024
c21fd00
Account for invalid ZCL color modes
puddly Jul 1, 2024
6d8395d
Add a quick test for HS
puddly Jul 1, 2024
da2cf75
Unit test enhanced hue as well
puddly Jul 1, 2024
bd22c2b
Re-introduce erroneously removed `cached_property`
puddly Jul 2, 2024
ba9ed65
Add `restore_extra_state_attributes`
puddly Jul 2, 2024
4e164c0
Persist the door lock state after locking/unlocking
puddly Jul 2, 2024
73c4be7
Remove unused lock `kwargs`
puddly Jul 2, 2024
b951f8b
Add `restore_external_state_attributes`
puddly Jul 3, 2024
c075f46
Implement external state for `cover`
puddly Jul 3, 2024
9eaf159
Implement external state for `select`
puddly Jul 3, 2024
7ef8ba3
Implement external state for `siren`
puddly Jul 3, 2024
890a826
Remove unnecessary `_persist_lock_state`
puddly Jul 3, 2024
8aebd9a
Revert "Implement external state for `siren`"
puddly Jul 3, 2024
1802d95
Implement a stub `restore_external_state_attributes` for non-ZCL selects
puddly Jul 3, 2024
c6c15b2
Migrate coverage to `pyproject.toml` and exclude NotImplementedError
puddly Jul 3, 2024
8aebec5
Update zha/application/platforms/light/__init__.py
puddly Jul 3, 2024
3eb8222
Migrate lighting to use explicit state restoration instead of ZCL cache
puddly Jul 3, 2024
cd36b2f
Reduce diff size
puddly Jul 3, 2024
4680d66
Only restore the state if the attribute isn't `None`
puddly Jul 3, 2024
d0703bd
Migrate lock to use state restoration
puddly Jul 3, 2024
50f6d16
Add some unit tests
puddly Jul 3, 2024
d8c25ef
Offload validation to Core
puddly Jul 3, 2024
3b069b6
Implement an `undefined` type
puddly Jul 3, 2024
d6165c5
Migrate remaining platforms to use `UNDEFINED` as well, where appropr…
puddly Jul 4, 2024
4df1b9a
Finish unit tests
puddly Jul 4, 2024
462a1ff
Remove `UNDEFINED`
puddly Jul 5, 2024
221fe2d
Only restore (most) light state attributes if they are not `None`
puddly Jul 5, 2024
26874c1
Fix `number` entity name
puddly Jul 5, 2024
b8d5c57
Revert `cached_property` -> `property` change
puddly Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ async def test_number(

assert cluster.read_attributes.call_count == 3

assert entity.name == "PWM1"

# test that the state is 15.0
assert entity.state["state"] == 15.0

Expand Down
9 changes: 4 additions & 5 deletions zha/application/platforms/number/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,13 @@
"""Return the value step."""
return self._analog_output_cluster_handler.resolution

@functools.cached_property
@property
puddly marked this conversation as resolved.
Show resolved Hide resolved
def name(self) -> str | None:
"""Return the name of the number entity."""
description = self._analog_output_cluster_handler.description
# TODO what happened here?
if description is not None and len(description) > 0:
return f"{super().name} {description}"
return super().name
if not description:
return None

Check warning on line 149 in zha/application/platforms/number/__init__.py

View check run for this annotation

Codecov / codecov/patch

zha/application/platforms/number/__init__.py#L149

Added line #L149 was not covered by tests
return description

@functools.cached_property
def icon(self) -> str | None:
Expand Down
Loading