Skip to content

Add device triggers for Legrand radiant wireless switch #3970

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

Merged
merged 11 commits into from
May 24, 2025

Conversation

stout01
Copy link
Contributor

@stout01 stout01 commented Mar 21, 2025

Proposed change

Adds on/off press and long press event support for the Legrand radiant wireless switch

image image

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

Copy link

codecov bot commented Mar 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.22%. Comparing base (5556090) to head (b94d3d9).
Report is 6 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3970      +/-   ##
==========================================
+ Coverage   91.19%   91.22%   +0.02%     
==========================================
  Files         335      336       +1     
  Lines       10886    10890       +4     
==========================================
+ Hits         9928     9934       +6     
+ Misses        958      956       -2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheJulianJES TheJulianJES added the needs reviewer answer An answer from a reviewer is needed (e.g. why a PR isn't acceptable in the current state). label Mar 26, 2025
Copy link
Collaborator

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

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

I think we can even use a v2 quirk for defining the device_automation_triggers instead. This is still the old "v1 quirk style".

See this example: https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/sonoff/button.py

You'll likely also want to add .replaces(LegrandPowerConfigurationCluster) though (if needed to get battery percentage working for this device).

LegrandPowerConfigurationCluster,
Identify.cluster_id,
PollControl.cluster_id,
LegrandCluster,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking at the LegrandCluster implementation, it seems specific to a dimmer, so we may not want to replace that here:

class LegrandCluster(CustomCluster):
"""LegrandCluster."""
cluster_id = MANUFACTURER_SPECIFIC_CLUSTER_ID
name = "LegrandCluster"
ep_attribute = "legrand_cluster"
attributes = {
0x0000: ("dimmer", t.data16, True),
0x0001: ("led_dark", t.Bool, True),
0x0002: ("led_on", t.Bool, True),
}

(IMO, that LegrandCluster class should have been defined in those dimmer quirks instead and named appropriately to avoid confusion.)

@TheJulianJES TheJulianJES changed the title Add support for Legrand radiant wireless switch Add device triggers for Legrand radiant wireless switch Apr 29, 2025
@TheJulianJES TheJulianJES added waiting for changes Waiting for changes to the PR needs reviewer answer An answer from a reviewer is needed (e.g. why a PR isn't acceptable in the current state). and removed needs reviewer answer An answer from a reviewer is needed (e.g. why a PR isn't acceptable in the current state). labels Apr 29, 2025
(
QuirkBuilder(f" {LEGRAND}", " Remote switch")
.replaces(LegrandPowerConfigurationCluster)
.removes(BinaryInput.cluster_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed because the binary input never changes. It is always displayed as "Off".
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

We may want to use .prevent_default_entity_creation(endpoint_id=1, cluster_id=BinaryInput.cluster_id) instead of removing the cluster entirely.
Not really a huge difference, but might be nicer to do it this way, since we can prevent discovery for default ZHA entities via quirks now.

Otherwise, I think this looks good now.

@stout01 stout01 requested a review from TheJulianJES May 5, 2025 14:33
@TheJulianJES TheJulianJES added smash This PR is close to be merged soon and removed needs reviewer answer An answer from a reviewer is needed (e.g. why a PR isn't acceptable in the current state). waiting for changes Waiting for changes to the PR labels May 19, 2025
Copy link
Collaborator

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good to me.

@TheJulianJES TheJulianJES merged commit a6401a4 into zigpy:dev May 24, 2025
9 checks passed
@stout01 stout01 deleted the legrand-wireless-switch branch May 25, 2025 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
smash This PR is close to be merged soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Device Support Request] Legrand Wireless Radiant Switch
2 participants