Xiaomi Human / Body / Motion Sensor - Timeout

Hi,

I read almost all discussion and came with this steps that need to be done:

  1. Mod the sensor
  2. Create the /custom_components/xiaomi_aqara/ folder
  3. Put init .py and binary_sensor.py in the /custom_components/xiaomi_aqara/ folder
  4. NO changes to configuration.yaml to use the custom component?
  5. Reboot HA

Two questions:

  1. After this motion will be triggered every 5 second in ha yes ?
  2. Is there any other way to do this without this hardware mod ?

@syssi Any update on how to get this working with xiaomi gateway?

I don’t understand your question. What are you looking for?

I have modded the sensor, and it has been working fine until I update HomeAssistant to 0.93. Is there some new config I need to update for custom component?

Still works for me, I’d check all your steps again.

HI All, after some test on the unmodded version. Here is hte time line of the sensor.
Consider 0 sec when motion detected
0 - ha shows motion changed to on
60 - 120 motion sensor tried to detect motion.
120 if there motion detect - the motion extend another 60 sec.if no motion, ha will change to off.
180 ha shows off if no motion after 120 sec. if there is motion, the timer extend every 60 sec
eg
at 130 sec, if there is motion 130+60 = 190. ha turn off at 190 sec.

hopefully this helps writing automation.
I try to highlight, there is no changes of state between 120 and 180 .
if no motion at 60 -120 it is off. if there is motion, it will extend to 180.

@syssi First of all, thank you very much for this custom component.

Unfortunately it’s not working for me.

To resume what I have done so far:

  1. Modded one (two others are not modded, connected to the same gateway) of my aqua sensors (I can see in the Xiaomi Home app that the mod worked)
  2. created a folder ‘custom_components’ in ‘config’ folder
  3. created a folder ‘xiaomi_aqara’ in ‘custom components’ folder
  4. uploaded binary_sensory.py and init.py from ‘https://github.com/syssi/home-assistant/tree/feature/xiaomi-aqara-modded-motion-sensor/homeassistant/components/xiaomi_aqara’ to ‘xiaomi_aqara’ folder
  5. restarted home assistant

Is this procedure correct or did I anything wrong?
There is just no change after doing this. The sensors are still working as before :frowning:

this is btw. my log file (maybe it helps):

INFO:2019-08-20 11:38:39,953:hass_configurator.configurator:127.0.0.1 - "GET /api/listdir?path=. HTTP/1.1" 200 -
INFO:2019-08-20 11:38:39,961:hass_configurator.configurator:127.0.0.1 - "GET / HTTP/1.1" 200 -
172.30.32.2 - - [20/Aug/2019:11:38:39 +0200] "GET /api/listdir?path=. HTTP/1.1" 200 4728 "http://hassio.local:8123/api/hassio_ingress/-1e11RGHyBG6gURRXg8KqEFDo0-Z8ZmMH6rSKOKNz08/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15"
172.30.32.2 - - [20/Aug/2019:11:38:40 +0200] "GET / HTTP/1.1" 200 45584 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15"
INFO:2019-08-20 11:38:40,568:hass_configurator.configurator:127.0.0.1 - "GET /api/file?filename=/config/custom_component/xiaomi_aqara/binary_sensor.py HTTP/1.1" 200 -
172.30.32.2 - - [20/Aug/2019:11:38:40 +0200] "GET /api/file?filename=/config/custom_component/xiaomi_aqara/binary_sensor.py HTTP/1.1" 200 18065 "http://hassio.local:8123/api/hassio_ingress/-1e11RGHyBG6gURRXg8KqEFDo0-Z8ZmMH6rSKOKNz08/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15"
INFO:2019-08-20 11:38:44,275:hass_configurator.configurator:127.0.0.1 - "GET /api/file?filename=/config/home-assistant.log HTTP/1.1" 200 -
172.30.32.2 - - [20/Aug/2019:11:38:44 +0200] "GET /api/file?filename=/config/home-assistant.log HTTP/1.1" 200 155 "http://hassio.local:8123/api/hassio_ingress/-1e11RGHyBG6gURRXg8KqEFDo0-Z8ZmMH6rSKOKNz08/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15"
INFO:2019-08-20 11:38:50,579:hass_configurator.configurator:127.0.0.1 - "POST /api/save HTTP/1.1" 200 -
172.30.32.2 - - [20/Aug/2019:11:38:50 +0200] "POST /api/save HTTP/1.1" 200 103 "http://hassio.local:8123/api/hassio_ingress/-1e11RGHyBG6gURRXg8KqEFDo0-Z8ZmMH6rSKOKNz08/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15"
INFO:2019-08-20 11:38:50,627:hass_configurator.configurator:127.0.0.1 - "GET /api/listdir?path=/config HTTP/1.1" 200 -
172.30.32.2 - - [20/Aug/2019:11:38:50 +0200] "GET /api/listdir?path=/config HTTP/1.1" 200 4852 "http://hassio.local:8123/api/hassio_ingress/-1e11RGHyBG6gURRXg8KqEFDo0-Z8ZmMH6rSKOKNz08/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15"

