Standardized button event entities for ZHA remotes

Open
#961 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start with the linked ZHA stack, zigpy/zha#958 → #959, and the zha-quirks stack, #5480 → #5490; the issue says the quirks CI depends on a ZHA release containing #959. Read the architecture choices and open decisions, then review the relevant PRs and their per-device hardware confirmation notes. The work is complete when the standard event entities and device mappings are implemented, the stacks and version bumps are merged, and the open decisions are resolved.

Written by the indexing model from the issue text.

Description

entities quirks
Summary

ZHA remotes get one event entity per physical button, firing the standard button event types of home-assistant/architecture#1502 (approved 2026-10-15). Device automation triggers stay as they are. This issue tracks the PRs, the decisions made and still open, alternatives, and the pre-existing problems found while converting the quirks. Mention zigpy-review-bot in a comment here to have it make changes on the PRs.

Bot working notes for this work (private, maintainers only): HANDOFF.md in zigpy/review-bot-reviews, with the branch heads, design constraints, decisions, per-device research notes and how to update the stacked PRs.

PRs

All ZHA and zha-quirks PRs below are merged and released, in zha 2.5.0 and zha-quirks 2.5.0 (2026-11-25). The Home Assistant Core bump to both, with the ZHA entity names, is home-assistant/core#194481 (merged 2026-11-25, milestone 2026.12.0b0).

