Intercept IKEA BILRESA triggers and replace ZHA events - #4991
Conversation
long_press (DIM_UP/DIM_DOWN): - IkeaBilresaLevelControl was intercepting move/move_with_on_off commands without emitting any ZHA event, so the device trigger never fired. Now emits move_up_press / move_down_press synthetic events. - Trigger map updated to match the new named commands (no PARAMS). double_press (DIM_UP/DIM_DOWN): - ZHA's device trigger layer cannot match events that require PARAMS (broken in HA 2026.5.x). Added IkeaBilresaScenesCluster which intercepts the press command (0x0007) and emits double_press_dim_up / double_press_dim_down as param-free named events. - Trigger map updated to match the new named commands (no PARAMS). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #4991 +/- ##
=======================================
Coverage 93.07% 93.08%
=======================================
Files 401 401
Lines 13306 13317 +11
=======================================
+ Hits 12385 12396 +11
Misses 921 921 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ents Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
I have seen the error but have not digging in it then have testing firmware update of IKEAs gen 4 devices also Bilresa Dual looks working OK only the errors then adding automation and they have fixing one bug that was making commands not working OK from button 1 in the test and latest firmware in Thread mode. Do you have getting one scroll wheel ? Great work done !!! |
|
@MattWestb IKEA E2490 BILRESA Scroll Wheel — Home Assistant Blueprint https://gist.github.com/MacBassett/76c3e64287c3b58720639b04915abc7e |
| class IkeaBilresaScenesCluster(ScenesCluster): | ||
| """Scenes cluster for BILRESA: emits distinct events for double-press up/down. | ||
|
|
||
| Replaces PARAMS-based matching (broken in ZHA's device trigger layer) with |
There was a problem hiding this comment.
If this is really broken in ZHA or HA, we should fix that, instead of working around it here and sending different events.
There was a problem hiding this comment.
Agreed — fix is now in HA core: home-assistant/core#170483. See the comment above for the full analysis of why PARAMS matching fails (extra fields from CommandSchema.as_dict() cause PREVENT_EXTRA to reject the event).
IkeaBilresaScenesCluster is explicitly marked as a workaround in the PR description and can be removed once the core fix ships. IkeaBilresaLevelControl is a separate quirk bug (move commands were swallowed without emitting any event) and needs to stay.
|
Can you listen to |
|
Without custom quirk but with latest ZHA: |
|
@TheJulianJES @MattWestb — MattWestb's raw event confirms the root cause. The trigger's I've submitted a fix to HA core: home-assistant/core#170483. It strips On the two changes in this PR:
|
TheJulianJES
left a comment
There was a problem hiding this comment.
I'm sorry, but most of what your AI seems to be writing is completely false.
I think this is just an issue with cluster_id being a zigpy type and not a plain int. But that only causes an issue with voluptuous if PARAMS is also provided, as we only build a schema in Core here then: https://github.com/home-assistant/core/blob/2e738e22d2475aa0d905f97bdd76bc276067a5f2/homeassistant/components/homeassistant/triggers/event.py#L77-L88 (where voluptuous is strict)
To verify this, please replace CLUSTER_ID: LevelControl.cluster_id with CLUSTER_ID: 8, and see if the device triggers start working then.
If that's the case, we'd just need to convert the zigpy types to primitive ones. I guess we could either do that in ZHA (zha.zigbee.device:get_device_automation_triggers), in HA Core (homeassistant.components.zha.device_trigger), or possibly even in zigpy for v2 quirks only in zigpy.quirks.v2:recursive_freeze – I think one of the first options is better though.)
Proposed change
Fix
remote_button_long_pressandremote_button_double_pressdevice triggers for the IKEA BILRESA 2-button remote (09B9) — both never fired, onlylong_releaseworked.long_pressfix (IkeaBilresaLevelControlinzhaquirks/ikea/__init__.py):The cluster was intercepting
move/move_with_on_offcommands and storing direction state, but never emitting a ZHA event. Addedmove_up_press/move_down_presssynthetic event emission in the move handler. Trigger map inbilresa2btn.pyupdated to match the new named commands (removingPARAMS).double_pressfix (IkeaBilresaScenesClusterinzhaquirks/ikea/__init__.py):ZHA's device trigger layer cannot match triggers that require
PARAMSdue to a bug in HA core:CommandSchema.as_dict()includes an inheritedcommandfield not present in the quirk'sPARAMSdefinition, causing voluptuousPREVENT_EXTRAto reject the event. A fix has been submitted to HA core in home-assistant/core#170483.As a workaround (and to support HA versions before that fix ships),
IkeaBilresaScenesClusteremitsdouble_press_dim_up/double_press_dim_downas param-free named events — the same no-PARAMSpattern already used bylong_release. Once the core fix is merged and released, this class can be removed andbilresa2btn.pyreverted to useCOMMAND_PRESS+PARAMS.Additional information
Tested on real hardware (IKEA BILRESA 09B9, HA 2026.5.x, ZHA). All 8 device trigger types verified working after the fix.
Device diagnostics
Not included — this PR fixes existing clusters for an existing quirk, no new device registration.
Checklist
pre-commitchecks pass / the code has been formatted using Black