You spelt aqara wrong when you created your folder in custom_components.
Not sure whether this is your issue though.

Thanks @miles.beattie

Unfortunately it was typed wrong here but correct in home assistant.
So issue still exists…

@syssi Any chance that you have a look at my issue?

In the meantime I also tried to do the following things to get the issue solved (without access).

  • remove the sensor from the entity list and restart HA
  • add all files of your folder to the xiaomi_aqara folder (and not only init.py and binary_sensor.py)

So now I guess that there are only two options left:
a) I need to mod all my sensors?
b) I need to change xiaomi_aqara to xiaomi_aqara_custom and ignore the stock config

Anything from your side to help?

I need some time to overhaul the patch / to check what’s going on here.

1 Like

Thanks for your reply and your initiative.
Looking forward to the patch :wink:

In the meantime I have madded also the other two motion sensors (= now all motion sensors in my system are hardware modded).

I can see that it works in the mi home app.
Unfortunately still not in HA.

As you can see in the logs, your custom component will be used (no error in logs).

Is it really working for anyone here (latest HA)?
Imho my HA system is not very very complex currently…

1 Like

Oh boy im looking for a fix for this as well. Having to wait for 60 or 90 secounds every time makes me go NUTS

I´m getting this error
2019-08-30 18:50:29 ERROR (SyncWorker_2) [homeassistant.loader] Error parsing manifest.json file at /config/custom_components/xiaomi_aqara/manifest.json: Expecting value: line 7 column 1 (char 6)

Any help?

solved. it was my fault copiying the files. Works perfect!!!

did you get it to work on the latest version of home assistant 0.98.2

Maybe I overlooked something browsing through all 327 posts but I have a few questions.

  1. Is it correct understood that the timeout can ONLY be changed by modifying the sensor as described? The reason why I ask is because I see some of you who uses {“duration”: 5} to change the refresh time but this is not usable in the long run because it gets back to default setting after a restart or?
  2. I’m using the ConBee2 as gateway - do I still need to create the /custom_components/xiaomi_aqara/ folder with the init.py and binary_sensor.py or is that only applicable when you have the Aqara gateway?

I read almost all comments but some them are not relevant anymore because of some software updates. My case is that my hall or bathroom light does not power on every time. I can say its working 8-9 from 10 but that 1-2 times are freaking me out. Here is my automation.

Hardware:

  • Rasberry Pi 3
  • CC2531 USB stick

Software:
HassIO 0.98.2
HassOS 2.12
zigbee2mqtt 1.5.1.2

My general question is there known a good way to troubleshoot to find which is the cause of the issue. I tried to watch the logs without success of any problems.

  • Link quality
  • Sensors itself
  • HASS
  • zigbee2mqtt
  • CC2531 USB stick

I already plan to increase range with router CC2530

For now, I cannot catch what is the cause because of random behavior.
’Whenever the “robot” is pleased to serve you he is doing it perfectly’

  #Hall light
  - alias: Turn on hall light at 100% when there is movement
    trigger:
      platform: state
      entity_id: binary_sensor.corridor_occupancy_occupancy
      to: 'on'
    condition:
      condition: numeric_state
      entity_id: sensor.corridor_occupancy_illuminance
      below: '15'
    action:
      service: homeassistant.turn_on
      entity_id: light.hall
      data:
        brightness_pct: 100
  - alias: Turn on hall lights at 5% at night
    trigger:
      platform: state
      entity_id: binary_sensor.corridor_occupancy_occupancy
      to: 'on'
    condition:
      condition: time
      after: '00:30'
      before: '05:00'
    action:
      service: homeassistant.turn_on
      entity_id: light.hall
      data:
        brightness_pct: 5
  # Turn off ligts when there is no movement - PIR have 1 min sleep which does not measure
  - alias: Turn off hall light 2 minutes after last movement
    trigger:
      platform: state
      entity_id: binary_sensor.corridor_occupancy_occupancy
      to: 'off'
      for:
        minutes: 2
    action:
      service: homeassistant.turn_off
      entity_id: light.hall

Same thing happens to me too!
I thought it is something with my automation, but I’m using entity controller for my light’s , not automation… So it’s probobly becouse of hardware mod?