Xiaomi Aqara Cube triples my actions and automation

perhaps I’m doing something wrong but I’m running HA 0.85.1 on my RPi3b+ (running raspbian and docker).

I have a simple automation to report action_type and action_value (if any) using following code:

alias: Aqara Cube Living
trigger:
- platform: event
  event_type: xiaomi_aqara.cube_action
  event_data:
    entity_id: binary_sensor.aqara_cube_living
action:
- service: telegram_bot.send_message
  data_template:
    parse_mode: 'html'
    message: >
      {{ trigger.event.data['action_type'] }}, {{ trigger.event.data['action_value'] }}

Weird thing is that I receive every action three times:

HA, [21.01.19 15:10]
tap_twice,

HA, [21.01.19 15:10]
tap_twice,

HA, [21.01.19 15:10]
tap_twice,

HA, [21.01.19 15:10]
flip90,

HA, [21.01.19 15:10]
flip90,

HA, [21.01.19 15:10]
flip90,

HA, [21.01.19 15:10]
flip180,

HA, [21.01.19 15:10]
flip180,

HA, [21.01.19 15:10]
flip180,

HA, [21.01.19 15:11]
rotate, -55.5

HA, [21.01.19 15:11]
rotate, -55.5

HA, [21.01.19 15:11]
rotate, -55.5

HA, [21.01.19 15:11]
shake_air,

HA, [21.01.19 15:11]
shake_air,

HA, [21.01.19 15:11]
shake_air,

HA, [21.01.19 15:12]
alert,

HA, [21.01.19 15:12]
alert,

HA, [21.01.19 15:12]
alert,

HA, [21.01.19 15:12]
rotate, 23.5

HA, [21.01.19 15:12]
rotate, 23.5

HA, [21.01.19 15:12]
rotate, 23.5

HA, [21.01.19 15:13]
rotate, -34.5

HA, [21.01.19 15:13]
rotate, -34.5

HA, [21.01.19 15:13]
rotate, -34.5

Anyone else experiencing this? Bug?

I am experiencing this as well, although not three times, but only two times! Every action that I do on the cube arrives twice as an event in Home Assistant.

Very strange behavior, and haven’t figured it out yet. My next step is to enable the debug logging and see what’s going on… I’m suspecting the GW to submit the event twice, possibly because it has a duplicate entry on the integration with HA.

Are you also using the Xiaomi GW or another, self-built, Zigbee GW? Did you find anything interesting already?

My last resort will be to build in a timeout in the automation handling that prevents the second (or 2nd + 3rd in your case) event from triggering the automation.

Update: when I enable debug logging I don’t see any substantial information in home-assistant.log (perhaps I didn’t enable the right debugging / components). I did, however, run a tcpdump on the HA server and checked - the events are emitted only once by the Xiaomi GW.

Second update: a restart of Home Assistant made the problem go away! I’m totally confused.

I have two xiaomi gateways. Didn’t find anything yet and I’m not sure if it is still occruring. I assigned a single action to a turn_on turn_off or volume_up/volume_down service so the triple action didn’t mess things up. I did change one action to a toggle recently and that also works but if it’s still a triple action that makes sence. Would be worse in your case but you mention a restart of HA solved it? I’ve restarted HA several time and for (back than) it didn’t solve a thing.