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

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

Conversation

stout01
Copy link

@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.20%. Comparing base (5556090) to head (2c42e52).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #3970   +/-   ##
=======================================
  Coverage   91.19%   91.20%           
=======================================
  Files         335      336    +1     
  Lines       10886    10891    +5     
=======================================
+ Hits         9928     9933    +5     
  Misses        958      958           

☔ 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
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

@stout01 stout01 requested a review from TheJulianJES May 5, 2025 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Device Support Request] Legrand Wireless Radiant Switch
2 participants