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

Remove LevelControl cluster for IKEA plugs #3174

Conversation

TheJulianJES
Copy link
Collaborator

@TheJulianJES TheJulianJES commented May 28, 2024

Proposed change

Adds a v2 quirk for IKEA plugs that removes the LevelControl cluster for IKEA TRADFRI and TRETAKT smart plugs, so the config options aren't shown in ZHA.
The old Tradfri plug quirk is also no longer needed and thus removed, as the v2 quirk also matches all of those deviecs.

Additional information

Supersedes #3145

This is still untested, but should work fine. Feedback is welcome!

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works

This removes the `LevelControl` cluster for IKEA TRADFRI and TRETAKT smart plugs, so the config options aren't shown in ZHA.
This is no longer needed, as the v2 quirk also matches all of these devices.
Copy link

codecov bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.18%. Comparing base (5ce06cf) to head (290f163).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3174      +/-   ##
==========================================
- Coverage   88.19%   88.18%   -0.02%     
==========================================
  Files         300      300              
  Lines        9400     9392       -8     
==========================================
- Hits         8290     8282       -8     
  Misses       1110     1110              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheJulianJES
Copy link
Collaborator Author

Codecov project coverage decrease is expected, as the old quirk had quite a few lines and is now fully removed with this.

@MattWestb
Copy link
Contributor

Not possible testing then ZHA is trying using both old (HA 2024.5.X) and new local quirks and is not loading:

Logger: homeassistant.config_entries
Source: config_entries.py:584
First occurred: 07:05:49 (1 occurrences)
Last logged: 07:05:49

Error setting up entry socket://192.168.2.74:9999 for zha
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 584, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 135, in async_setup_entry
    async with radio_mgr.connect_zigpy_app() as app:
  File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/radio_manager.py", line 182, in connect_zigpy_app
    app = await self.radio_type.controller.new(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/zigpy/application.py", line 252, in new
    await app._load_db()
  File "/usr/local/lib/python3.12/site-packages/zigpy/application.py", line 108, in _load_db
    await self._dblistener.load()
  File "/usr/local/lib/python3.12/site-packages/zigpy/appdb.py", line 675, in load
    device = zigpy.quirks.get_device(device)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/zigpy/quirks/__init__.py", line 41, in get_device
    return _DEVICE_REGISTRY.get_device(device)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/zigpy/quirks/registry.py", line 96, in get_device
    raise MultipleQuirksMatchException(
zigpy.exceptions.MultipleQuirksMatchException: Multiple matches found for device <Device model='TRETAKT Smart plug' manuf='IKEA of Sweden' nwk=0x222F ieee=38:39:8f:ff:fe:0f:72:5c is_initialized=True>: [QuirksV2RegistryEntry(registry=<zigpy.quirks.registry.DeviceRegistry object at 0xffff570da480>, quirk_location='file[/config/custom_zha_quirks/IKEAPlugs.py]-line:9', filters=[], custom_device_class=None, device_node_descriptor=None, skip_device_configuration=False, adds_metadata=[], removes_metadata=[RemovesMetadata(cluster_id=8, endpoint_id=1, cluster_type=<ClusterType.Server: 0>)], replaces_metadata=[], entity_metadata=[], device_automation_triggers_metadata={}), QuirksV2RegistryEntry(registry=<zigpy.quirks.registry.DeviceRegistry object at 0xffff570da480>, quirk_location='file[/config/custom_zha_quirks/IKEAPlugs.py]-line:9', filters=[], custom_device_class=None, device_node_descriptor=None, skip_device_configuration=False, adds_metadata=[], removes_metadata=[RemovesMetadata(cluster_id=8, endpoint_id=1, cluster_type=<ClusterType.Server: 0>)], replaces_metadata=[], entity_metadata=[], device_automation_triggers_metadata={})]

But i like the design of the quirk !!!!

@jasimancas
Copy link
Contributor

jasimancas commented May 29, 2024

image

Works properly @TheJulianJES ! :D

Can you rename "zigpy.quirks.v2.CustomDeviceV2" (the CustomDeviceV2 part) to "Ikea_Plugs_v2" or similar?

@TheJulianJES
Copy link
Collaborator Author

Thanks for testing!
Due to how quirks v2 works, there's no longer a quirk class in zha-quirks, so it'll look like this for now.
In a future release, we'll probably show the new quirk_location in the frontend that works for v2 quirks. Related PR:

@TheJulianJES TheJulianJES merged commit 3e8d14d into zigpy:dev May 29, 2024
5 of 6 checks passed
@jasimancas
Copy link
Contributor

Thank you very much for all you do for ZHA, glad to help.

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.

3 participants