ZHA (stack: zigpy/zha#958 → zigpy/zha#959):

  • zigpy/zha#958: button event types updated to home-assistant/architecture#1502 (single_press, multi_press + press_count; removes multi_press_ongoing, multi_press_end, multi_press_count). Approved by puddly; uses the same names as home-assistant/core#188103 (merged 2026-11-02). Released in zha 2.4.0.
  • zigpy/zha#959: ZhaEventButton, which maps a device's zha_events to standard event types, matched like device trigger data, plus EntityPlatform.EVENT. Released in zha 2.5.0.

zha-quirks (all merged 2026-11-25, released in zha-quirks 2.5.0):

  • zigpy/zha-device-handlers#5480: QuirkBuilder.button_event() / ButtonEvent, discovery, test helpers, docs
  • zigpy/zha-device-handlers#5481: IKEA STYRBAR/BILRESA, SONOFF, Third Reality (v2)
  • zigpy/zha-device-handlers#5482: ubisys S1-R, S2, C4, Legrand (v2)
  • zigpy/zha-device-handlers#5813: ubisys D1/D1-R, merged 2026-11-25 after the input mode defaults fix zigpy/zha-device-handlers#5825; its hardware confirmation is still open
  • zigpy/zha-device-handlers#5483: Inovelli (v2)
  • zigpy/zha-device-handlers#5484: Aqara H1, frient, Candeo, ZunZunBee, SmartHjemmet, YOKIS, Sunricher (v2)
  • zigpy/zha-device-handlers#5814: Aqara W100 and Namron Simplify remote, whose quirks came to dev later (v2)
  • zigpy/zha-device-handlers#5820: skip a custom quirk that fails to register instead of failing ZHA's startup (bug fix on its own, split out of zigpy/zha-device-handlers#5485)
  • zigpy/zha-device-handlers#5485: v1 quirks support (CustomDevice.button_event_entities), merged 2026-11-25; the v1 PRs below build on it
  • zigpy/zha-device-handlers#5486: IKEA (v1)
  • zigpy/zha-device-handlers#5487: Xiaomi/Aqara (v1)
  • zigpy/zha-device-handlers#5819 (stacked on zigpy/zha-device-handlers#5487): no button event entities for the Aqara models that can't fire them (lumi.sensor_86sw1, lumi.sensor_86sw2, and button 2 / both of lumi.ctrl_ln1.aq1)
  • zigpy/zha-device-handlers#5488: Tuya (v1)
  • zigpy/zha-device-handlers#5489: CentraLite, icasa, Sinope, Terncy and others (v1)
  • zigpy/zha-device-handlers#5490: OSRAM, Sengled, Paulmann, ADEO, Aduro, Aurora (v1)
  • zigpy/zha-device-handlers#5821: Philips Hue (v1), split out of zigpy/zha-device-handlers#5490 since it changes the Philips remote cluster; merged 2026-11-25. It describes what changes if zigpy/zha-device-handlers#5002 (open) lands later

Device behaviour still to confirm (entities and event types left out until then): zigpy/zha-device-handlers#5815

Remotes and buttons still without button events, with the open PRs and issues that would add them: zigpy/zha-device-handlers#5850

Related, independent of the stack:

  • zigpy/zha-device-handlers#5809: the STYRBAR quirk drops the stray on it sends at the start of every arrow hold, which also fixes the On button's device trigger (merged)

Home Assistant Core:

  • home-assistant/core#188103: ButtonEventType updated to home-assistant/architecture#1502 (not ZHA-specific; merged 2026-11-02). Same names as zigpy/zha#958; Core keeps the old constants as deprecated until 2027.5.0. Docs (merged): isy994 home-assistant/home-assistant.io#49727, developer docs and blog home-assistant/contributors.home-assistant.io#118
  • Button triggers for event entities (not ZHA-specific): button.pressed home-assistant/core#190432, button.held with interval home-assistant/core#190686, button.hold_ended home-assistant/core#190787, all merged. They target every button event entity and fire on the declared types (button.pressed: single_press, else press_end, else press_start; button.held: long_press_start, else long_press_end; button.hold_ended needs both hold types).
  • button.is_being_held condition (home-assistant/core#191663, merged 2026-11-18): true while a button event entity's last event type is long_press_start, up to a 30 s hold timeout; entities that don't declare both long_press_start and long_press_end are skipped.
  • Multi press as a press_count option on button.pressed (home-assistant/core#191943, merged 2026-11-18): press_count defaults to 1 (unchanged behaviour); above 1 the trigger fires on multi_press events with a matching press_count, on event entities that declare multi_press. Docs: home-assistant/home-assistant.io#50462 (merged 2026-11-19).
  • ZHA entity names and the ZHA / zha-quirks 2.5.0 bump: home-assistant/core#194481 (merged 2026-11-25, milestone 2026.12.0b0) bumps ZHA and zha-quirks to 2.5.0 and adds the button event entity names of the branch zigpy-bot/zha-button-event-translations (the numbered and rocker names use the button_numbered and rocker_top / rocker_bottom keys ZHA already has for its Green Power switches)
  • ZHA and zha-quirks version bumps: zigpy/zha-device-handlers#5817 and zigpy/zha#1090 (both merged 2026-11-25) made each library require the other's 2.5.0, built from a dev commit until the release, with the zha device snapshots regenerated for the button event entities. Both 2.5.0 releases are out (2026-11-25): zigpy/zha-device-handlers#5829 (merged) builds zha-quirks against the released zha 2.5.0 again, and zigpy/zha#1094 (merged 2026-11-25) does the same for zha with the released zha-quirks 2.5.0, removing its uv override
Design choices and alternatives

The architecture choices below are proposals. They overlap with the Green Power work (zigpy/zha#868, zigpy/zha-device-handlers#5273), zigpy/zha#919 and the direct entity API in zigpy/zha-device-handlers#5410, so they are open to review; changing one mostly means reworking zigpy/zha#959, zigpy/zha-device-handlers#5480 and zigpy/zha-device-handlers#5485, while the per-device mappings in the other PRs carry over.

Architecture (open to review)
  • Where the matching lives. Chosen: a generic ZhaEventButton in ZHA (zigpy/zha#959); quirks only declare metadata that discovery maps to it, like button.Button or sensor.Sensor.

    • Alternative: entity classes in zhaquirks, like the Green Power quirk's own CommandEvent entity in zigpy/zha-device-handlers#5273, which listens to the device's Green Power command events.
    • Alternative: quirks create the entities directly through the entity API of zigpy/zha-device-handlers#5410 (adds_entity), instead of new builder metadata.
    • Earlier design notes: the RFC in zigpy/zha#419 sketched a builder .event(event_types=..., setup_triggers=...) and preferred quirk-defined event entity classes (listening to the cluster directly) registered by the quirk; zigpy/zha#864 then added the base platform without discovery, and zigpy/zha-device-handlers#5273 follows that preference for Green Power.
    • Converging: ZhaEventButton takes its matches as a constructor argument, so with zigpy/zha-device-handlers#5410 it can be added as .adds_entity(ZhaEventButton, endpoint_id=..., cluster_id=..., event_matches=[...]). .button_event() could then become a thin wrapper around that, or be replaced by it.
  • What the entity listens to. Chosen: the device's zha_events, matched like device trigger data, so a button event can reuse a trigger's data and fires for the same events as that trigger. It also covers what custom quirk clusters emit via zha_send_event.

    • Alternative: listen to the cluster commands or attribute reports directly (like the Green Power entity listens to its commands). That avoids the zha_event round trip and string command names, but needs a separate mapping for every custom quirk cluster that today only produces zha_events.
  • ZCL-anchored vs device-bound. Chosen: ZclPlatformEntity attached to one of the button's clusters (cluster_id / cluster_type are required in the API), because the quirks' entity discovery, metadata and prevent_default_entity_creation() / change_entity_metadata() are built around a cluster per entity.

    • Alternative: a device-bound PlatformEntity, which zigpy/zha#919 made possible. The button event API would then drop the cluster, but the quirk-side code paths that use entity.endpoint / targets_cluster need to handle device-bound entities first.
  • v1 quirks. Chosen: a button_event_entities class attribute (zigpy/zha-device-handlers#5485) that gives a v1 quirk a QuirkV2Device carrying only its entities; the device triggers stay on the class.

    • Alternative: convert the remote v1 quirks to v2 first, then use .button_event() everywhere. Planned as a later PR, which makes the attribute obsolete.
  • API shape. Chosen: one .button_event() call per physical button with a list of ButtonEvent(event_type=..., trigger=... | event_data=...); only standard ButtonEventTypes are accepted.

    • Alternative: derive event entities from the existing trigger dicts automatically. Rejected: trigger subtypes are not physical buttons (an IKEA on button is (SHORT_PRESS, TURN_ON) and (LONG_PRESS, DIM_UP)), and the event type depends on the device's timing, so every device needs its own mapping.
    • Alternative: allow integration-specific extra event types (the proposal's rule 8). Left out for now so typos fail and the entities stay standard; it can be added later.
Mapping (following home-assistant/architecture#1502)
  • One native event → one standard event, no timers. Events a quirk derives with a timer (Philips multi-press, Mija hold) are not mapped, The STYRBAR's stray on is dropped in the quirk instead, below the zha_event (zigpy/zha-device-handlers#5809), as Z2M and deCONZ filter it. The only state is the rule-7 bit: repeats (a repeated hold fires once) and while_held (a shared or unclassified release ends the hold).

  • Unconfirmed behaviour is left out. Adding an entity or event type later is not breaking, changing or removing one is. So an event type whose timing rests only on a deCONZ label or on inference (typically whether a hold is reported at the threshold or after release), and an entity whose basic press mapping is unclear, are left out until confirmed: zigpy/zha-device-handlers#5815 lists them with the test that settles each.

  • Philips: the quirk now also sends the native initial press and short release immediately, as new zha_events. This is additive: existing events and triggers are unchanged. Alternative: rework PhilipsRemoteCluster so the timer-derived events go away.

  • ubisys: S1-R, S2 and C4 are mapped for the inputs' factory configuration (push-button toggle); every mode the quirk can write gives the right event, one press_start per rocker flip, or nothing. The D1 is mapped in zigpy/zha-device-handlers#5813 (merged): the quirk's input mode select rewrote the other input from a wrong default (zigpy/zha-device-handlers#5812), fixed by zigpy/zha-device-handlers#5825. Later: read the configured input actions and adapt the entities.

  • Tuya TS004F dimmer: entities for both device modes, so one set is always idle. The smart button only gets its event (scene) mode entity; its command mode is left out, see zigpy/zha-device-handlers#5815.

  • Naming: unique_id_suffix button_<name> (button_both for "both buttons"); translation keys <name>_button, HA Core's button_numbered with {number} (and button_numbered_on / button_numbered_off), and rocker_top / rocker_bottom with {rocker}.

  • Skipped: cubes, vibration and motion sensors, rotary rotation, EchoStar doorbell (needs a doorbell entity), Insta NEXENTRO (mode set in the vendor app), Aqara ctrl_neutral (a click is one frame carrying the hold and the release; the open issue zigpy/zha-device-handlers#5856 reports it, with a tested custom quirk that tells the click frame apart and adds button events), Lutron dim buttons, Aqara H1/E1 command mode, OSRAM Lightify 4x and LDS CCT switch (triggers contradict Z2M/deCONZ), TRADFRI wireless dimmer and Inovelli VZM36 (no buttons).

Open decisions
  • Review of the architecture choices above (where the matching lives, what the entity listens to, ZCL-anchored vs device-bound, v1 support, API shape), in particular against the Green Power entities and the direct entity API of zigpy/zha-device-handlers#5410. The comment in zigpy/zha#959 explains why both how the entity gets its events and how it is created can change later without touching the quirks.
  • STYRBAR stray on: it comes at the start of every arrow hold, not after it; dropped in the quirk (zigpy/zha-device-handlers#5809), and press_end stays mapped for the On button.
  • OSRAM Switch Mini: named Up / Center / Down, as Z2M, deCONZ and the device do (zigpy/zha-device-handlers#5490).
  • Device-bound entities: drop cluster_id / cluster_type from the button event API once quirks can create device-bound entities (zigpy/zha#919 made them possible; zigpy/zha-device-handlers#5410).
  • Converting the v1 quirks to v2, after which button_event_entities becomes .button_event() calls.
  • Deprecating device automation triggers for remotes that have event entities, and when.
  • Doorbell entities (ring) for doorbell quirks such as the EchoStar bell.
  • Rotary controls: shared ZHA/Matter proposal in zigpy/backlog#84 (BILRESA wheel, Hue tap dial, Candeo knobs, Lutron Aurora, Aqara H1 knob, Tuya TS004F knob).
  • Holds reported at the threshold with no release (SONOFF SNZB-01 off, SYMFONISK gen2, SNZB-01M hold, ZBM5, Third Reality): long_press_start, per rule 6 of home-assistant/architecture#1502. The SNZB-01P and Third Reality holds map to it; the holds whose timing isn't confirmed on hardware (WB01 / CK-TLSR8656-SS5-01(7000), SNZB-01M, SYMFONISK gen2 firmware 1.0.012 dots) are left out until zigpy/zha-device-handlers#5815 settles them, and the ZBM5 gets single_press only. Investigated in zigpy/backlog#83 (closed).
Hardware confirmation

Each device PR lists the mappings that rest on an assumption (when a command is sent, whether a release follows every press, whether a hold repeats) under "Needs hardware confirmation". Reports from owners of these devices are welcome on the PRs. Debug logs of a short press, a double press and a hold are the most useful.

Pre-existing problems found (not changed by the PRs)
  • v2 quirk trigger data is frozen, turning lists into tuples, while zha_event args are lists. Unverified: HA's device trigger matching may then never fire for v2 triggers with list args, e.g. the Aqara H1 (ALT_SHORT_PRESS, BUTTON) trigger with ARGS: [].
  • QuirkBuilder.prevent_default_entity_creation() also removes the quirk's own entities on the matched endpoint and cluster (frient Smart Button works around it).
  • Legrand remotes: the long press triggers require rate: 255, but the 067773 sends 100; the double/triple (TURN_OFF, BUTTON_n) triggers have no endpoint and fire for any rocker.
  • ubisys: every input mode defaulted to Toggle in the quirk, while the factory defaults differ (S1 rocker, D1 "Dimmer single"). Fixed by zigpy/zha-device-handlers#5825 (merged 2026-11-25); devices ZHA set up before keep the cached Toggle value until they are removed and paired again (zigpy/zha-device-handlers#5825 describes the workaround).
  • Inovelli VZM30/VZM35: the triggers also fire for button events from endpoint 3 (Z2M ignores that endpoint).
  • CentraLite 3450-L key fob: triggers match a press command no OnOff client sends.
  • Sengled E1E-G7F: the dim triggers can't fire (the quirk sends plain list args); OSRAM Switch Mini (LONG_RELEASE, button_1) expects stop_with_on_off, the device sends stop; color up/down triggers of the Switch Mini don't match.
  • Sourcing & Creation EB-SB-1B: the short press trigger has no command, so it also matches attribute_updated and fires twice per press.
  • Aqara 86sw1/86sw2 share quirks with remotes but report presses as on/off attribute reports, which fire none of the triggers.
  • Attribute-based button quirks (Aqara event mode, ZunZunBee, SmartHjemmet) send a zha_event for read responses too, so a read at startup can replay the last press.
  • IKEA E1810: with a low appVersion answer from the bound device, arrow holds become repeated clicks (Z2M answers 99); what ZHA answers is unknown.
  • IKEA E1743 and RODRET end the hold of either dim button with the same stop command, and STYRBAR did so before firmware 2.4.5 (zigpy/zha-device-handlers#2028) and E1524/E1810 before 2.3.080 (zigpy/zha-device-handlers#2123), while (LONG_RELEASE, DIM_UP) is bound to stop_with_on_off and (LONG_RELEASE, DIM_DOWN) to stop. So on those remotes (before the fix below) a dim down release fired the dim up trigger and the dim down trigger never fired (zigpy/zha-device-handlers#2024). The button event entities are unaffected, since both releases match while the button is held. Fixed for the dim buttons by zigpy/zha-device-handlers#5496 (merged, released in zha-quirks 2.4.0), which tracks the direction like the BILRESA and open/close quirks already do and supersedes zigpy/zha-device-handlers#4433; the left/right arrows of E1810 and STYRBAR share one Scenes release the same way and still have no long release trigger.
  • The two IKEA/Tuya direction tracking clusters disagree on a stop without a seen move: the open/close remote fires stop_opening for a bare stop, the level control cluster fires nothing. The button_open / button_close entities of zigpy/zha-device-handlers#5486 take their long_press_end from these events, so a guessed direction would end a press that was never seen. Tracked in zigpy/zha-device-handlers#5581.
  • Quirks QuirkV2Device still accesses entity.endpoint on device-bound entities, which warns since zigpy/zha#919.
Related
  • OpenHomeFoundation/protocols-backlog#30 (overall tracking, Matter + ZHA)

  • zigpy/backlog#84 (rotary event entities for dials, knobs and scroll wheels)

  • home-assistant/architecture#1502, home-assistant/architecture#1377

  • zigpy/zha#864 (base event platform), home-assistant/core#183109 (ZHA event platform in Core)

  • zigpy/zha#868, zigpy/zha-device-handlers#5273 (Green Power buttons), zigpy/zha-device-handlers#5372 and zigpy/zha-device-handlers#5330 (Lutron Aurora)

  • zigpy/zha#594 (event entities firing the raw OnOff / LevelControl / Color command names, a different approach than the standard button types), home-assistant/core#183074 (ZHA event labels for the Lutron Aurora, closed unmerged)

Dominant language
Python
Stars
96
Forks
84
Avg merge
2d 4h
Merged PRs (30d)
30

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from zigpy/zha

All issues in zigpy/zha

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.