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

Change ZHA Tuya plugs to use quirk IDs #102489

Merged

Conversation

TheJulianJES
Copy link
Contributor

@TheJulianJES TheJulianJES commented Oct 21, 2023

Proposed change

This implements using quirk IDs for configurable Tuya plugs.

The main purpose is to not duplicate manufacturer/model names in both ZHA and zha-quirks.
For example, there are many different versions of the Tuya TS011F plug. Each version requires a (slightly new) quirk.
With this PR, it'll be enough to create a new quirk in zha-quirks with the same quirk ID.

This fixes issues like: #82108 (and others that aren't listed here where plugs don't have a quirk yet, but ZHA still tries to initialize the custom attributes which don't exist).
So this PR is both a bug-fix and an improvement to code quality.

(In the future, more existing "devices" can be switched to using quirk IDs.)

Tested

Tested these changes with a BlitzWolf SHP-13 (_TZ3000_g5xawfcq / TS0121) plug and they seem to be working as expected.
The child_lock entity isn't created for this plug, as the devices report that it's an "unsupported attribute" upon initialization of the plug (expected/good).
(That plug model uses the configuration attributes on the OnOff cluster.)

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue) (fixes issues from previous implementation)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests (<- original goal)

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @dmulcahey, @Adminiuga, @puddly, mind taking a look at this pull request as it has been labeled with an integration (zha) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zha can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign zha Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@TheJulianJES TheJulianJES force-pushed the tjj/zha_quirk_ids_change_matches branch from 37e14a6 to 9168a28 Compare October 24, 2023 21:35
@TheJulianJES
Copy link
Contributor Author

TheJulianJES commented Oct 24, 2023

PR is rebased now. Diff should be easier to review now and changes are tested on physical devices.

EDIT: Quirks bump is made too. PR is ready.

@TheJulianJES TheJulianJES mentioned this pull request Oct 24, 2023
20 tasks
@TheJulianJES
Copy link
Contributor Author

TheJulianJES commented Oct 25, 2023

I'd still target this PR for the 2023.11.x beta if possible, as it fixes multiple issues with non-quirked Tuya plugs.
See this linked issue for example. (It's still an issue, but was closed due to being stale.)

EDIT: Do not tag it for 2023.11.x anymore.

@dmulcahey dmulcahey merged commit e755dd8 into home-assistant:dev Nov 17, 2023
23 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

async_initialize' stage failed: 'power_on_state'
4 participants