Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xiaomi Door/Window sensor: in_clusters and out_clusters inverted in binary_sensor/zha ? #15477

Closed
jeromelaban opened this issue Jul 15, 2018 · 11 comments

Comments

@jeromelaban
Copy link

Home Assistant release with the issue:
0.73.1

Last working Home Assistant release (if known):
None, this never worked properly.

Operating environment (Hass.io/Docker/Windows/etc.):
Linux XXXX 4.13.0-43-generic #48-Ubuntu SMP Wed May 16 12:18:01 UTC 2018 i686 i686 i686 GNU/Linux

Component/platform:
zha, switch/zha and binary_sensor_zha

Description of problem:

  • An aqara door/window sensor is detected as a switch
  • It fails by default to rediscover the server upon server restart
  • The binary_sensor zha seems to have input and output clusters inverted

For the first one, it looks like this is inverted: jeromelaban@8916972#diff-3117ca794cf7c83eeb69e9ce82903ee6

As I understand, an Input cluster is an data input on the sensor itself, which means that a non-reporting switch would only have an output cluster.

Detection log:

homeassistant_1  | 2018-07-14 23:08:39 INFO (MainThread) [homeassistant.core] Bus:Handling <Event platform_discovered[L]: service=load_platform.switch, platform=zha, discovered=discovery_key=XX:XX:XX:XX:XX:XX:XX:XX-1-6>
homeassistant_1  | 2018-07-14 23:08:39 INFO (MainThread) [homeassistant.loader] Loaded switch.zha from homeassistant.components.switch.zha
homeassistant_1  | 2018-07-14 23:08:57 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=switch.lumi_lumisensor_magnetaq2_XXXXXXXX_1_6, old_state=None, new_state=<state switch.lumi_lumisensor_magnetaq2_XXXXXXXX_1_6=off; friendly_name=LUMI lumi.sensor_magnet.aq2 @ 2018-07-14T23:08:57.713497-04:00>>

For the second one, jeromelaban@8916972#diff-703075fd5213171ebce4a964b8b1329e seems to be the issue, where the bind command fails upon restart. Skipping it make the switch work properly anyways. Seems like the binary_sensor has this safe workaround in place (https://github.com/jeromelaban/home-assistant/blob/8916972053e4bfb0f667e5c8b26a613346783ca1/homeassistant/components/binary_sensor/zha.py#L80)

This is the generated error in the logs:

homeassistant_1  | Traceback (most recent call last):
homeassistant_1  |   File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
homeassistant_1  |     SLOW_SETUP_MAX_WAIT, loop=hass.loop)
homeassistant_1  |   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
homeassistant_1  |     return fut.result()
homeassistant_1  |   File "/usr/src/app/homeassistant/components/switch/zha.py", line 27, in async_setup_platform
homeassistant_1  |     await cluster.bind()
homeassistant_1  |   File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 89, in request
homeassistant_1  |     expect_reply=expect_reply,
homeassistant_1  |   File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/application.py", line 241, in request
homeassistant_1  |     v = await send_fut
homeassistant_1  | zigpy.exceptions.DeliveryError: Message send failure: EmberStatus.DELIVERY_FAILED

And the last point, while by the current implementation, the current switch implementation shows the proper status of the door/window sensor (albeit being discovered incorrectly) it uses the on/off status as an input cluster. In the binary_sensor implementation though, the on/off status is tentatively searched in the output cluster, which fails and never adds the sensor properly. Doing this change: jeromelaban@8916972#diff-e027da3cf460e2d27c7c7e7727df9ea3 fixes the issue, and the status is reported properly.

Does this make sense, or is just that the Xiaomi door/window sensor is incorrectly reporting its clusters inverted ?

Additional information
Here's what the zigpy library reports:

2018-07-15 11:14:36 INFO (MainThread) [homeassistant.components.zha] Permitting joins for {
    'application_listener': <homeassistant.components.zha.ApplicationListener object at 0xae556c8c>, 
    'endpoint': <zigpy.quirks.CustomEndpoint object at 0xae57792c>, 
    'in_clusters': {6: <zigpy.zcl.clusters.general.OnOff object at 0xae577acc>}, 
    'out_clusters': {}, 
    'new_join': False, 'unique_id': '00:XX:XX:XX:XX:XX:XX:0d-1-6',
    'entity_suffix': '_6',
    'manufacturer': 'LUMI',
    'model': 
    'lumi.sensor_magnet.aq2'
}
@kkr16
Copy link
Contributor

kkr16 commented Jul 20, 2018

Hey, I have a similar issue where the motion sensor (binary_sensor) is added but not triggered.
The luminosity (binary lx sensor) does update as expected.

@xtianpaiva
Copy link

Good detailed Analysis @jeromelaban, same issue here with door/window sensors; in the other hand, I have a Aqara Temp/Humidity sensor working fine.

@balloobbot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

@dmulcahey
Copy link
Contributor

@jeromelaban I am working on improving Xiaomi devices and how they are handled by ZHA. if you take a look here: https://github.com/dmulcahey/zha-device-handlers/blob/master/quirks/xiaomi/aqara_open_close_sensor.py you can see how you can tweak your current installation to make this particular sensor work better. I am working on getting first class support for these sensors added to ZHA in HA.

@tehbra1n
Copy link

tehbra1n commented Jan 4, 2019

@dmulcahey your link is a 404 atm

@dmulcahey
Copy link
Contributor

@tehbra1n whoops: https://github.com/dmulcahey/zha-device-handlers/

that being said, support has now been added to HA.

@jeromelaban are you on the latest HA? and if so is this still an issue for you?

@dmulcahey
Copy link
Contributor

Will close on Friday if there are no further comments.

@kkr16
Copy link
Contributor

kkr16 commented Feb 20, 2019

Will close on Friday if there are no further comments.

Not sure about door/window sensors but Xiaomi motion sensors now work perfectly fine using zha as of .87

Edit: HA version .87 NOT .88

@dmulcahey
Copy link
Contributor

Awesome to hear!

@dmulcahey
Copy link
Contributor

closing because no feedback being given.

@daniele-athome
Copy link
Contributor

daniele-athome commented Feb 6, 2020

Hi, I've been having this exact same issue with a door sensor, Aqara MCCGQ11LM. The in/out clusters become inverted on HA restart therefore the entity becomes a switch instead of a binary sensor. Also the battery cluster disappears. Is there something I can give you to debug this? Normal HA logs during restart don't seem to show anything relevant...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants