Repository navigation
Update button event types to the revised standard - #958
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
puddly
left a comment
There was a problem hiding this comment.
I think this is fine without the rest of the PR stack
|
@zigpy-review-bot Compare this PR with the proposed Core PR: |
|
Compared against home-assistant/core#188103 (head as of now, open and not a draft, approved by two Core reviewers). What matches
Differences
Status of this PRThe "kept as a draft until Core has updated its |
|
(@zigpy-review-bot Also update #961 and all other related issues/PRs, including this if needed. Do review rounds where it makes sense.) |
|
I've updated zigpy/zha-device-handlers#5273 to use |
There was a problem hiding this comment.
🔵 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_pressandmulti_press, and renames the count attribute topress_count. - Requires button entities offering
multi_pressto also offersingle_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
|
Updated the bodies for home-assistant/core#188103:
The 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. |
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), renamesmulti_press_end+multi_press_counttomulti_press+press_count, and removesmulti_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
ButtonEventTypeto the approved proposal with the same names (single_press,multi_press,press_count). Core keepsMULTI_PRESS_ONGOING,MULTI_PRESS_ENDandATTR_MULTI_PRESS_COUNTas deprecated until 2027.5.0; this PR removes them (see Compatibility).Changes
ButtonEventType: addSINGLE_PRESSandMULTI_PRESS, removeMULTI_PRESS_ONGOINGandMULTI_PRESS_END.ATTR_MULTI_PRESS_COUNT(multi_press_count) becomesATTR_PRESS_COUNT(press_count).BaseEventenforces the two button rules the proposal adds:multi_presstogether withsingle_press, so thebutton.pressedtrigger stays exclusive whereverbutton.multi_pressedis offered;multi_pressmust carry an integerpress_countof at least 2.Both only apply to the
buttondevice 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.pycovers the new types and both rules.