Xiaomi Human / Body / Motion Sensor - Timeout

@ZJAVA configuration.yaml or devices.yaml?

@syssi Since configuration for xiaomi gateway moved to integrations, how to enable this again?
I do have HW mod ofcourse, and it was working until now.

i’m in your same boat, last time home assistant changed something i was able to fix that in the python files but now i don’t have a clue on how to fix

Xiaomi Aqara Custom component is no longer working in last ha version.

The automation with the python script still works ! The Set state python script I mean is this one:

I successfully switched from @syssi custom_components to @critical2104 python script (i got the hardware mod on my sensors), now it works again!

A quick recap for anyone interested:

  • Enable python script component adding the string “python_script:” in your configuration.yaml

  • Create a folder named “python_scripts” in your home assistant folder

  • Get the python script file “set_state.py” linked in the quote @MiSSHeaDShoT reply and put it in the python_scripts folder

  • Create an automation like mine and adapt it to your needs:

  - alias: Xiaomi Sensor Fix
    trigger:
      - platform: state
        entity_id:
          - binary_sensor.bodysensor_cucina
          - binary_sensor.bodysensor_doccia
          - binary_sensor.bodysensor_entrata
          - binary_sensor.bodysensor_lavandino
        from: 'off'
        to: 'on'
        for: 00:00:05
    condition: []
    action:
      - service: python_script.set_state
        data_template:
          entity_id: "{{ trigger.entity_id }}"
          state: 'off'

Thank you guys for your help <3

edit: there’s a problem though: once the sensor correctly goes off after the custom time (like 5 or 10 seconds) it won’t turn on if triggered shortly after.
Did some tests and the sensor states are triggered correctly (checked in the xiaomi home app) but something is off with the python script, it works only the first time

4 Likes

I have migrated back to 0.111 just for this.

i did extensive tests and while the set_state python script works (it set the motion sensor off) and the modded sensor is effectively triggered every 5s, the automation won’t work after the first time and it goes like that:

  • Sensor is off
  • Sensor is triggered by movement, home assistant sensor state goes on
  • Python script force sensor state to off after n seconds
  • Home assistant state remain on off despite the modded sensor is triggered again (as seen from xiaomi home app logs)

Then i disabled the python script and the home assistant state remains on for 2 minutes, again like it’s totally ignoring the hardware mod of the sensor that, as i wrote before, is working perfectly.

So i think that home assistant python script alone can’t recognize the hardware mod without @syssi software mod that’s broken right now

1 Like

I have seen the same, this used to all work but now is broken, a shame as this used to be really handy for my automations.

Hoping there is a fix soon…

Here’s an AppDaemon app to to do the same.
Should be available on HACS in the next couple of days or you can install manually.

1 Like

thank you for the solution, but I’m getting the following error. the hassapi module, is it something that is exclusive to hassio\supervisor? I’m running HA as docker without supervisor component,

2020-08-25 22:16:55 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.aqara. Make sure all dependencies are installed
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/loader.py”, line 436, in _load_file
module = importlib.import_module(path)
File “/usr/local/lib/python3.8/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in _find_and_load
File “”, line 975, in _find_and_load_unlocked
File “”, line 671, in _load_unlocked
File “”, line 783, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/config/custom_components/aqara.py”, line 3, in
import hassapi as hass
ModuleNotFoundError: No module named 'hassapi’
2020-08-25 22:16:56 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.aqara. Make sure all dependencies are installed
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/loader.py”, line 436, in _load_file
module = importlib.import_module(path)
File “/usr/local/lib/python3.8/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in _find_and_load
File “”, line 975, in _find_and_load_unlocked
File “”, line 671, in _load_unlocked
File “”, line 783, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/config/custom_components/aqara.py”, line 3, in
import hassapi as hass
ModuleNotFoundError: No module named 'hassapi’
2020-08-25 22:16:56 ERROR (MainThread) [homeassistant.setup] Setup failed for aqara: Integration not found.

This is an AppDaemon app that is available in HACS. It is not a HA integration or custom component and can not be loaded as such.

See https://hacs.xyz/ and https://appdaemon.readthedocs.io/en/latest/INSTALL.html to install AppDaemon. Then you can install this app from the HA Community Store.

1 Like

Looking to buy some of these and do the hardware mod. Do they work with HA 0.114.4 and ZHA?

I plan on just doing a Node-Red flow to set the state of the sensor from on to off in order to allow the sensor to update the state again after 5 seconds.

Yes, they do. I’m using ZHA with a RaspBee II ZigBee shield: No issues

1 Like

Hi All,

I have set up Appdaemon 4 and set up appdaemon_aqara_motion_sensors integration.
Working with ZHA and tasmotized Sonoff ZigBee bridge.
Sensor is till on for 2 minutes.
Anyone having this working?
Am I missing something?

Thanks.

so there’s no way to fix the initial python script?

@syssi Is there going to be an update on this. I am still on 0.111 just for this.

Hi all,

what is the best way to reset the value to occupancy = no with hassio and node red? i dont find a good solution for me, can you give me a description of the solution?

Thank you

best regards

Mathias

do I have to insert the sd card to my pc to do this ? I have the sd card to my rpi3 and used file editor to find this folder but i couldnt find it

I don’t think you’ll be able to do this from the SD card. How did you install Home Assistant? Are you using HassIO?