Xiaomi Human / Body / Motion Sensor - Timeout

Hi,

I found these logs. Can anyone help?

019-05-04 19:57:34 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi_aqara_custom
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/setup.py", line 156, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_aqara_custom/__init__.py", line 124, in setup
    xiaomi.discover_gateways()
  File "/config/deps/lib/python3.7/site-packages/xiaomi_gateway/__init__.py", line 108, in discover_gateways
    discovery_retries, self._interface,
UnboundLocalError: local variable 'discovery_retries' referenced before assignment
2019-05-04 19:58:28 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi_aqara
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/setup.py", line 156, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/xiaomi_aqara/__init__.py", line 132, in setup
    xiaomi.discover_gateways()
  File "/config/deps/lib/python3.7/site-packages/xiaomi_gateway/__init__.py", line 108, in discover_gateways
    discovery_retries, self._interface,
UnboundLocalError: local variable 'discovery_retries' referenced before assignment

Hi All,

I rename value of DOMAIN in __init__.py to xiaomi_aqara_custom and HA is booting again. All my components name got changed though. Need to edit all my automations.

I’m getting these last bit of errors. No sure what it is but most of the sensors and stuff seems to be working. Anyone can help me troubleshoot these last bits? :slight_smile:

Error during setup of component xiaomi_aqara
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/setup.py", line 156, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/xiaomi_aqara/__init__.py", line 132, in setup
    xiaomi.discover_gateways()
  File "/config/deps/lib/python3.7/site-packages/xiaomi_gateway/__init__.py", line 108, in discover_gateways
    discovery_retries, self._interface,
UnboundLocalError: local variable 'discovery_retries' referenced before assignment

Hi,

I’m using both aqara and xiaomi motion sensors with decozn. I’ve made the hardware modification but it still refreshes every two minutes. Do i have to change something in config files? If so then what exactly?

I’m using Zigbee2Mqtt myself, and I have to change its config file or it won’t work.
Therefore I’m pretty sure you have to change a setting in Deconz in order for this to work.

In my Zigbee2Mqtt there is this setting: occupancy_timeout: 5

Yeah, the thing is that I cant find any config file for Deconz (I’ve added it throught integration).

I guess I might have to modify “core.entity_registry” but I dont want to experiment with it unless I know what exactly to do.

Google is your friend, friend :slight_smile:
I’m sure you are not the first one to try it.

Yeah, I know, but I’ve spent whole day googling it and did not find anything which could help :frowning:

still no update on this?

A few days ago I noticed that I had two gateways discovered in HA: xiaomi_aqara and xiaomi_aqara_custom
This happened after 0.92 release, with the new domain name for custom component - xiaomi_aqara_custom. Somehow HA also discovered the xiaomi_aqara and all the sensors and devices were added twice.
I tried to check the init.py code to see if I can find a solution, but my python skills sucks, so I had no luck with that.
So I decided to move to ziqbee2mqtt and I must say that everything works flawless with the hardware mod and occupancy_timeout option in ziqbee2mqtt. The only thing that I have to improve is the range if zigbee signal.

Same issue here with the duplication of every sensor. Anyone know why?

Hi, So I have now switched over to Deconz but also cannot find out anywhere how to change the motion sensor update time. Did you get anywhere?

Actually yes, I was about to write some short guide. I’m not at home at the moment so I’ll try to write it as precise as I remember :slight_smile:

Basically:

  1. Install Postman addon for chrome (or use other tool to send api reuqests)
  2. In deconz setings find something like “Open for other applications”
  3. In Postman send Post request: at http://hassioip:40850/api/ ; in body (raw) put: { “devicetype”: “my application” } it should rerutn you API key
  4. Go at http://hassioip:40850/api/apikey/sensors/ and find your sensor (it should be one or two digits)
  5. Go at http://hassioip:40850/api/apikey/sensors/sensornumber to check if it’s right one. It shoud have parameter like duration: 90
  6. Use Postman to send POST request at http://hassioip:40850/api/apikey/sensors/sensornumber /config ; in body (raw) put: {“duration”: 5} - where 5 is refresh time.
4 Likes

Awesome! This works perfectly. Thanks :slight_smile:

Many thanks @syssi, after mod 3 of my sensors and using your custom component, everything works perfect. I only had to hide the duplicated entities, but this is not a big deal. Great job mate!!

@syssi is there an updated version of custom component for this?

For those who use the xiaomi_aqara_custom component from @syssi and find all the entities duplicated.

First of all add to configuration.yaml

discovery:
  ignore: 
   - xiaomi_gw

xiaomi_aqara_custom:
  gateways:
    - host: xxx.xxx.xxx.xxx  # Gateway IP
    - mac: XX:XX:XX:XX:XX:XX # Gateway mac address
      key: xxxxxxxxxxxxx     # Lan Access Password

Then remove all duplicates entities and restart HA

Regards

1 Like

I would be happy about a copy of a (maybe reduced) .storage/core.entity_registry file. This entries will give a hint what’s going wrong here (in case of duplicates).

I don’t have duplicates, as custom component doesn’t work for me since 0.92. I cannot figure out what I must change in order for it to start working again?

Could you explain why your custom component is called xiaomi_aqara_custom? Normally the custom component should override the official component.

FYI, restarting Deconz resets this to 90, built into Deconz, not found a way around it yet.

I am thinking of using node red to make a flow, whenever its restarted wait 2mins then send all the requests automatically.