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

Send all button press events for Sinope SW2500ZB/DM2500ZB #3438

Merged
merged 3 commits into from
Oct 26, 2024

Conversation

bassdr
Copy link
Contributor

@bassdr bassdr commented Oct 17, 2024

Proposed change

Added support for both press and release button events in order to properly support short and long press events.
Also added the pressed button and text description in the event arguments to simplify writing automations processing it.

ZHA now send both when we start pressing the Switch's up or down button, and when we release. Before, we were only sending events when a button was released after being pressed for a long time, or if double pressed, limiting possibilities. Now all events are sent: pressed, short released, long released and double pressed.

Note that I also added two extra arguments the the send zha_event because it was a bit hard to extract which button was pressed (up or down). It's now a new attribute {button: turn_on} or {button: turn_off} and a description that contains the ActionButton name (Pressed_on, Released_off, Double_on, etc.)

Additional information

I have been using this as a custom quirks for a while. I have two dimmer switches DM2500ZB dimmer switches and I'm emulating a 3-way dimmers with the downstairs dimmer using an HA automation to control upstairs dimmer that has the stairs lights connect to it. It works fine.

I also have two SW2500ZB, the events are also sent as expected.

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

@bassdr bassdr force-pushed the sinope-sw2500zb-press-release-events branch 2 times, most recently from 1037865 to f9df3d8 Compare October 17, 2024 04:59
Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.41%. Comparing base (de3643c) to head (f922d14).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3438      +/-   ##
==========================================
+ Coverage   89.40%   89.41%   +0.01%     
==========================================
  Files         309      309              
  Lines       10014    10027      +13     
==========================================
+ Hits         8953     8966      +13     
  Misses       1061     1061              

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

@bassdr bassdr force-pushed the sinope-sw2500zb-press-release-events branch 2 times, most recently from da1ebbc to 14de93c Compare October 17, 2024 05:12
@bassdr
Copy link
Contributor Author

bassdr commented Oct 17, 2024

@claudegel FYI.

@bassdr bassdr force-pushed the sinope-sw2500zb-press-release-events branch 3 times, most recently from bae08c9 to 35f991a Compare October 18, 2024 21:56
@TheJulianJES TheJulianJES changed the title zhaquirks SINOPE SW2500ZB/DM2500ZB: Send all button press events Send all button press events for Sinope SW2500ZB/DM2500ZB Oct 19, 2024
@bassdr bassdr force-pushed the sinope-sw2500zb-press-release-events branch from 35f991a to 5ee1785 Compare October 19, 2024 12:36
@bassdr bassdr force-pushed the sinope-sw2500zb-press-release-events branch from 7e5fd50 to 3cab468 Compare October 22, 2024 02:13
@bassdr
Copy link
Contributor Author

bassdr commented Oct 22, 2024

I've tested my latest changes in HA and it works fine.

@bassdr bassdr force-pushed the sinope-sw2500zb-press-release-events branch from 3cab468 to ec0d580 Compare October 23, 2024 01:24
bassdr and others added 3 commits October 25, 2024 17:41
…utton events in order to properly support short and long press events.

Also added the pressed button in the event arguments to simplify automations processing it.
…uments of the `zha_event`: Added "description" containing the ButtonAction name.

Got rid of deprecation warnings in test_sinope.py
@bassdr bassdr force-pushed the sinope-sw2500zb-press-release-events branch from b15c372 to f922d14 Compare October 25, 2024 21:47
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.

Looks good. Thanks.

@TheJulianJES TheJulianJES merged commit f50a2de into zigpy:dev Oct 26, 2024
9 checks passed
@bassdr bassdr deleted the sinope-sw2500zb-press-release-events branch October 26, 2024 15:33
@ckm2k1 ckm2k1 mentioned this pull request Nov 11, 2024
3 tasks
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