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

Initial standalone version #6

Merged
merged 124 commits into from
Mar 27, 2024
Merged

Initial standalone version #6

merged 124 commits into from
Mar 27, 2024

Conversation

dmulcahey
Copy link
Contributor

@dmulcahey dmulcahey commented Mar 20, 2024

TODO:

  • test coverage
  • update platform + tests
  • (invalid) mypy unreachable code errors in light.py
    - [ ] make group entities use cluster handlers? - this can't be done until the API in Zigpy is compatible.
  • make config schemas dataclasses
  • make all events dataclasses
  • device availability dispatcher replacement (handle similarly to group entities / lights?) Is this even needed? For HA maybe just use emit from our device and have HA use that to to update the proxy it holds
  • sweep for unused methods that remain from the conversion
  • prune unused constants
  • verify all entity defaults to account for things that were previously handled by HA core
  • rename entity classes
  • remove ZHA prefix from class names
  • handle zigpy controller reset correctly - Find a way to not reload the integration when a radio reset is sufficient
  • remove any remaining commented out blocks after the above items are complete
  • outbound events (relay events for UI, ZHA events for devices etc.) and clean up disparity between async_send_signal and emit and centralize on emit
  • don't use event base to manage group state and refreshes. Use direct entity access instead for efficiency?
  • Reduce counter sensor overhead (maybe another reason to pull in coordinator entity)
  • Clean up handle_cluster_handler_attribute_updated - make sure entities are only using the data they intend to
  • Clean up all to_json() methods

@dmulcahey
Copy link
Contributor Author

dmulcahey commented Mar 26, 2024

Can't unify group entities to use cluster handlers until Zigpy is updated to make the API consistent:

DEBUG    zigpy.group:group.py:259 [0x0002] trying to create new group 6 cluster id
DEBUG    zigpy.group:group.py:270 [0x0002] trying to create a new group 'id' cluster
DEBUG    zigpy.util:util.py:62 Error calling listener <bound method Gateway.group_member_added of <zha.application.gateway.Gateway object at 0x122efdb50>> with args (<Group group_id=0x0002 name='Test Group' members={(01:2d:6f:00:0a:90:69:e8, 1): <Endpoint id=1 in=[on_off:0x0006, level:0x0008, light_color:0x0300, groups:0x0004, identify:0x0003] out=[] status=<Status.NEW: 0>>, (02:2d:6f:00:0a:90:69:e9, 1): <Endpoint id=1 in=[on_off:0x0006, level:0x0008, light_color:0x0300, groups:0x0004, identify:0x0003] out=[] status=<Status.NEW: 0>>}>, <Endpoint id=1 in=[on_off:0x0006, level:0x0008, light_color:0x0300, groups:0x0004, identify:0x0003] out=[] status=<Status.NEW: 0>>)
Traceback (most recent call last):
  File "/Users/dmulcahey/development/homeassistant/zha/venv/lib/python3.12/site-packages/zigpy/util.py", line 60, in listener_event
    result.append(method(*args))
                  ^^^^^^^^^^^^^
  File "/Users/dmulcahey/development/homeassistant/zha/zha/application/gateway.py", line 357, in group_member_added
    discovery.GROUP_PROBE.discover_group_entities(zha_group)
  File "/Users/dmulcahey/development/homeassistant/zha/zha/application/discovery.py", line 582, in discover_group_entities
    entity_class(group)
  File "/Users/dmulcahey/development/homeassistant/zha/zha/application/platforms/light/__init__.py", line 1121, in __init__
    self._on_off_cluster_handler: OnOffClusterHandler = OnOffClusterHandler(
                                                        ^^^^^^^^^^^^^^^^^^^^
  File "/Users/dmulcahey/development/homeassistant/zha/zha/zigbee/cluster_handlers/general.py", line 433, in __init__
    super().__init__(cluster, endpoint)
  File "/Users/dmulcahey/development/homeassistant/zha/zha/zigbee/cluster_handlers/__init__.py", line 177, in __init__
    self._id: str = f"{endpoint.id}:0x{cluster.cluster_id:04x}"
                       ^^^^^^^^^^^
  File "/Users/dmulcahey/development/homeassistant/zha/venv/lib/python3.12/site-packages/zigpy/group.py", line 272, in __getattr__
    cluster = GroupCluster.from_attr(self, name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dmulcahey/development/homeassistant/zha/venv/lib/python3.12/site-packages/zigpy/group.py", line 206, in from_attr
    raise AttributeError(f"Unsupported {ep_name} group cluster")
AttributeError: Unsupported id group cluster

The logging in Zigpy also appears to need to be tweaked:

DEBUG    zigpy.group:group.py:259 [0x0002] trying to create new group 8 cluster id
DEBUG    zigpy.group:group.py:259 [0x0002] trying to create new group 3 cluster id

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.

1 participant