HA doesn't get some events from XIaomi Gateway

Hi Guys,
I have HA installed on RPI.
Last week I decided to integrate Xiaomi gateway and sensors (Door sensor, Motion sensor, Button, Temp sensor) to my HA system.
I configured the configuration.yaml
file like this:
sensor:
xiaomi_aqara:
discovery_retry: 15
gateways:

  • host: 192.168.1.234
  • key: XiaomiGatewayKey

After restart I can see all the sensors&Buttons on HA.
Sometimes, Some of the events doesn’t get to HA, I configured the logger section like this:
logger:
default: critical
logs:
xiaomi_aqara: debug
xiaomi_gateway: debug
homeassistant.components.xiaomi_aqara: debug

For example, for long press the the Xiaomi button the gateway should sent two multicast events:

  1. long_click_press
  2. long_click_release

And for opening and close the door it should send two more multicast events:

  1. open
  2. close

As you can see in the attached log file, sometimes I get the events and sometimes I don’t (for single and double click the button should send only on muticast events, Sometime I get them and someties I don’t):
2018-10-15 06:22:20 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {‘sid’: ‘158d0001a04236’, ‘cmd’: ‘report’, ‘model’: ‘magnet’, ‘short_id’: 3469, ‘data’: ‘{“status”:“open”}’}
2018-10-15 06:22:20 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> : {‘status’: ‘open’}
2018-10-15 06:26:21 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {‘sid’: ‘158d0001a04236’, ‘cmd’: ‘report’, ‘model’: ‘magnet’, ‘short_id’: 3469, ‘data’: ‘{“status”:“open”}’}
2018-10-15 06:26:21 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> : {‘status’: ‘open’}
2018-10-15 06:26:32 DEBUG (Thread-23) [xiaomi_gateway] MCAST (heartbeat) << {‘sid’: ‘158d0001a04236’, ‘cmd’: ‘heartbeat’, ‘model’: ‘magnet’, ‘short_id’: 3469, ‘data’: ‘{“voltage”:2985,“status”:“close”}’}
2018-10-15 06:26:32 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> : {‘status’: ‘close’, ‘voltage’: 2985}

2018-10-15 05:53:25 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Switch_158d0001a23375: off>: {'status': 'long_click_press'}
2018-10-15 05:53:33 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'sid': '158d0001a23375', 'cmd': 'report', 'model': 'switch', 'short_id': 44914, 'data': '{"status":"double_click"}'}
2018-10-15 05:53:33 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Switch_158d0001a23375: on>: {'status': 'double_click'}
2018-10-15 05:54:27 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'sid': '158d0001a23375', 'cmd': 'report', 'model': 'switch', 'short_id': 44914, 'data': '{"status":"long_click_press"}'}
2018-10-15 05:54:27 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Switch_158d0001a23375: on>: {'status': 'long_click_press'}
2018-10-15 05:54:28 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'sid': '158d0001a23375', 'cmd': 'report', 'model': 'switch', 'short_id': 44914, 'data': '{"status":"long_click_release"}'}
2018-10-15 05:54:28 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Switch_158d0001a23375: on>: {'status': 'long_click_release'}

The Gateway and HA are both on wifi range, Same subnet with static IP address.

Can someone help me with this issue?

Thanks a lot,
Liran.