Skip to content

Update button event types to the revised standard - #958

Merged
TheJulianJES merged 1 commit into
devfrom
zigpy-bot/button-event-types
Oct 26, 2026
Merged

TheJulianJES merged 1 commit into
devfrom
zigpy-bot/button-event-types

Conversation

@zigpy-review-bot

@zigpy-review-bot zigpy-review-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Note

Part of the standardized button event entities work tracked in #961: all PRs, design choices and alternatives, open decisions.

Summary

home-assistant/architecture#1502 (approved 2026-10-15) amends the standard button event types from home-assistant/architecture#1377. It splits them into a physical layer (press_start, press_end) and a gesture layer (long_press_start, long_press_end, single_press, multi_press), renames multi_press_end + multi_press_count to multi_press + press_count, and removes multi_press_ongoing. This updates the event platform's constants added in #864 to match.

Note

Matches home-assistant/core#188103 (approved, not merged yet), which updates Core's ButtonEventType to the approved proposal with the same names (single_press, multi_press, press_count). Core keeps MULTI_PRESS_ONGOING, MULTI_PRESS_END and ATTR_MULTI_PRESS_COUNT as deprecated until 2027.5.0; this PR removes them (see Compatibility).

Changes

  • ButtonEventType: add SINGLE_PRESS and MULTI_PRESS, remove MULTI_PRESS_ONGOING and MULTI_PRESS_END.

  • ATTR_MULTI_PRESS_COUNT (multi_press_count) becomes ATTR_PRESS_COUNT (press_count).

  • BaseEvent enforces the two button rules the proposal adds:

    • a button event entity may only declare multi_press together with single_press, so the button.pressed trigger stays exclusive wherever button.multi_pressed is offered;
    • a triggered multi_press must carry an integer press_count of at least 2.

    Both only apply to the button device class, like the existing doorbell check.

Compatibility

Nothing in ZHA or the quirks creates button event entities yet, and HA Core's ZHA event platform passes event types through as strings, so the old constants are removed here instead of deprecated like in Core. The Green Power PRs (#868 and the draft zigpy/zha-device-handlers#5273) only use press_start / press_end, which keep their meaning.

Testing

tests/test_platform_event.py covers the new types and both rules.

Follow home-assistant/architecture#1502: add single_press and multi_press
with press_count, remove multi_press_ongoing, multi_press_end and
multi_press_count. Button event entities may only declare multi_press next to
single_press, and a multi_press must carry a press_count of at least 2.
@zigpy-review-bot zigpy-review-bot added breaking change Breaking change (mainly for PRs) blocked Blocked on something outside our control new feature Adds new feature labels Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.22%. Comparing base (9d740ee) to head (0de6bcf).
⚠️ Report is 10 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #958   +/-   ##
=======================================
  Coverage   97.22%   97.22%           
=======================================
  Files          61       61           
  Lines       10676    10682    +6     
=======================================
+ Hits        10380    10386    +6     
  Misses        296      296           

☔ View full report in Codecov by Harness.
📢 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.

@puddly puddly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is fine without the rest of the PR stack

@TheJulianJES

Copy link
Copy Markdown
Contributor

@zigpy-review-bot Compare this PR with the proposed Core PR:

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator Author

Compared against home-assistant/core#188103 (head as of now, open and not a draft, approved by two Core reviewers).

What matches

  • Constants: single_press, multi_press and the attribute press_count are named identically in both, and both keep press_start / press_end / long_press_start / long_press_end unchanged.
  • Core's only consumer, ISY994, declares single_press together with multi_press and always emits press_count: 2 for multi_press. That satisfies both rules this PR adds, so Core's own integration would pass this validation.
  • ZHA's event platform only passes event types through as strings, and nothing else in Core's zha component references these constants, so the rename has no coupling to Core's release timing.

Differences

  • Deprecation: Core keeps MULTI_PRESS_ONGOING, MULTI_PRESS_END and ATTR_MULTI_PRESS_COUNT as deprecated until 2027.5.0, and keeps their translations. This PR removes them outright. That is fine here since no ZHA or quirks entity uses them yet, but the two enums will not be identical until Core drops them.
  • Enforcement: the two rules (multi_press only together with single_press; multi_press needs an integer press_count of at least 2) exist only in this PR. Core's EventEntity doesn't validate them, and its docstring only says to declare a type if its meaning holds for every event sent under that name. Neither rule is contradicted by Core, and neither fires for ISY994, but they are stricter than what Core checks.
  • Docstrings: both describe the physical vs gesture split; ZHA's one also states "none are mandatory" like Core's.

Status of this PR

The "kept as a draft until Core has updated its ButtonEventType" note in the body is now answerable: a Core PR exists and its names match, so nothing needs to change here. It is still a draft, and I left the body as is.

@TheJulianJES

TheJulianJES commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

(@zigpy-review-bot Also update #961 and all other related issues/PRs, including this if needed. Do review rounds where it makes sense.)

@puddly

puddly commented Oct 26, 2026

Copy link
Copy Markdown
Member

I've updated zigpy/zha-device-handlers#5273 to use press_start instead of press_end for Hue Tap remotes (they emit an event only on press and nothing on release).

@TheJulianJES
TheJulianJES marked this pull request as ready for review October 26, 2026 20:59
Copilot AI balanced review requested due to automatic review settings October 26, 2026 20:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The PR explicitly awaits Home Assistant Core’s matching ButtonEventType update, so final approval requires cross-project compatibility confirmation.

No open issues 🎉

What changed in this PR

Updates ZHA’s event platform to the revised standard button event types, separating physical button events from recognized gestures.

Changes:

  • Replaces the old multi-press types with single_press and multi_press, and renames the count attribute to press_count.
  • Requires button entities offering multi_press to also offer single_press, and validates multi-press counts as integers of at least 2.
  • Updates tests for the renamed types, validation failures, and exemption of non-button entities.
File Description
zha/​application/​platforms/​event/​const.py Defines the revised button event types and count attribute.
zha/​application/​platforms/​event/​__init__.py Enforces button-specific declaration and event validation rules.
tests/​test_platform_event.py Covers updated event types and both validation rules.

Review effort: Balanced

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator Author

Updated the bodies for home-assistant/core#188103:

The blocked label is still on this PR. I left it because the request didn't ask for label changes. Remove it if merging no longer waits for the Core PR.

The text went through two review rounds with an Opus reviewer: the first caught that this PR had just been un-drafted, the second was clean apart from a grammar nit. I skipped Copilot because no code changed.

@TheJulianJES TheJulianJES removed the blocked Blocked on something outside our control label Oct 26, 2026
@TheJulianJES
TheJulianJES merged commit 738ee63 into dev Oct 26, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Breaking change (mainly for PRs) new feature Adds new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants