Smart Living Experience

How to improve Xiaomi/Aqara human motion sensors in Home Assistant

Since I published the tutorial to improve the refreshment of Xiaomi and Aqara sensors to notify every 5 seconds their state of movement, although, there was a catch that is what today I'm going to show you how to solve.


Although the sensors send the status (in case of detecting movement) every 5 seconds, stop detecting activity continue to notify every minute and a half, giving the same Xiaomi motion sensor and Aqara human motion sensor (which has luminosity).

Image result for aqara motion sensor

After a while searching, since I remembered that there was option in the Home Assistant sensors of being able to put them a time in which if there is no notification of state, they changed, but, very to my regret, it was removed on the part of Home Assistant already some versions ago. Luckily, it seems that many more people have made the improvement in Xiaomi sensors and that is why since the project Zigbee2mqtt have put the option to receive the state "without movement" after the seconds we want.


Timeout time of the improved Xiaomi or Aqara human motion sensor

Once we have done the modification following the tutorial I published to modify the motion sensors Xiaomi or Aqara, we will have to go inside the zigbee2mqtt configuration, that if you have followed the tutorial I published, you should have it in /opt/zigbee2mqtt/data/configuration.yaml, so we will write:

nano /opt/zigbee2mqtt/data/configuration.yaml

Once inside the configuration, before the section "devices:", we must put:

device_options:

    occupancy_timeout: 20

The number 20 indicates the number of seconds. It must be something like this:

Now, it would be time to restart our zigbee2mqtt server to check if it works. For it, we put the command:

sudo systemctl restart zigbee2mqtt

If we activate any motion sensor, it should return the "occupancy: false" when passing the seconds configured in the previous points, which in our case have been 20 seconds.

If everything has gone well, we can conclude the tutorial, if this configuration affects all sensors equally, but, if for some reason you want to make it affect the sensors differently, you can configure within each device the parameter "occupancy_timeout" remaining so:

In this way the sensors will return to their "no movement" state at different times.