Update
It’s not actually “a few seconds” but exactly 1 minute when it stops responding. Paired at 2:30:47 and stuck at 2:31:47 to the second.
It doesn’t get stuck in the “off” state, but whichever state it was in when it got stuck. In this case it got stuck in the “on” state.
I’ve also tried removing any router-capable devices to link the sensor directly to the coordinator but the problem persists.
Here’s the pairing log:
[0x0000:zdo] ZDO request ZDOCmd.Mgmt_Permit_Joining_req: [60, <Bool.false: 0>]
[0x7927:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=231 command_id=Command.Report_Attributes>
[0x7927:1:0x0006] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=Bool, value=Bool.false>)]]
[0x7927:1:0x0006] Attribute report received: on_off=0
[0x11ed] Delivery error for seq # 0x38, on endpoint id 0 cluster 0x0034: message send failure
Sending 'zdo_leave_req' failed: [0x11ed:0:0x0034]: Message send failure
Device 0x11ed (00:15:8d:00:04:1c:ae:f4) left the network
New device 0x11ed (00:15:8d:00:04:1c:ae:f4) joined the network
[0x11ed] Scheduling initialization
Tries remaining: 3
[0x11ed] Requesting 'Node Descriptor'
Tries remaining: 2
[0x11ed] Extending timeout for 0x3d request
Device 0x11ed (00:15:8d:00:04:1c:ae:f4) joined the network
[0x11ed] Scheduling initialization
[0x11ed] Canceling old initialize call
Received frame on uninitialized device <Device model=None manuf=None nwk=0x11ED ieee=00:15:8d:00:04:1c:ae:f4 is_initialized=False> from ep 0 to ep 0, cluster 19: b'\xb6\xed\x11\xf4\xae\x1c\x04\x00\x8d\x15\x00\x80'
[0x11ed:zdo] ZDO request ZDOCmd.Device_annce: [0x11ED, 00:15:8d:00:04:1c:ae:f4, 128]
Tries remaining: 3
[0x11ed] Requesting 'Node Descriptor'
Tries remaining: 2
[0x11ed] Extending timeout for 0x3f request
Received frame on uninitialized device <Device model=None manuf=None nwk=0x11ED ieee=00:15:8d:00:04:1c:ae:f4 is_initialized=False> from ep 1 to ep 1, cluster 0: b'\x18\x00\n\x05\x00B\x16lumi.sensor_magnet.aq2\x01\x00 \x03'
[0x11ed] Received ZCL while uninitialized on endpoint id 1, cluster 0x0000 id, hdr: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=0 command_id=Command.Report_Attributes>, payload: b'\x05\x00B\x16lumi.sensor_magnet.aq2\x01\x00 \x03'
[0x11ed] Uninitialized device command 'Command.Report_Attributes' args: [[Attribute(attrid=5, value=<TypeValue type=CharacterString, value=lumi.sensor_magnet.aq2>), Attribute(attrid=1, value=<TypeValue type=uint8_t, value=3>)]]
[0x11ed] Found 'MagnetAQ2' quirk for 'lumi.sensor_magnet.aq2' model
[0x11ed] Canceling old initialize call
Device is initialized <Device model='lumi.sensor_magnet.aq2' manuf='LUMI' nwk=0x11ED ieee=00:15:8d:00:04:1c:ae:f4 is_initialized=True>
Checking quirks for LUMI lumi.sensor_magnet.aq2 (00:15:8d:00:04:1c:ae:f4)
Considering <class 'zhaquirks.xiaomi.aqara.magnet_aq2.MagnetAQ2'>
Found custom device replacement for 00:15:8d:00:04:1c:ae:f4: <class 'zhaquirks.xiaomi.aqara.magnet_aq2.MagnetAQ2'>
[0x11ed] Was quickly initialized from 'zhaquirks.xiaomi.aqara.magnet_aq2.MagnetAQ2' quirk
device - 0x11ED:00:15:8d:00:04:1c:ae:f4 entering async_device_initialized - is_new_join: True
device - 0x11ED:00:15:8d:00:04:1c:ae:f4 has joined the ZHA zigbee network
[0x11ED](lumi.sensor_magnet.aq2): started configuration
[0x11ED:ZDO](lumi.sensor_magnet.aq2): 'async_configure' stage succeeded
[0x11ED:1:0x0000]: skipping channel configuration
[0x11ED:1:0x0001]: skipping channel configuration
[0x11ED:1:0x0006]: skipping channel configuration
[0x11ED:1:0x0006]: skipping channel configuration
[0x11ED:1:0x0000]: 'async_configure' stage succeeded
[0x11ED:1:0x0001]: 'async_configure' stage succeeded
[0x11ED:1:0x0006]: 'async_configure' stage succeeded
[0x11ED:1:0x0006]: 'async_configure' stage succeeded
[0x11ed:1:0x0000] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=True is_reply=True disable_default_response=True> manufacturer=4447 tsn=1 command_id=Command.Report_Attributes>
[0x11ed:1:0x0000] ZCL request 0x000a: [[Attribute(attrid=65281, value=<TypeValue type=LVBytes, value=b'\x01!\x8b\x0b\x03(&\x04!\xa8\x01\x05!\x0f\x00\x06$\x01\x00\x00\x00\x00\n!\x00\x00d\x10\x00'>)]]
[0x11ed:1:0x0000] Attribute report received: 65281=b'\x01!\x8b\x0b\x03(&\x04!\xa8\x01\x05!\x0f\x00\x06$\x01\x00\x00\x00\x00\n!\x00\x00d\x10\x00'
[0x11ed:1:0x0001] Voltage mV: [Min]:2820 < [RAW]:2955 < [Max]:3100, Battery Percent: 48.0
[0x11ED](lumi.sensor_magnet.aq2): completed configuration
[0x11ED](lumi.sensor_magnet.aq2): stored in registry: ZhaDeviceEntry(name='LUMI lumi.sensor_magnet.aq2', ieee='00:15:8d:00:04:1c:ae:f4', last_seen=1636437584.3800182)
[0x11ED](lumi.sensor_magnet.aq2): started initialization
[0x11ED:ZDO](lumi.sensor_magnet.aq2): 'async_initialize' stage succeeded
[0x11ED:1:0x0000]: 'async_initialize' stage succeeded
[0x11ED:1:0x0001]: 'async_initialize' stage succeeded
[0x11ED:1:0x0006]: 'async_initialize' stage succeeded
[0x11ED:1:0x0006]: 'async_initialize' stage succeeded
[0x11ED](lumi.sensor_magnet.aq2): power source: Battery or Unknown
[0x11ED](lumi.sensor_magnet.aq2): completed initialization
[0x11ed:zdo] ZDO request ZDOCmd.Node_Desc_rsp: [<Status.SUCCESS: 0>, 0x11ED, NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4151, maximum_buffer_size=127, maximum_incoming_transfer_size=100, server_mask=0, maximum_outgoing_transfer_size=100, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)]
[0x11ed:zdo] Unsupported ZDO request:ZDOCmd.Node_Desc_rsp
[0x359F:1:0x0500]: Updated alarm state: 0
Tries remaining: 1
[0x11ed] Extending timeout for 0x41 request
[0x11ed:zdo] ZDO request ZDOCmd.Node_Desc_rsp: [<Status.SUCCESS: 0>, 0x11ED, NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4151, maximum_buffer_size=127, maximum_incoming_transfer_size=100, server_mask=0, maximum_outgoing_transfer_size=100, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)]
[0x11ed:zdo] Unsupported ZDO request:ZDOCmd.Node_Desc_rsp
[0x99a3:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=68 command_id=Command.Report_Attributes>
[0x99a3:1:0x0400] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=uint16_t, value=156>)]]
[0x99a3:1:0x0400] Attribute report received: measured_value=156
[0x99a3:1:0x0406] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=69 command_id=Command.Report_Attributes>
[0x99a3:1:0x0406] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=bitmap8, value=bitmap8.1>)]]
[0x99a3:1:0x0406] Attribute report received: occupancy=1
[0x99A3:1:0x0500]: Updated alarm state: 1
Tries remaining: 2
[0x11ed] Already have endpoints: {0: <zigpy.zdo.ZDO object at 0x7fc5fbf3fc10>, 1: <Endpoint id=1 in=[basic:0x0000, identify:0x0003, manufacturer_specific:0xFFFF, on_off:0x0006] out=[basic:0x0000, groups:0x0004, manufacturer_specific:0xFFFF] status=<Status.ZDO_INIT: 1>>}
[0x11ed] All endpoints are already initialized: [<Endpoint id=1 in=[basic:0x0000, identify:0x0003, manufacturer_specific:0xFFFF, on_off:0x0006] out=[basic:0x0000, groups:0x0004, manufacturer_specific:0xFFFF] status=<Status.ZDO_INIT: 1>>]
[0x11ed] Already have model and manufacturer info
[0x11ed] Discovered basic device information for <Device model='lumi.sensor_magnet.aq2' manuf='LUMI' nwk=0x11ED ieee=00:15:8d:00:04:1c:ae:f4 is_initialized=True>
Device is initialized <Device model='lumi.sensor_magnet.aq2' manuf='LUMI' nwk=0x11ED ieee=00:15:8d:00:04:1c:ae:f4 is_initialized=True>
Checking quirks for LUMI lumi.sensor_magnet.aq2 (00:15:8d:00:04:1c:ae:f4)
Considering <class 'zhaquirks.xiaomi.aqara.magnet_aq2.MagnetAQ2'>
Found custom device replacement for 00:15:8d:00:04:1c:ae:f4: <class 'zhaquirks.xiaomi.aqara.magnet_aq2.MagnetAQ2'>
device - 0x11ED:00:15:8d:00:04:1c:ae:f4 entering async_device_initialized - is_new_join: False
device - 0x11ED:00:15:8d:00:04:1c:ae:f4 has been reset and re-added or its nwk address changed
skipping discovery for previously discovered device - 0x11ED:00:15:8d:00:04:1c:ae:f4
[0x11ED](lumi.sensor_magnet.aq2): started configuration
[0x11ED:ZDO](lumi.sensor_magnet.aq2): 'async_configure' stage succeeded
Device 00:15:8d:00:04:1c:ae:f4 already exists. Updating it.
[0x11ED:1:0x0000]: skipping channel configuration
[0x11ED:1:0x0001]: skipping channel configuration
[0x11ED:1:0x0006]: skipping channel configuration
[0x11ED:1:0x0006]: skipping channel configuration
[0x11ED:1:0x0000]: 'async_configure' stage succeeded
[0x11ED:1:0x0001]: 'async_configure' stage succeeded
[0x11ED:1:0x0006]: 'async_configure' stage succeeded
[0x11ED:1:0x0006]: 'async_configure' stage succeeded
[0x11ED](lumi.sensor_magnet.aq2): completed configuration
[0x11ED](lumi.sensor_magnet.aq2): stored in registry: ZhaDeviceEntry(name='LUMI lumi.sensor_magnet.aq2', ieee='00:15:8d:00:04:1c:ae:f4', last_seen=1636437613.3785496)
[0x11ED](lumi.sensor_magnet.aq2): started initialization
[0x11ED:ZDO](lumi.sensor_magnet.aq2): 'async_initialize' stage succeeded
[0x11ED:1:0x0000]: 'async_initialize' stage succeeded
[0x11ED:1:0x0001]: 'async_initialize' stage succeeded
[0x11ED:1:0x0006]: 'async_initialize' stage succeeded
[0x11ED:1:0x0006]: 'async_initialize' stage succeeded
[0x11ED](lumi.sensor_magnet.aq2): power source: Battery or Unknown
[0x11ED](lumi.sensor_magnet.aq2): completed initialization
[0x8C2B](lumi.sensor_motion.aq2): set: 0 for attr: 2 to cluster: 1280 for ept: 1 - res: ([WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)],)
Set attribute for: cluster_id: [1280] cluster_type: [in] endpoint_id: [1] attribute: [2] value: [0] manufacturer: [None] response: [([WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)],)]
[0xD2DF](lumi.sensor_motion.aq2): set: 0 for attr: 2 to cluster: 1280 for ept: 1 - res: ([WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)],)
Set attribute for: cluster_id: [1280] cluster_type: [in] endpoint_id: [1] attribute: [2] value: [0] manufacturer: [None] response: [([WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)],)]
Set attribute for: cluster_id: [1280] cluster_type: [in] endpoint_id: [1] attribute: [2] value: [0] manufacturer: [None] response: [None]
[0x359F](lumi.sensor_motion.aq2): set: 0 for attr: 2 to cluster: 1280 for ept: 1 - res: ([WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)],)
Set attribute for: cluster_id: [1280] cluster_type: [in] endpoint_id: [1] attribute: [2] value: [0] manufacturer: [None] response: [([WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)],)]
[0x99A3](lumi.sensor_motion.aq2): set: 0 for attr: 2 to cluster: 1280 for ept: 1 - res: ([WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)],)
Set attribute for: cluster_id: [1280] cluster_type: [in] endpoint_id: [1] attribute: [2] value: [0] manufacturer: [None] response: [([WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)],)]
[0x72d7:1:0x0000] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=True is_reply=True disable_default_response=True> manufacturer=4447 tsn=199 command_id=Command.Report_Attributes>
[0x72d7:1:0x0000] ZCL request 0x000a: [[Attribute(attrid=65281, value=<TypeValue type=LVBytes, value=b'\x01!\xc7\x0b\x03(\x1d\x04!\xa8\x13\x05!\x11\x00\x06$\x01\x00\x00\x00\x00\n!\x00\x00'>)]]
[0x72d7:1:0x0000] Attribute report received: 65281=b'\x01!\xc7\x0b\x03(\x1d\x04!\xa8\x13\x05!\x11\x00\x06$\x01\x00\x00\x00\x00\n!\x00\x00'
[0x72d7:1:0x0001] Voltage mV: [Min]:2820 < [RAW]:3015 < [Max]:3100, Battery Percent: 69.5