Skip to content

generic_switch: double-counts pressCount (acts on both ShortRelease and MultiPressComplete) — ignore MultiPressComplete count≤1 #76

Description

@simons-plugins

Summary

matter_handlers/generic_switch.py on_node_event acts on both ShortRelease and MultiPressComplete for the same physical press, so every clean single press updates lastButtonEvent twice and bumps pressCount by 2. It can also briefly flicker the label.

Evidence (live, IKEA BILRESA node 0x2E, matter-server 1.1.2)

Every clean single wheel-click emits the pair:

ep3 initialPress           (ignored)
ep3 shortRelease        →  lastButtonEvent=shortPress, pressCount+1   (instant)
ep3 multiPressComplete  →  count=1 → shortPress again, pressCount+1   (~0.4–0.5s later)

So a 3-single-press test produced pressCount += 6, not 3. Confirmed across multiple runs (all totalNumberOfPressesCounted: 1).

Why it happens

A multi-press-capable GenericSwitch always closes a press sequence with MultiPressComplete carrying the total count, in addition to the per-release ShortRelease. The handler maps both, double-counting.

Proposed fix (author's call on exact approach)

The redundancy is specifically MultiPressComplete with count == 1 — it's just the formal close of a press ShortRelease already surfaced. Options:

  • Minimal: in the MultiPressComplete branch, ignore count ≤ 1 (return {}) — ShortRelease already produced shortPress. Keep count ≥ 2 → doublePress/triplePress/multiPress<N>. This removes the double-count and keeps single presses instant.
  • (Alternative: act on MultiPressComplete only and drop ShortRelease — gives authoritative counts but adds the ~0.5s multi-press-window latency to every press, and would also delay per-notch scroll responsiveness, so probably not preferred.)

Nuance to preserve

ShortRelease is what makes scrolling feel live (each notch = a ShortRelease); don't remove it. The minimal fix (drop MultiPressComplete count≤1) keeps scroll + single-click instant and only uses MultiPressComplete for genuine multi-counts.

Out of scope (device, not plugin)

Double-tap of the BILRESA wheel-press is unreliable in hardware (combined rotate+press → a fast double registers as a scroll, a single, or nothing — 0/4 clean doubles in testing). Single-click / long-press / scroll are reliable. Not fixable here; noted so it isn't chased.

Env

Plugin 2026.3.1, matter-server 1.1.2 (matter.js 0.17.4), Indigo 2025.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions