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

Inovelli v2 Quirks Update #3232

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open

Conversation

codyhackw
Copy link
Contributor

Proposed change

Updating Inovelli Quirks to the v2 formatting, as well as an update to add the leading/training edge parameter for the VZM36, but removing it from the VZM31SN per Inovelli's request (it's still configurable via button press combo at the switch, which is the recommended method).

Additional information

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

Updating Inovelli Quirks to the new formatting, as well as update to add the leading/training edge parameter for the VZM36, but removing it from the VZM31SN per Inovelli's request.
@TheJulianJES
Copy link
Collaborator

Oooh, awesome that you're doing this!
There are some very small changes to the quirks v2 API, example here: #3280
It'll land with the next HA beta, so should also be in the final 2024.8.0 release.

Also, there were some repo changes, so you probably need to rebase this (or merge dev into your branch).

@TheJulianJES
Copy link
Collaborator

This also seems to supersede this PR then:

@codyhackw
Copy link
Contributor Author

Oooh, awesome that you're doing this! There are some very small changes to the quirks v2 API, example here: #3280 It'll land with the next HA beta, so should also be in the final 2024.8.0 release.

Also, there were some repo changes, so you probably need to rebase this (or merge dev into your branch).

Looks like that was just the change from add_to_registry_v2 to QuirkBuilder being used and add_to_registry() called at the end now? If so, should be fixed now. I believe I chose the right option there on merging dev in, but if not, just let me know and I can get that sorted too.

@TheJulianJES
Copy link
Collaborator

TheJulianJES commented Aug 4, 2024

Yep, that's fine. Pre-commit just complains about some missing docstrings now.
Tests are a bit different with quirks v2, since we no longer have specific classes for the quirks. I'll have to look at the specific test(s), but you should be able to use device = zigpy_device_from_v2_quirk("manuf", "model") to get a device with the custom clusters in a test.

Copy link

codecov bot commented Aug 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.29%. Comparing base (915ff9b) to head (4b5af81).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3232      +/-   ##
==========================================
+ Coverage   88.18%   88.29%   +0.10%     
==========================================
  Files         301      301              
  Lines        9412     9498      +86     
==========================================
+ Hits         8300     8386      +86     
  Misses       1112     1112              

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

@dmulcahey
Copy link
Collaborator

IMG_8210

Just comments missing

@TheJulianJES
Copy link
Collaborator

And the custom cluster on endpoint 3 isn't replaced yet (when it exists). But we can't add .replaces() for that endpoint yet, since RemovesMetadata assumes the endpoint actually exists (or zigpy crashes otherwise). That seems like an issue.
I'll post more details later and/or fix the zigpy issue if it's one.

@dmulcahey
Copy link
Collaborator

And the custom cluster on endpoint 3 isn't replaced yet (when it exists). But we can't add .replaces() for that endpoint yet, since RemovesMetadata assumes the endpoint actually exists (or zigpy crashes otherwise). That seems like an issue. I'll post more details later and/or fix the zigpy issue if it's one.

Ooo… I wonder if we should have another implementation replace_if_present or if we should update the existing one 🤔

@TheJulianJES
Copy link
Collaborator

TheJulianJES commented Aug 11, 2024

Ooo… I wonder if we should have another implementation replace_if_present or if we should update the existing one 🤔

Up until seconds ago, I thought we can just update the existing one. It adds RemovesMetadata and AddsMetadata.
If we call removes on a non-existent cluster (on a valid endpoint), nothing will happen already. We ignore that case.
But we error out if we try to remove a cluster on a non-existent endpoint.

To ignore this, we can just check if the endpoint exists:
zigpy/zigpy@dev...TheJulianJES:tjj/quirks_v2_removes_non_exist_endpoint (ignore test line change here)

But the above change is not enough. When AddsMetadata is processed, it'll also fail on the non-existent endpoint.
If we also check there that the endpoint exists, a change like this would work: zigpy/zigpy@dev...TheJulianJES:tjj/quirks_v2_removes_non_exist_endpoint_and_add

Currently thinking about if we want to error out when removes, replaces, or adds is called on a non-existent endpoint. Maybe? Like, removes already completely ignores if a cluster that is to be replaced is missing. It just errors out when the endpoint is missing too.
But with adds (also used by `replaces), I'm not sure. We may want to error out here, as the cluster will be missing if the endpoint is missing (obviously). Silently failing here might not be a good option.
But it's also unlikely to ever do this unintentionally? Like, at least when testing, you'll notice that the cluster you're trying to replace/add is missing.

Maybe we want a separate method after all? Not sure yet...

EDIT: We can use the following for this PR:

(
QuirkBuilder("Inovelli", "VZM31-SN")
.replaces(InovelliVZM31SNCluster)
.replaces(InovelliVZM31SNCluster, endpoint_id=2, cluster_type=ClusterType.Client)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be able to use replace_cluster_occurrences from zigpy/zigpy#1441 for the custom output clusters on all endpoints.

Haven't tested this, but this might work (if zigpy is new enough on the quirks repo, might need to be bumped?):

Suggested change
.replaces(InovelliVZM31SNCluster, endpoint_id=2, cluster_type=ClusterType.Client)
.replace_cluster_occurrences(InovelliVZM31SNCluster, cluster_type=ClusterType.Client)

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