ZHA multiple events

Using ZHA I noticed multiple "zha_event"s come up for some actions - should I worry about it ?

any way to ensure I get every event once and reduce any noise that might cause automations to fire multiple times ?

i.e. these 2 events for same actions arrive consecutively

Event 13 fired 5:47 PM:
{
    "event_type": "zha_event",
    "data": {
        "unique_id": "0x059f:1:0x0006",
        "device_ieee": "00:15:8d:00:01:25:63:f6",
        "command": "click",
        "args": {
            "click_type": "double"
        }
    },
    "origin": "LOCAL",
    "time_fired": "2019-06-09T14:47:48.651971+00:00",
    "context": {
        "id": "7aa09b79085a44cd8c1ed7ed243a39b5",
        "parent_id": null,
        "user_id": null
    }
}
Event 12 fired 5:47 PM:
{
    "event_type": "zha_event",
    "data": {
        "unique_id": "0x059f:1:0x0006",
        "device_ieee": "00:15:8d:00:01:25:63:f6",
        "command": "click",
        "args": {
            "click_type": "double"
        }
    },
    "origin": "LOCAL",
    "time_fired": "2019-06-09T14:47:48.650747+00:00",
    "context": {
        "id": "98e2895163ad474e9bd142f4d4f7a7b2",
        "parent_id": null,
        "user_id": null
    }
}

I am also seeing this same behavior. Itā€™s causing me issues when I use toggle for lights, because I get multiple toggle events when trying to toggle a lamp or switch.

I feel that it started after I added to Zigbee devices that act as relays. (Smartthings Zigbee plug/outlet, and a single bulb)

Not sure how I can code around it as I am using the toggle to change the lamp status.

Is there any setting that can ignore events based on age? Maybe a Zigbee setting that can be enabled?

Still the same issue with my hue button (sometimes) and always with my IKEA Shortcut Button

Also have the same problem with an IKEA Symfonisk remote. Have you found a solution in the meantime?

Iā€™m also experiencing this issue and would love to know about any updates also. My newly acquired Aqara Wireless Mini Switch emits an event anywhere from 1 to 6 times per press, seemingly based on distance between the button and the USB dongle. I guess the button might be repeating the signal until it receives something like ā€œokay, I heard youā€ from HA?

I am a very new user to HA and experienced the same issues in this thread. The picture attached is what I did to resolve. Super Ugly I know, but its working. The function is a simple counting function starting at (1), this enables the traffic light.

  1. Once the button is pressed (button_single), it passes the fist zha_event, (toggling the lamp), increases the counter to (2), then disables the traffic light immediately, stopping all subsequent events for the same action to proceed.

  2. Once the lamp toggles a delay kicks in for 5 seconds, then resets the counter back to 1, enabling the traffic light. The delay allows the (sometimes) multiple zha events to proceed as can be seen using the debug node.

  3. The injection node initializes the counter at startup if node red resets or I reboot the host.

Note: The code for the counting function node was copied from examples I found on YouTube

If there is a cleaner way to resolve this issue, I would like to implement if someone could share

Having the same issue suddenly also with a Ikea Symfonsik. Worked for 6 month w/o issue and now suddenly issues 2 single press events within a few ms, switching my Sonos device off and directly back on. Assuming the button hasnā€˜t changed its behavior, it seems like Homeassistant ignored or couldnā€˜t process the second event before, but now it does.
Couldnā€˜t such short-term second events be prevented using the ā€žsingleā€œ parameter together with a parameterized ā€žgrace periodā€œ in which the same event would be ignored? So you could ignore the event for another say 200ms once it occurred.

Iā€™m seeing the same issue but with only one of several Aqara Mini switches.

The ZHA visualization shows the problematic switch taking a sub-optimal route through a distant Sonoff Zigbee power switch whereas the other switches are taking optimal routes.

The only workaround I can think of so far is to set the automation to ā€œmode: singleā€ and add a delay.

I used a delay to rate limit. I Just made the delay 1 msg every 8 seconds.

Hope that helps

1 Like

I think I have mine set to one message ever 150 ms.
That is enough to catch the extra events but still gives a functional device.

I also have this issue and to be honest it kept me from writing automations using the ZHA events. I noticed that I get one more event from my Tradfri remotes each time when I remove it and add it back to ZHA. That part can be reproduced pretty easily.

@vlaryn I tried your solution with the delay node, but for some reason the nodes were delayed on top of being rate limited. Also I could not set the rate below 1 second even with a change node in front that sets msg.rate.

But what worked for me was a function node with the following code:

var interval = 50; //in ms

var event_id = msg.payload.event.device_id 
  + '.' + msg.payload.event.command;

var last = context.get(event_id) || 0;
var now = Date.now();
context.set(event_id, now);

if (now - last > interval) {
  return msg;
} else {
  return null;
}

It generates an ā€œEvent IDā€ out of the device_id and the command, then it reads and stores the last time that the device fired that command in the using context.get / context.set and the ā€œEvent IDā€. Finally if the event happened within the configured interval it discards the message, otherwise it just passes it to the output.

This has the advantage that you can set a pretty low rate limit and that it still fires events from different devices or with different commands, even when they are fired near simoultaniously.

I altered the code that I found here: Rate Limiter (flow) - Node-RED

Thanks!

This solved it for me.