Aqara motion problem

Hello, friends. I don’t speak English well, sorry for that.
I have installed home assistant in venv.
Everything worked well, but a few days ago, motion sensors began to malfunction. I have 4 sensors and they all work poorly.
I added a line to the config:

logger:
  default: info
  logs:
    xiaomi_gateway: debug

Then I saw that when a motion is detected, the xiaomi gateway sometimes sends the event “motion” and “lux”, and sometimes just “lux”:

2020-02-02 15:06:44 DEBUG (Thread-2) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'sensor_motion.aq2', 'sid': '158d0003f*****', 'short_id': 19236, 'data': '{"lux":"18"}'}
2020-02-02 15:06:44 DEBUG (Thread-2) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'sensor_motion.aq2', 'sid': '158d0003f*****', 'short_id': 19236, 'data': '{"status":"motion"}'}

and only “lux” event, when motion detected:

2020-02-02 15:08:03 DEBUG (Thread-2) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'sensor_motion.aq2', 'sid': '158d0003f*****', 'short_id': 19236, 'data': '{"lux":"16"}'}

It can work well for a while and detect motion every time, but then it starts to work badly again.
All other sensors and switches work well. I installed the home assistant on a new SD card with a clean config, but this failed. I removed the sensors from the gateway and reconnected them, but that didn’t help either. I don’t know what to do, maybe someone had this? Thanks.

What is the actual question? Doesn’t motion work? Or does lux not work?

If it is motion, it can only detect motion once every 2 minutes. It is hardware so nothing you can do about that. It basically means you can only have it trigger something once every 2 minutes.

Lux only updates whenever motion is detected on those aqaras (which makes lux completely useless on them).

When the sensor works well, when there is movement, it sends me a “motion” and “lux” event every 5 seconds. When it doesn’t work well, it sends me a “lux” event only. I will add a log, pay attention to the time please.
It doesn’t matter how much time has passed. I can be in the bedroom for an hour, then go to the kitchen and it won’t work, because he sent only the “lux” event.

Please look at this. He sent me the “motion” event after 5 seconds. It works well:

2020-02-02 15:45:57 DEBUG (Thread-2) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'sensor_motion.aq2', 'sid': '158d0003f*****', 'short_id': 19236, 'data': '{"lux":"12"}'}
2020-02-02 15:45:57 DEBUG (Thread-2) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'sensor_motion.aq2', 'sid': '158d0003f*****', 'short_id': 19236, 'data': '{"status":"motion"}'}
2020-02-02 15:46:02 DEBUG (Thread-2) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'sensor_motion.aq2', 'sid': '158d0003f*****', 'short_id': 19236, 'data': '{"lux":"13"}'}
2020-02-02 15:46:02 DEBUG (Thread-2) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'sensor_motion.aq2', 'sid': '158d0003f*****', 'short_id': 19236, 'data': '{"status":"motion"}'}

The problem was in the gateway. After a complete reset and removal of all devices, everything worked well.