Pairing the Xiaomi/Aqara Vibration Sensor (zigbee)

Goal: To pair the sensor to the CC2531 zigbee router.

See also CC2531 Router Operations

Enable Permit (aka pairing) Mode

I am using ZHA included in Home Assistant.

In Home Assistant (HA, aka hass), enable pairing mode:

Developer Tools > Services

The service to call is “zha.permit”

Note, I change duration to 250 seconds to give me plenty of time to fuss with the sensors buttons.

“ieee_address” is the zigbee MAC address of the zigbee router (eg. CC2531 running router firmware) that is permitted to add end-devices (eg. sensors) during the “duration” period.

If “ieee_address” is not provided, then the coordinator and all routers are permitted to add end-devices during the permit period. For Xiaomi sensors, I found it’s best to “lock” the sensor to the desired router (ie. closest router), so I always use “ieee_address” to ensure the sensor pairs to the router I want.

How to find the router’s MAC address

In HA with ZHA:

Configuration > Zigbee Home Automation > LUMI router > IEEE

Or, I run zha_map and read the “neighbours” file:

donn@fox:/usr/share/hassio/homeassistant$ cat neighbours/neighbours_00124b0019010203.txt
...
    "device_type": "Router",
    "ieee": "00:12:4b:00:19:01:02:03",
    "lqi": 104,
    "manufacturer": "LUMI",
    "model": "lumi.router",

Push the button on the sensor (a lot)

Here’s what happened after I enabled permit-mode:

Saw in home-assistant.log:

2020-06-25 15:34:49 INFO (MainThread) [homeassistant.components.zha.api] Permitting joins for 60s on 00:12:4b:00:19:01:02:03 device

Press and hold sensor button for 5s. Saw blue led flash 3 times.

Press button every 1 to 2s. See blue led flash once, on most button presses.

10s go by. Nothing is happening in the HA log, so…

Press and hold button for 5s, again.

Press button every 1 to 2s, again.

This time I start seeing messages in HA log that sensor is discovered.

IMPORTANT: Keep pressing the button every 1 to 2s for another 1 minute until new zigbee log messages no longer appear.

HA log results

2020-06-25 15:34:49 INFO (MainThread) [homeassistant.components.zha.api] Permitting joins for 60s on 00:12:4b:00:19:01:02:03 device
2020-06-25 15:35:42 INFO (MainThread) [zigpy_deconz.zigbee.application] New device joined: 0xb1e2, 00:15:8d:00:02:11:22:33
2020-06-25 15:35:42 INFO (MainThread) [zigpy.application] Device 0xb1e2 (00:15:8d:00:02:11:22:33) joined the network
2020-06-25 15:35:42 INFO (MainThread) [zigpy.device] [0xb1e2] Requesting 'Node Descriptor'
2020-06-25 15:35:46 INFO (MainThread) [zigpy.device] [0xb1e2] Node Descriptor: <Optional byte1=2 byte2=64 mac_capability_flags=128 manufacturer_code=4151 maximum_buffer_size=127 maximum_incoming_transfer_size=100 server_mask=0 maximum_outgoing_transfer_size=100 descriptor_capability_field=0>
2020-06-25 15:35:46 INFO (MainThread) [zigpy.device] [0xb1e2] Discovering endpoints
2020-06-25 15:35:49 INFO (MainThread) [zigpy.device] [0xb1e2] Discovered endpoints: [1, 2]
2020-06-25 15:35:49 INFO (MainThread) [zigpy.endpoint] [0xb1e2:1] Discovering endpoint information
2020-06-25 15:35:52 INFO (MainThread) [zigpy.endpoint] [0xb1e2:1] Discovered endpoint information: <Optional endpoint=1 profile=260 device_type=10 device_version=1 input_clusters=[0, 3, 25, 257] output_clusters=[0, 4, 3, 5, 25, 257]>
2020-06-25 15:35:57 INFO (MainThread) [zigpy.endpoint] [0xb1e2:2] Discovering endpoint information
2020-06-25 15:36:02 INFO (MainThread) [zigpy.endpoint] [0xb1e2:2] Discovered endpoint information: <Optional endpoint=2 profile=260 device_type=24322 device_version=1 input_clusters=[3, 18] output_clusters=[4, 3, 5, 18]>
2020-06-25 15:36:13 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.zha entity: binary_sensor.lumi_lumi_vibration_aq1_33221102_ias_zone
2020-06-25 15:36:13 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.zha entity: sensor.lumi_lumi_vibration_aq1_33221102_power

Verify the pairing

HA “Services” page: Call the service “zha_map.scan_now” to rebuild the zigbee network map data.

The router’s “neighbours” file confirms the Xiaomi sensor is a “Child” of the router, so pairing was successful:

        {
            "depth": 2,
            "device_type": "End_Device",
            "ieee": "00:15:8d:00:02:11:22:33",
            "lqi": 7,
            "manufacturer": "LUMI",
            "model": "lumi.vibration.aq1",
            "new_joins_accepted": "Unknown",
            "nwk": "0xb1e2",
            "offline": false,
            "pan_id": "00:21:2e:ff:ff:0a:0b:0c",
            "relation": "Child",
            "rx_on_when_idle": "Off",
            "supported": true
        }

Test the sensor

Tap the sensor to vibrate it.  Entity state changes from “off” to “on”:

 

Refs:

https://github.com/home-assistant/core/issues/28614

 

#

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.