Yoda-x/ha-zha-new

Can't add xiaomi aqara motion sensor

Closed this issue · 19 comments

When I execute zha_new.permit, then hold down the sensor's pair button for three seconds, I get:

018-09-17 07:00:50 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/zha_new.py", line 410, in async_device_initialized
self.custom_devices[device_model] = custom_module = get_custom_device_info(device_model)
File "/config/custom_components/zha_new.py", line 872, in get_custom_device_info
device_module = import_module("custom_components.device." + dev_func)
File "/usr/local/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/config/custom_components/device/lumi_sensor_motion_aq2.py", line 1, in
lumi_sensor_magnet.py
NameError: name 'lumi_sensor_magnet' is not defined
2018-09-17 07:00:56 WARNING (MainThread) [bellows.zigbee.application] Unexpected message send notification

Have the same sensor. Connected it successfully. Check that zigpy and bellows libraries versions from this repository downloaded by your HA to deps folder in HA config directory.

Ok, I might need some help with this. I'm running a docker image on ubuntu. So i logged into the homeassistant docker image. Then I installed git and ran: pip3 install git+https://github.com/Yoda-x/zigpy git+https://github.com/Yoda-x/bellows --u

Rebooted, executed zha_new.permit and I got the same error message without a device being set up.

In my folder: \config\deps\lib\python3.6\site-packages I have 4 folders: bellows, zigpy, bellows-0.7.0_Y.dist-info, and zigpy-0.1.2_Y.dist-info.

Is that what is supposed to be in there? There is also a file "bellows" in \config\deps\bin

In my folder: \config\deps\lib\python3.6\site-packages I have 4 folders: bellows, zigpy, bellows-0.7.0_Y.dist-info, and zigpy-0.1.2_Y.dist-info.

Is that what is supposed to be in there? There is also a file "bellows" in \config\deps\bin

Yes, dependencies is fine.
I'll describe the steps I performed after my dependencies was managed. Maybe it will help you too:

  1. Call zha_new.permit
  2. Press sensor's button for 3 seconds to reset it
  3. Press sensor's button for 3 seconds one more time
  4. Continue short pressing the button every second to avoid sensor sleep. Something about 30 times.
  5. See some errors in HA log
  6. Reboot HA
  7. Find sensor connected

Hmmm... no luck after trying that. The log looks like this after the reboot step:

018-09-18 07:09:41 WARNING (MainThread) [homeassistant.components.http] legacy_api_password support has been enabled. If you don't require it, remove the 'api_password' from your http config.
2018-09-18 07:09:47 WARNING (MainThread) [homeassistant.loader] You are using a custom component for zha_new which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2018-09-18 07:09:56 WARNING (MainThread) [bellows.uart] Reset success
2018-09-18 07:09:57 WARNING (MainThread) [bellows.zigbee.application] Unexpected response TSN=61 command=266 args=b'\x00\x00!%\x00'
2018-09-18 07:09:57 WARNING (MainThread) [zigpy.endpoint] [0xa8d2:1] Message on unknown cluster 0x0400
2018-09-18 07:09:58 WARNING (MainThread) [homeassistant.setup] Setup of config is taking over 10 seconds.
2018-09-18 07:10:00 WARNING (MainThread) [bellows.zigbee.application] Unexpected response TSN=62 command=266 args=b'\x00\x00!%\x00'
2018-09-18 07:10:00 WARNING (MainThread) [zigpy.endpoint] [0xa8d2:1] Message on unknown cluster 0x0400
2018-09-18 07:10:01 WARNING (MainThread) [bellows.zigbee.application] Unexpected response TSN=63 command=266 args=b'\x00\x00!%\x00'
2018-09-18 07:10:01 WARNING (MainThread) [zigpy.endpoint] [0xa8d2:1] Message on unknown cluster 0x0400
2018-09-18 07:10:03 WARNING (MainThread) [bellows.zigbee.application] Unexpected response TSN=64 command=266 args=b'\x00\x00!%\x00'
2018-09-18 07:10:03 WARNING (MainThread) [zigpy.endpoint] [0xa8d2:1] Message on unknown cluster 0x0400
2018-09-18 07:10:06 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/zha_new.py", line 404, in async_device_initialized
if (discovered_info[CONF_MODEL] is not None
KeyError: 'model'
2018-09-18 07:10:10 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
2018-09-18 07:11:11 WARNING (MainThread) [bellows.zigbee.application] Unexpected response TSN=65 command=266 args=b'\x00\x00!$\x00'
2018-09-18 07:11:11 WARNING (MainThread) [zigpy.endpoint] [0xa8d2:1] Message on unknown cluster 0x0400
2018-09-18 07:11:11 WARNING (MainThread) [bellows.zigbee.application] Unexpected response TSN=66 command=266 args=b'\x00\x00\x18\x01'
2018-09-18 07:11:11 WARNING (MainThread) [zigpy.endpoint] [0xa8d2:1] Message on unknown cluster 0x0406

Also tried pairing a xiaomi temperature sensor and had the same problem:

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/zha_new.py", line 408, in async_device_initialized
self.custom_devices[device_model] = custom_module = get_custom_device_info(device_model)
File "/config/custom_components/zha_new.py", line 861, in get_custom_device_info
device_module = import_module("custom_components.device." + dev_func)
File "/usr/local/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/config/custom_components/device/lumi_weather.py", line 1, in
lumi_sensor_magnet.py
NameError: name 'lumi_sensor_magnet' is not defined

please get the newest preview, this may load the right bellows/zigpy out of the box.
And the new code should do better during the device discovery.
I do not recommend docker for testing. A venv is much easier to maintain.
btw. never saw this error

I deleted the custom_components folder and made a new one with the files from the preview branch. I also deleted the zigbee.db and rebooted. Following the same procedure as before I receive the same errors:

2018-09-21 21:18:51 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/discovery.py", line 168, in scan_devices
results = await hass.async_add_job(_discover, netdisco)
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/discovery.py", line 194, in _discover
netdisco.scan()
File "/usr/local/lib/python3.6/site-packages/netdisco/discovery.py", line 57, in scan
self.ssdp.scan()
File "/usr/local/lib/python3.6/site-packages/netdisco/ssdp.py", line 41, in scan
self.update()
File "/usr/local/lib/python3.6/site-packages/netdisco/ssdp.py", line 89, in update
entry for entry in scan()
File "/usr/local/lib/python3.6/site-packages/netdisco/ssdp.py", line 225, in scan
for addr in zeroconf.get_all_addresses():
TypeError: get_all_addresses() missing 1 required positional argument: 'address_family'
2018-09-21 21:19:11 WARNING (MainThread) [bellows.zigbee.application] Unexpected response TSN=67 command=266 args=b'\x00\x00!!\x00'
2018-09-21 21:19:11 WARNING (MainThread) [zigpy.endpoint] [0x9eab:1] Message on unknown cluster 0x0400
2018-09-21 21:19:11 WARNING (MainThread) [bellows.zigbee.application] Unexpected response TSN=68 command=266 args=b'\x00\x00\x18\x01'
2018-09-21 21:19:11 WARNING (MainThread) [zigpy.endpoint] [0x9eab:1] Message on unknown cluster 0x0406

The error messages come from the netdisco component.
After you deleted the zigbee db you must pair the devices again.
Sofar I don't see any bad in the log

I am getting a similar error with the preview deps in hass.io V78
[quote]
Error doing job: Task exception was never retrieved

Traceback (most recent call last):
File "/config/custom_components/zha_new.py", line 408, in async_device_initialized
self.custom_devices[device_model] = custom_module = get_custom_device_info(device_model)
File "/config/custom_components/zha_new.py", line 861, in get_custom_device_info
device_module = import_module("custom_components.device." + dev_func)
File "/usr/local/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/config/custom_components/device/lumi_sensor_motion_aq2.py", line 1, in
lumi_sensor_magnet.py
NameError: name 'lumi_sensor_magnet' is not defined
[/quote]

@AlpineWhite : how you installed zha_new? I did not tested it on hassio. Just read that hassio is picky about requirements that are not hosted on pypi.
@bakazm : what is your platform? docker,venv,hassio,etc?

I am running on Home Assistant in a docker container on Ubuntu. My USB stick is a Linear HUSBZB-1. I believe the USB stick is working fine because ZHA-new is seeing activity from my Xiaomi Aquara motion sensor.

To pair the sensor I run zha_new.permit and then hold the button for 3 seconds. I push the button again about every second for 30 seconds to keep the device awake. On the home screen, zha_new shows the status as "Device init 00:15:8d:00:01:e0:58:49". However it never seems to get past that point.

The log shows this as soon as I execute zha_new.permit (before I try to pair):

Unexpected message send notification
7:25 AM deps/lib/python3.6/site-packages/bellows/zigbee/application.py (WARNING)

Then after or during pairing it says:

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/zha_new.py", line 413, in async_device_initialized
self.custom_devices[device_model] = custom_module = get_custom_device_info(device_model)
File "/config/custom_components/zha_new.py", line 876, in get_custom_device_info
device_module = import_module("custom_components.device." + dev_func)
File "/usr/local/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/config/custom_components/device/lumi_sensor_motion_aq2.py", line 1, in
lumi_sensor_magnet.py
NameError: name 'lumi_sensor_magnet' is not defined

How you installed zha_new?
Can you please verify the two file exists in the device dir

  • lumi_sensor_motion_aq2..py
  • lumi_sensor_magnet. py
    One should be a symlink to the other
    And you should see some python code if you open each of them.

I initially installed by adding the wget statements in place of the requirements in zha_new until you merged that pull.

The wget in requirements does now populate the deps folder with zigpy and bellows. I copied the custom_components folder via samba.

When looking through custom_component/devices I do see both files. Inside lumi_sensor_magnet.py is the code I am expecting. Inside lumi_sensor_motion_aq2.py I only see one line:
lumi_sensor_magnet.py

Out of curiosity, I copied the contents of magnet into motion_aq2 and now I have a motion sensor in my homeassistant without a reboot.

I installed zha_new by downloading the folder from github and copying the custom_components folder to my config folder. I added this to my configuration file.

zha_new:
usb_path: /dev/ttyUSB1
database_path: zigbee.db

Yes, both files exist in the device dir. Yes, the lumi_sensor_magney.py contains lots of code. The file lumi_sensor_magnet_aq2.py only contains the line "lumi_sensor_magnet.py".

please use git to clone the code. Downloading the code via wget or browser not creates the symlink.

lumi_sensor_magnet_aq2.py is a symlink to lumi_sensor_magnet.py.
This is the case for multiple files in the device folder

OK, looks like that fixed it. For future reference in case I need to do this again: I needed to brush up on my Alpine since it didn't come with git installed (apk add git), followed by "Git clone https://github.com/Yoda-x/ha-zha-new.git". It cloned it to a ha_zha_new folder so I copied it to the right location and rebooted. I paired a new xiaomi temperature sensor and it's working great. The motion sensor also showed up, but it's not updating... will toy with that later. Thanks!

Good to hear it's working now

closing issue