Repository: zigpy/zha-device-handlers

Issue:
[Device Support Request] Linkind ZB-MotionSensor-D0003
**Is your feature request related to a problem? Please describe.**

The sensor is recognized in Home Assistant as a motion sensor and reports motion in the logs as Alarm_1; the sensor also has a bright/dark sensor it reports as Alarm_2 on dark. The problem is that if either Alarm is active Home Assistant marks motion as "on" --- if it is dark the sensor does not time out after motion stops until it is bright again and the motion status updates making it useless for detecting repeated motion in dark or near-dark rooms. Note that it only updates the status of bright/dark when it reports on motion start or motion timeout.

**Describe the solution you'd like**

The motion entity reports motion status (Alarm_1) regardless of the light/dark status (Alarm_2). If possible, an entity that reports the light/dark update status. If possible, An additional entity for Tamper status.

**Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add devices screen. Be sure to add the entire content of the log panel after pairing the device to a code block below this line.**

```yaml
{
  "node_descriptor": "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=4456, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, 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)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0402",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x0020",
        "0x0500",
        "0x0b05",
        "0xfc81"
      ],
      "out_clusters": [
        "0x0019"
      ]
    }
  },
  "manufacturer": "lk",
  "model": "ZB-MotionSensor-D0003",
  "class": "zigpy.device.Device"
}
```

**Additional context**

https://zigbee.blakadder.com/Linkind_ZS110040078.html
https://www.linkind.com/product/pir-motion-sensor-zigbee/

Output from activity log showing various states; bright and dark were achieved by placing sensor in front of computer monitor and changing between white and black background:

_NoTamper, Bright, NoMotion 0-0-0 0 48_
[0x3ab3:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=37 command_id=0>
[0x3ab3:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports: 48>, <bitmap8.0: 0>, 0, 0]
[0x3ab3:1:0x0500]: Updated alarm state: ZoneStatus.0

_NoTamper, Bright, Motion 0-0-1 1 49_
[0x3ab3:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=38 command_id=0>
[0x3ab3:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports|Alarm_1: 49>, <bitmap8.0: 0>, 0, 0]
[0x3ab3:1:0x0500]: Updated alarm state: ZoneStatus.Alarm_1

_NoTamper, Dark, NoMotion 0-2-0 2 50_
[0x3ab3:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=32 command_id=0>
[0x3ab3:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports|Alarm_2: 50>, <bitmap8.0: 0>, 0, 0]
[0x3ab3:1:0x0500]: Updated alarm state: ZoneStatus.Alarm_2

_NoTamper, Dark, Motion 0-2-1 3 51_
[0x3ab3:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=31 command_id=0>
[0x3ab3:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports|Alarm_2|Alarm_1: 51>, <bitmap8.0: 0>, 0, 0]
[0x3ab3:1:0x0500]: Updated alarm state: ZoneStatus.Alarm_2|Alarm_1

_Tamper, Bright, NoMotion 4-0-0 4 52_
[0x3ab3:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=24 command_id=0>
[0x3ab3:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports|Tamper: 52>, <bitmap8.0: 0>, 0, 0]
[0x3ab3:1:0x0500]: Updated alarm state: ZoneStatus.0

_Tamper, Bright, Motion 4-0-1 5 53_
[0x3ab3:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=23 command_id=0>
[0x3ab3:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports|Tamper|Alarm_1: 53>, <bitmap8.0: 0>, 0, 0]
[0x3ab3:1:0x0500]: Updated alarm state: ZoneStatus.Alarm_1

_Tamper, Dark, NoMotion 4-2-0 6 54_
[0x3ab3:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=29 command_id=0>
[0x3ab3:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports|Tamper|Alarm_2: 54>, <bitmap8.0: 0>, 0, 0]
[0x3ab3:1:0x0500]: Updated alarm state: ZoneStatus.Alarm_2

_Tamper, Dark, Motion 4-2-1 7 55_
[0x3ab3:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=20 command_id=0>
[0x3ab3:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports|Tamper|Alarm_2|Alarm_1: 55>, <bitmap8.0: 0>, 0, 0]
[0x3ab3:1:0x0500]: Updated alarm state: ZoneStatus.Alarm_2|Alarm_1

_Other_
[0x3ab3:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=True is_reply=True disable_default_response=True> manufacturer=4456 tsn=25 command_id=Command.Report_Attributes>
[0x3ab3:1:0x0500] ZCL request 0x000a: [[Attribute(attrid=65531, value=<TypeValue type=uint8_t, value=1>)]]
[0x3ab3:1:0x0500] Attribute report received: 65531=1

Output from join log:

<details>
<summary>Logs</summary>

```python
2022-01-16 12:41:56 DEBUG (MainThread) [bellows.zigbee.application] Received childJoinHandler frame with [1, <Bool.true: 1>, 0x8009, 04:cd:15:ff:fe:63:7d:48, <EmberNodeType.SLEEPY_END_DEVICE: 4>]
2022-01-16 12:41:56 DEBUG (MainThread) [bellows.zigbee.application] Received trustCenterJoinHandler frame with [0x8009, 04:cd:15:ff:fe:63:7d:48, <EmberDeviceUpdate.STANDARD_SECURITY_UNSECURED_JOIN: 1>, <EmberJoinDecision.USE_PRECONFIGURED_KEY: 0>, 0x0000]
2022-01-16 12:41:56 INFO (MainThread) [zigpy.application] Device 0x8009 (04:cd:15:ff:fe:63:7d:48) joined the network
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.application] Device 04:cd:15:ff:fe:63:7d:48 changed id (0x8009 => 0x8009)
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.device] [0x8009] Scheduling initialization
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.device] [0x8009] Canceling old initialize call
2022-01-16 12:41:56 INFO (MainThread) [zigpy.device] [0x8009] Requesting 'Node Descriptor'
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0x95 request
2022-01-16 12:41:56 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:56 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_BROADCAST: 4>, EmberApsFrame(profileId=0, clusterId=19, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_SOURCE_EUI64|APS_OPTION_UNKNOWN: 1032>, groupId=0, sequence=13), 255, -82, 0x8009, 255, 255, b'\x81\t\x80H}c\xfe\xff\x15\xcd\x04\x80']
2022-01-16 12:41:56 INFO (MainThread) [bellows.zigbee.application] ZDO Device announce: 0x8009, 04:cd:15:ff:fe:63:7d:48
2022-01-16 12:41:56 INFO (MainThread) [zigpy.application] Device 0x8009 (04:cd:15:ff:fe:63:7d:48) joined the network
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.device] [0x8009] Scheduling initialization
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.device] [0x8009] Canceling old initialize call
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.application] Received frame on uninitialized device <Device model=None manuf=None nwk=0x8009 ieee=04:cd:15:ff:fe:63:7d:48 is_initialized=False> from ep 0 to ep 0, cluster 19: b'\x81\t\x80H}c\xfe\xff\x15\xcd\x04\x80'
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.zdo] [0x8009:zdo] ZDO request ZDOCmd.Device_annce: [0x8009, 04:cd:15:ff:fe:63:7d:48, 128]
2022-01-16 12:41:56 INFO (MainThread) [zigpy.device] [0x8009] Requesting 'Node Descriptor'
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0x97 request
2022-01-16 12:41:56 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:56 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=0, clusterId=2, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=151), 152, b'\x97\t\x80')
2022-01-16 12:41:56 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=0, clusterId=32770, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=14), 255, -82, 0x8009, 255, 255, b'\x97\x00\t\x80\x02@\x80h\x11RR\x00\x00,R\x00\x00']
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.application] Received frame on uninitialized device <Device model=None manuf=None nwk=0x8009 ieee=04:cd:15:ff:fe:63:7d:48 is_initialized=False> from ep 0 to ep 0, cluster 32770: b'\x97\x00\t\x80\x02@\x80h\x11RR\x00\x00,R\x00\x00'
2022-01-16 12:41:56 INFO (MainThread) [zigpy.device] [0x8009] Got Node Descriptor: 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=4456, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, 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)
2022-01-16 12:41:56 INFO (MainThread) [zigpy.device] [0x8009] Discovering endpoints
2022-01-16 12:41:56 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0x99 request
2022-01-16 12:41:56 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:56 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=0, clusterId=5, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=153), 154, b'\x99\t\x80')
2022-01-16 12:41:57 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=0, clusterId=32773, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=15), 255, -82, 0x8009, 255, 255, b'\x99\x00\t\x80\x01\x01']
2022-01-16 12:41:57 DEBUG (MainThread) [zigpy.application] Received frame on uninitialized device <Device model=None manuf=None nwk=0x8009 ieee=04:cd:15:ff:fe:63:7d:48 is_initialized=False> from ep 0 to ep 0, cluster 32773: b'\x99\x00\t\x80\x01\x01'
2022-01-16 12:41:57 INFO (MainThread) [zigpy.device] [0x8009] Discovered endpoints: [1]
2022-01-16 12:41:57 INFO (MainThread) [zigpy.device] [0x8009] Initializing endpoints [<Endpoint id=1 in=[] out=[] status=<Status.NEW: 0>>]
2022-01-16 12:41:57 INFO (MainThread) [zigpy.endpoint] [0x8009:1] Discovering endpoint information
2022-01-16 12:41:57 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0x9b request
2022-01-16 12:41:57 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:57 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=0, clusterId=4, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=155), 156, b'\x9b\t\x80\x01')
2022-01-16 12:41:57 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=0, clusterId=32772, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=16), 255, -82, 0x8009, 255, 255, b'\x9b\x00\t\x80\x18\x01\x04\x01\x02\x04\x01\x07\x00\x00\x01\x00\x03\x00 \x00\x00\x05\x05\x0b\x81\xfc\x01\x19\x00']
2022-01-16 12:41:57 DEBUG (MainThread) [zigpy.application] Received frame on uninitialized device <Device model=None manuf=None nwk=0x8009 ieee=04:cd:15:ff:fe:63:7d:48 is_initialized=False> from ep 0 to ep 0, cluster 32772: b'\x9b\x00\t\x80\x18\x01\x04\x01\x02\x04\x01\x07\x00\x00\x01\x00\x03\x00 \x00\x00\x05\x05\x0b\x81\xfc\x01\x19\x00'
2022-01-16 12:41:57 INFO (MainThread) [zigpy.endpoint] [0x8009:1] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=1026, device_version=1, input_clusters=[0, 1, 3, 32, 1280, 2821, 64641], output_clusters=[25])
2022-01-16 12:41:57 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0x9d request
2022-01-16 12:41:57 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:57 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=0, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=157), 158, b'\x00\x9d\x00\x04\x00\x05\x00')
2022-01-16 12:41:57 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=0, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=17), 255, -82, 0x8009, 255, 255, b'\x08\x9d\x01\x04\x00\x00B\x02lk\x05\x00\x00B\x15ZB-MotionSensor-D0003']
2022-01-16 12:41:57 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0000] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=157 command_id=Command.Read_Attributes_rsp>
2022-01-16 12:41:57 INFO (MainThread) [zigpy.device] [0x8009] Read model 'ZB-MotionSensor-D0003' and manufacturer 'lk' from <Endpoint id=1 in=[basic:0x0000, power:0x0001, identify:0x0003, poll_control:0x0020, ias_zone:0x0500, diagnostic:0x0B05, manufacturer_specific:0xFC81] out=[ota:0x0019] status=<Status.ZDO_INIT: 1>>
2022-01-16 12:41:57 INFO (MainThread) [zigpy.device] [0x8009] Discovered basic device information for <Device model='ZB-MotionSensor-D0003' manuf='lk' nwk=0x8009 ieee=04:cd:15:ff:fe:63:7d:48 is_initialized=True>
2022-01-16 12:41:57 DEBUG (MainThread) [zigpy.application] Device is initialized <Device model='ZB-MotionSensor-D0003' manuf='lk' nwk=0x8009 ieee=04:cd:15:ff:fe:63:7d:48 is_initialized=True>
2022-01-16 12:41:57 DEBUG (MainThread) [homeassistant.components.zha.core.gateway] device - 0x8009:04:cd:15:ff:fe:63:7d:48 entering async_device_initialized - is_new_join: True
2022-01-16 12:41:57 DEBUG (MainThread) [homeassistant.components.zha.core.gateway] device - 0x8009:04:cd:15:ff:fe:63:7d:48 has joined the ZHA zigbee network
2022-01-16 12:41:57 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x8009](ZB-MotionSensor-D0003): started configuration
2022-01-16 12:41:57 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:ZDO](ZB-MotionSensor-D0003): 'async_configure' stage succeeded
2022-01-16 12:41:57 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0x9f request
2022-01-16 12:41:57 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:57 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xa1 request
2022-01-16 12:41:57 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0000]: finished channel configuration
2022-01-16 12:41:57 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xa3 request
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=159), 160, b'\x00\x9f\x00\x01\x00')
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=0, clusterId=33, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=161), 162, b'\xa1H}c\xfe\xff\x15\xcd\x04\x01\x01\x00\x03\xc2\xda\x0e\x15\x00o\r\x00\x01')
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=0, clusterId=33, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=163), 164, b'\xa3H}c\xfe\xff\x15\xcd\x04\x01 \x00\x03\xc2\xda\x0e\x15\x00o\r\x00\x01')
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=18), 240, -82, 0x8009, 255, 255, b'\x08\x9f\x01\x01\x00\x001\r\x00']
2022-01-16 12:41:58 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=159 command_id=Command.Read_Attributes_rsp>
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=0, clusterId=32801, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=19), 255, -82, 0x8009, 255, 255, b'\xa1\x00']
2022-01-16 12:41:58 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: started IASZoneChannel configuration
2022-01-16 12:41:58 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xa5 request
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:58 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0001]: bound 'power' cluster: Status.SUCCESS
2022-01-16 12:41:58 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xa7 request
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=0, clusterId=32801, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=20), 255, -82, 0x8009, 255, 255, b'\xa3\x00']
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=0, clusterId=33, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=165), 166, b'\xa5H}c\xfe\xff\x15\xcd\x04\x01\x00\x05\x03\xc2\xda\x0e\x15\x00o\r\x00\x01')
2022-01-16 12:41:58 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0020]: bound 'poll_control' cluster: Status.SUCCESS
2022-01-16 12:41:58 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xa9 request
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=1, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=167), 168, b'\x00\xa7\x06\x00 \x00 \x10\x0e0*\x01\x00!\x00 \x10\x0e0*\x01')
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:41:58 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=32, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=169), 170, b'\x00\xa9\x02\x00\x00#\x903\x00\x00')
2022-01-16 12:41:59 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=22), 255, -82, 0x8009, 255, 255, b'\x08\xa7\x07\x00']
2022-01-16 12:41:59 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=167 command_id=Command.Configure_Reporting_rsp>
2022-01-16 12:41:59 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=32, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=23), 246, -82, 0x8009, 255, 255, b'\x08\xa9\x04\x00']
2022-01-16 12:41:59 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0020] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=169 command_id=Command.Write_Attributes_rsp>
2022-01-16 12:41:59 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0001]: Successfully configured reporting for '{'battery_voltage': (3600, 10800, 1), 'battery_percentage_remaining': (3600, 10800, 1)}' on 'power' cluster: [ConfigureReportingResponseRecord(status=0)]
2022-01-16 12:41:59 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0001]: finished channel configuration
2022-01-16 12:41:59 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0020]: 3300.0s check-in interval set: [[WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)]]
2022-01-16 12:41:59 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0020]: finished channel configuration
2022-01-16 12:41:59 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0019]: finished channel configuration
2022-01-16 12:42:02 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_BROADCAST: 4>, EmberApsFrame(profileId=0, clusterId=54, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_UNKNOWN: 8>, groupId=0, sequence=25), 255, -81, 0x8009, 255, 255, b'\x02\xb4\x01']
2022-01-16 12:42:02 DEBUG (MainThread) [zigpy.zdo] [0x8009:zdo] ZDO request ZDOCmd.Mgmt_Permit_Joining_req: [180, <Bool.true: 1>]
2022-01-16 12:42:08 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=0, clusterId=32801, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=26), 255, -82, 0x8009, 255, 255, b'\xa5\x00']
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: bound 'ias_zone' cluster: Status.SUCCESS
2022-01-16 12:42:08 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xad request
2022-01-16 12:42:08 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:42:08 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=173), 174, b'\x00\xad\x02\x10\x00\xf0\xc2\xda\x0e\x15\x00o\r\x00')
2022-01-16 12:42:08 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=0, clusterId=32801, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=21), 255, -79, 0x8009, 255, 255, b'\xa5\x00']
2022-01-16 12:42:08 DEBUG (MainThread) [zigpy.zdo] [0x8009:zdo] ZDO request ZDOCmd.Bind_rsp: [<Status.SUCCESS: 0>]
2022-01-16 12:42:08 DEBUG (MainThread) [zigpy.zdo] [0x8009:zdo] No handler for ZDO request:ZDOCmd.Bind_rsp([<Status.SUCCESS: 0>])
2022-01-16 12:42:08 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=27), 255, -79, 0x8009, 255, 255, b'\x08\xad\x04\x00']
2022-01-16 12:42:08 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=173 command_id=Command.Write_Attributes_rsp>
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: wrote cie_addr: 00:0d:6f:00:15:0e:da:c2 to 'ias_zone' cluster: [WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)]
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: Sending pro-active IAS enroll response
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: finished IASZoneChannel configuration
2022-01-16 12:42:08 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xaf request
2022-01-16 12:42:08 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: 'async_configure' stage succeeded
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0001]: 'async_configure' stage succeeded
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0000]: 'async_configure' stage succeeded
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0020]: 'async_configure' stage succeeded
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0019]: 'async_configure' stage succeeded
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x8009](ZB-MotionSensor-D0003): completed configuration
2022-01-16 12:42:08 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x8009](ZB-MotionSensor-D0003): stored in registry: ZhaDeviceEntry(name='unk_manufacturer unk_model', ieee='04:cd:15:ff:fe:63:7d:48', last_seen=1642372928.5891716)
2022-01-16 12:42:08 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xb1 request
2022-01-16 12:42:08 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=175), 176, b'\x01\xaf\x00\x00\x00')
2022-01-16 12:42:08 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:42:08 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=3, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=177), 178, b'\x01\xb1@\x02\x00')
2022-01-16 12:42:09 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=3, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=28), 255, -79, 0x8009, 255, 255, b'\x08\xb1\x0b@\x81']
2022-01-16 12:42:09 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0003] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=177 command_id=Command.Default_Response>
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0003]: executed 'trigger_effect' command with args: '(2, 0)' kwargs: '{}' result: [64, <Status.UNSUP_CLUSTER_COMMAND: 129>]
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x8009](ZB-MotionSensor-D0003): started initialization
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:ZDO](ZB-MotionSensor-D0003): 'async_initialize' stage succeeded
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: initializing channel: from_cache: False
2022-01-16 12:42:09 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xb3 request
2022-01-16 12:42:09 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0001]: initializing channel: from_cache: False
2022-01-16 12:42:09 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xb5 request
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0000]: initializing channel: from_cache: False
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0000]: finished channel initialization
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0020]: initializing channel: from_cache: False
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0020]: finished channel initialization
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0019]: initializing channel: from_cache: False
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0019]: finished channel initialization
2022-01-16 12:42:09 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=179), 180, b'\x00\xb3\x00\x00\x00')
2022-01-16 12:42:09 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:42:09 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=1, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=181), 182, b'\x00\xb5\x00 \x00!\x00')
2022-01-16 12:42:09 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=29), 255, -80, 0x8009, 255, 255, b'\x08\xb3\x01\x00\x00\x000\x01']
2022-01-16 12:42:09 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=179 command_id=Command.Read_Attributes_rsp>
2022-01-16 12:42:09 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=32), 255, -80, 0x8009, 255, 255, b'\x08\xb5\x01 \x00\x00 \x1b!\x00\x00 \x86']
2022-01-16 12:42:09 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=181 command_id=Command.Read_Attributes_rsp>
2022-01-16 12:42:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: finished channel initialization
2022-01-16 12:42:09 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xb7 request
2022-01-16 12:42:09 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:42:09 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=1, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=183), 184, b'\x00\xb7\x001\x003\x00')
2022-01-16 12:42:11 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=33), 255, -80, 0x8009, 255, 255, b'\x08\xb7\x011\x00\x000\x023\x00\x00 \x01']
2022-01-16 12:42:11 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=183 command_id=Command.Read_Attributes_rsp>
2022-01-16 12:42:11 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0001]: finished channel initialization
2022-01-16 12:42:11 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: 'async_initialize' stage succeeded
2022-01-16 12:42:11 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0001]: 'async_initialize' stage succeeded
2022-01-16 12:42:11 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0000]: 'async_initialize' stage succeeded
2022-01-16 12:42:11 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0020]: 'async_initialize' stage succeeded
2022-01-16 12:42:11 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0019]: 'async_initialize' stage succeeded
2022-01-16 12:42:11 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x8009](ZB-MotionSensor-D0003): power source: Battery or Unknown
2022-01-16 12:42:11 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x8009](ZB-MotionSensor-D0003): completed initialization
2022-01-16 12:42:14 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_BROADCAST: 4>, EmberApsFrame(profileId=0, clusterId=6, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_UNKNOWN: 264>, groupId=0, sequence=34), 255, -82, 0x8009, 255, 255, b'\x03\xfd\xff\x04\x01\x01\x19\x00\x00']
2022-01-16 12:42:14 DEBUG (MainThread) [zigpy.zdo] [0x8009:zdo] ZDO request ZDOCmd.Match_Desc_req: [0xFFFD, 260, [25], []]
2022-01-16 12:42:14 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=0, clusterId=32774, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=3), 185, b'\x03\x00\x00\x00\x01\x01')
2022-01-16 12:42:16 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=25, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_RETRY: 64>, groupId=0, sequence=35), 255, -82, 0x8009, 255, 255, b'\x01\x02\x01\x00h\x11\xfb\x80\x02\x00#Q']
2022-01-16 12:42:16 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0019] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=2 command_id=1>
2022-01-16 12:42:16 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0019] ZCL request 0x0001: [0, 4456, 33019, 1361248258, None]
2022-01-16 12:42:16 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0019] OTA query_next_image handler for 'lk ZB-MotionSensor-D0003': field_control=0, manufacture_id=4456, image_type=33019, current_file_version=1361248258, hardware_version=None
2022-01-16 12:42:16 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0019] No OTA image is available
2022-01-16 12:42:16 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=25, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=2), 186, b'\x19\x02\x02\x98')
2022-01-16 12:42:18 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=30), 255, -82, 0x8009, 255, 255, b'\t\x01\x01\r\x00h\x11']
2022-01-16 12:42:18 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=1 command_id=1>
2022-01-16 12:42:18 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL request 0x0001: [<ZoneType.Motion_Sensor: 13>, 4456]
2022-01-16 12:42:18 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: Enroll requested
2022-01-16 12:42:18 DEBUG (MainThread) [zigpy.device] [0x8009] Extending timeout for 0xbb request
2022-01-16 12:42:18 DEBUG (MainThread) [bellows.zigbee.application] Extending timeout for 04:cd:15:ff:fe:63:7d:48/0x8009
2022-01-16 12:42:18 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=187), 188, b'\x01\xbb\x00\x00\x00')
2022-01-16 12:42:19 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=36), 255, -82, 0x8009, 255, 255, b'\x1ch\x11\x03\n\xfb\xff \x00']
2022-01-16 12:42:19 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=True is_reply=True disable_default_response=True> manufacturer=4456 tsn=3 command_id=Command.Report_Attributes>
2022-01-16 12:42:19 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL request 0x000a: [[Attribute(attrid=65531, value=<TypeValue type=uint8_t, value=0>)]]
2022-01-16 12:42:19 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] Attribute report received: 65531=0
2022-01-16 12:42:24 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_BROADCAST: 4>, EmberApsFrame(profileId=0, clusterId=6, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_UNKNOWN: 264>, groupId=0, sequence=37), 255, -83, 0x8009, 255, 255, b'\x04\xfd\xff\x04\x01\x01\x19\x00\x00']
2022-01-16 12:42:24 DEBUG (MainThread) [zigpy.zdo] [0x8009:zdo] ZDO request ZDOCmd.Match_Desc_req: [0xFFFD, 260, [25], []]
2022-01-16 12:42:24 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=0, clusterId=32774, sourceEndpoint=0, destinationEndpoint=0, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=4), 189, b'\x04\x00\x00\x00\x01\x01')
2022-01-16 12:42:26 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=25, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_RETRY: 64>, groupId=0, sequence=38), 244, -82, 0x8009, 255, 255, b'\x01\x04\x01\x00h\x11\xfb\x80\x02\x00#Q']
2022-01-16 12:42:26 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0019] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=4 command_id=1>
2022-01-16 12:42:26 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0019] ZCL request 0x0001: [0, 4456, 33019, 1361248258, None]
2022-01-16 12:42:26 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0019] OTA query_next_image handler for 'lk ZB-MotionSensor-D0003': field_control=0, manufacture_id=4456, image_type=33019, current_file_version=1361248258, hardware_version=None
2022-01-16 12:42:26 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0019] No OTA image is available
2022-01-16 12:42:26 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0x8009, EmberApsFrame(profileId=260, clusterId=25, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=4), 190, b'\x19\x04\x02\x98')
2022-01-16 12:42:59 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=39), 255, -80, 0x8009, 255, 255, b'\x18\x05\n!\x00 \xa8']
2022-01-16 12:42:59 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=5 command_id=Command.Report_Attributes>
2022-01-16 12:42:59 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0001] ZCL request 0x000a: [[Attribute(attrid=33, value=<TypeValue type=uint8_t, value=168>)]]
2022-01-16 12:42:59 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0001] Attribute report received: battery_percentage_remaining=168
2022-01-16 12:45:06 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=40), 255, -74, 0x8009, 255, 255, b'\x1ch\x11\x06\n\xfb\xff \x01']
2022-01-16 12:45:06 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=True is_reply=True disable_default_response=True> manufacturer=4456 tsn=6 command_id=Command.Report_Attributes>
2022-01-16 12:45:06 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL request 0x000a: [[Attribute(attrid=65531, value=<TypeValue type=uint8_t, value=1>)]]
2022-01-16 12:45:06 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] Attribute report received: 65531=1
2022-01-16 12:45:06 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=41), 255, -74, 0x8009, 255, 255, b'\x19\x07\x007\x00\x00\x00\x00\x00']
2022-01-16 12:45:06 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=7 command_id=0>
2022-01-16 12:45:06 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports|Tamper|Alarm_2|Alarm_1: 55>, <bitmap8.0: 0>, 0, 0]
2022-01-16 12:45:06 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: Updated alarm state: ZoneStatus.Alarm_2|Alarm_1
2022-01-16 12:45:30 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=42), 253, -90, 0x8009, 255, 255, b'\x19\x08\x003\x00\x00\x00\x00\x00']
2022-01-16 12:45:30 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=8 command_id=0>
2022-01-16 12:45:30 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports|Alarm_2|Alarm_1: 51>, <bitmap8.0: 0>, 0, 0]
2022-01-16 12:45:30 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: Updated alarm state: ZoneStatus.Alarm_2|Alarm_1
2022-01-16 12:46:30 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=1280, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=43), 240, -78, 0x8009, 255, 255, b'\x19\t\x002\x00\x00\x00\x00\x00']
2022-01-16 12:46:30 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=9 command_id=0>
2022-01-16 12:46:30 DEBUG (MainThread) [zigpy.zcl] [0x8009:1:0x0500] ZCL request 0x0000: [<ZoneStatus.Restore_reports|Supervision_reports|Alarm_2: 50>, <bitmap8.0: 0>, 0, 0]
2022-01-16 12:46:30 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x8009:1:0x0500]: Updated alarm state: ZoneStatus.Alarm_2
```

</details>


Discussion:
Great job digging into this.  I'm also interested in getting this sensor working.  Mine seems to get stuck and doesn't want to do anything.
I bought one of these motion sensors recently, and it has similarly been getting stuck on motion detected and refuses to clear until I remove and re-pair with ZHA. 
Yeah… wonder if there is some way to solve this or if it’s just their firmware.  I do see there was solutions over on Hubitat forums but not sure what they ended up doing to make it work.

From: krazos ***@***.***>
Reply-To: zigpy/zha-device-handlers ***@***.***>
Date: Wednesday, February 2, 2022 at 10:16 AM
To: zigpy/zha-device-handlers ***@***.***>
Cc: jfrux ***@***.***>, Comment ***@***.***>
Subject: Re: [zigpy/zha-device-handlers] [Device Support Request] Linkind ZB-MotionSensor-D0003 (Issue #1291)


I bought one of these motion sensors recently, and it has similarly been getting stuck on motion detected and refuses to clear until I remove and re-pair with ZHA.

—
Reply to this email directly, view it on GitHub<https://github.com/zigpy/zha-device-handlers/issues/1291#issuecomment-1028044408>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AABJYRJYBMCE3XCZ2U6XKV3UZFDD7ANCNFSM5MDKBDTQ>.
You are receiving this because you commented.Message ID: ***@***.***>

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 version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Is there any resolution to this issue as yet? I just paired 3 of these motion sensors with ZHA yesterday after a long time running Zigbee2MQTT. Immediately they detected motion they stuck on detected and did not clear without a full delete and repair - only to do it again immediately. They work fine in Zigbee2MQTT. Currently running HA 2022.7.7, which I assume has a reasonably up to date ZHA 
I would also be genuinely interested in a solution. 
I am **currently trying to learn** how to **write quirks properly**, but this one was maybe a little hard for the beginning 👯 

What I have done so far (for 8 Hours until now):

### → Created a quirk that matches the device and gets applied.
```
"""Linkind ZB-MotionSensor-D0003."""
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
    Basic,
    Identify,
    Ota,
    PollControl,
    PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.security import IasZone

from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODELS_INFO,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
    SKIP_CONFIGURATION,
)
from zhaquirks.linkind import LinkindBasicCluster

LINKIND_CLUSTER_ID = 0xFC81

class LinkindD0003(CustomDevice):
    """Linkind ZB-MotionSensor-D0003."""

    signature = {
        MODELS_INFO: [("lk", "ZB-MotionSensor-D0003")],
        # <SimpleDescriptor endpoint=1 profile=260 device_type=1026
        # device_version=1 
        # input_clusters=[0, 1, 3, 32, 1280, 2821, 64641]
        # output_clusters=[25]>
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    PowerConfiguration.cluster_id,
                    Identify.cluster_id,
                    PollControl.cluster_id,
                    IasZone.cluster_id,
                    Diagnostic.cluster_id,
                    LINKIND_CLUSTER_ID,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            }
        },
    }

    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
                INPUT_CLUSTERS: [
                    LinkindBasicCluster,
                    PowerConfiguration.cluster_id,
                    Identify.cluster_id,
                    PollControl.cluster_id,
                    IasZone.cluster_id,
                    Diagnostic.cluster_id,
                    LINKIND_CLUSTER_ID,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            }
        },
    }
```

One thing in this quirk might be messed up, I guess:
- The Manufacturer-Specific cluster was written by me, like I saw it on some Aqara devices (no idea if this is right). But as far as I know, there is no way around defining this cluster because otherwise ZHA wouldn't apply this quirk (Cluster-Missmatch)
- But anyway, it is applied when joining the device:
<img width="1022" alt="Google Chrome - Einstellungen – Home Assistant_2023-01-24_19 21 11@2x" src="https://user-images.githubusercontent.com/62359912/214375862-0c4c97f0-acf9-425f-979c-8a2ddd39ea85.png">


### What I don't know how to do: How to get the Occupancy Sensor working?

For my understanding, the [IasZone Cluster](https://github.com/zigpy/zigpy/blob/b94cfe12903b21ed146e556c1e514e2abc16611f/zigpy/zcl/clusters/security.py#L41) should handle the "Strings" inside the ZoneStatus. But as it seems, this is not happening properly. (I have the same issue, the Occupancy is and will stay as "detected")

So now I am a little confused.
- Shouldn't this be handled by the IasZone or is it normal that this doesn't work out of the box? (For the strings inside the ZoneStatus, see the [initial issue](https://github.com/zigpy/zha-device-handlers/issues/1291#issue-1105212201))
- Is it because this device uses inside ZoneStatus Alarm_2 as "Dark-Sensor" and Alarm_1 as "Motion-Sensor"? (Might be quite unusual)
- Do we somehow need to modify (if possible) the way IasZone interprets these "strings"?
- Will we need a custom attribute mapping with a kind of lambda handler, like for [some Tuya devices](https://github.com/zigpy/zha-device-handlers/issues/1599#issuecomment-1219634462)? (And if yes, how to establish a DPToAttributeMapping without the TuyaDPType?)

Could someone point me in the right direction or link up an example-quirks? I wouldn't normally do this, but maybe 
@javicalle has some advice or tips to give? 

Additional Reference (Z2M Converter): https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/devices/linkind.js#L113
Perhaps one additional Question, regarding the Z2M Converter: If I get this correctly, the Method used to get the readings from the sensor (which works perfectly in Z2M) is [this one](https://github.com/Koenkk/zigbee-herdsman-converters/blob/d8913308b6acf7ca1a5d03eacd8b9b39a7a14984/converters/fromZigbee.js#L1068). Is there a "method" like this in ZHA which could be used to read the sensor?

Maybe I am completely on the wrong trail with my questions and ideas here, everything is possible when learning something new 😁

Thanks to everyone who is trying to help 🙏 & please excuse the many questions 🤓



<details>
  <summary>My Diagnostics for the device</summary>
  
  ```
{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.1.6",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.10.7",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/Berlin",
    "os_name": "Linux",
    "os_version": "5.15.76-v8",
    "supervisor": "2022.12.1",
    "host_os": "Home Assistant OS 9.4",
    "docker_version": "20.10.19",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {},
  "integration_manifest": {
    "domain": "zha",
    "name": "Zigbee Home Automation",
    "config_flow": true,
    "documentation": "https://www.home-assistant.io/integrations/zha",
    "requirements": [
      "bellows==0.34.6",
      "pyserial==3.5",
      "pyserial-asyncio==0.6",
      "zha-quirks==0.0.90",
      "zigpy-deconz==0.19.2",
      "zigpy==0.53.0",
      "zigpy-xbee==0.16.2",
      "zigpy-zigate==0.10.3",
      "zigpy-znp==0.9.2"
    ],
    "usb": [
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*2652*",
        "known_devices": [
          "slae.sh cc2652rb stick"
        ]
      },
      {
        "vid": "1A86",
        "pid": "55D4",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus v2"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*zigstar*",
        "known_devices": [
          "ZigStar Coordinators"
        ]
      },
      {
        "vid": "1CF1",
        "pid": "0030",
        "description": "*conbee*",
        "known_devices": [
          "Conbee II"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8A2A",
        "description": "*zigbee*",
        "known_devices": [
          "Nortek HUSBZB-1"
        ]
      },
      {
        "vid": "0403",
        "pid": "6015",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate+"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8B34",
        "description": "*bv 2010/10*",
        "known_devices": [
          "Bitron Video AV2010/10"
        ]
      }
    ],
    "codeowners": [
      "@dmulcahey",
      "@adminiuga",
      "@puddly"
    ],
    "zeroconf": [
      {
        "type": "_esphomelib._tcp.local.",
        "name": "tube*"
      },
      {
        "type": "_zigate-zigbee-gateway._tcp.local.",
        "name": "*zigate*"
      },
      {
        "type": "_zigstar_gw._tcp.local.",
        "name": "*zigstar*"
      },
      {
        "type": "_slzb-06._tcp.local.",
        "name": "slzb-06*"
      }
    ],
    "dependencies": [
      "file_upload"
    ],
    "after_dependencies": [
      "onboarding",
      "usb",
      "zeroconf"
    ],
    "iot_class": "local_polling",
    "loggers": [
      "aiosqlite",
      "bellows",
      "crccheck",
      "pure_pcapy3",
      "zhaquirks",
      "zigpy",
      "zigpy_deconz",
      "zigpy_xbee",
      "zigpy_zigate",
      "zigpy_znp"
    ],
    "is_built_in": true
  },
  "data": {
    "ieee": "**REDACTED**",
    "nwk": 24133,
    "manufacturer": "lk",
    "model": "ZB-MotionSensor-D0003",
    "name": "lk ZB-MotionSensor-D0003",
    "quirk_applied": false,
    "quirk_class": "zigpy.device.Device",
    "manufacturer_code": 4456,
    "power_source": "Battery or Unknown",
    "lqi": 126,
    "rssi": null,
    "last_seen": "2023-01-24T16:06:48",
    "available": true,
    "device_type": "EndDevice",
    "signature": {
      "node_descriptor": "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=4456, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, 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)",
      "endpoints": {
        "1": {
          "profile_id": 260,
          "device_type": "0x0402",
          "in_clusters": [
            "0x0000",
            "0x0001",
            "0x0003",
            "0x0020",
            "0x0500",
            "0x0b05",
            "0xfc81"
          ],
          "out_clusters": [
            "0x0019"
          ]
        }
      }
    },
    "active_coordinator": false,
    "entities": [
      {
        "entity_id": "binary_sensor.lk_zb_motionsensor_d0003_iaszone",
        "name": "lk ZB-MotionSensor-D0003"
      },
      {
        "entity_id": "button.lk_zb_motionsensor_d0003_identify",
        "name": "lk ZB-MotionSensor-D0003"
      },
      {
        "entity_id": "sensor.lk_zb_motionsensor_d0003_battery",
        "name": "lk ZB-MotionSensor-D0003"
      }
    ],
    "neighbors": [],
    "routes": [],
    "endpoint_names": [
      {
        "name": "IAS_ZONE"
      }
    ],
    "user_given_name": null,
    "device_reg_id": "4920654c5d5f2a7058834d9c24cedd6d",
    "area_id": "schlafzimmer",
    "cluster_details": {
      "1": {
        "device_type": {
          "name": "IAS_ZONE",
          "id": 1026
        },
        "profile_id": 260,
        "in_clusters": {
          "0x0000": {
            "endpoint_attribute": "basic",
            "attributes": {
              "0x0004": {
                "attribute_name": "manufacturer",
                "value": "lk"
              },
              "0x0005": {
                "attribute_name": "model",
                "value": "ZB-MotionSensor-D0003"
              }
            },
            "unsupported_attributes": {}
          },
          "0x0001": {
            "endpoint_attribute": "power",
            "attributes": {
              "0x0020": {
                "attribute_name": "battery_voltage",
                "value": 29
              },
              "0x0021": {
                "attribute_name": "battery_percentage_remaining",
                "value": 196
              },
              "0x0031": {
                "attribute_name": "battery_size",
                "value": 2
              },
              "0x0033": {
                "attribute_name": "battery_quantity",
                "value": 1
              }
            },
            "unsupported_attributes": {}
          },
          "0x0003": {
            "endpoint_attribute": "identify",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0020": {
            "endpoint_attribute": "poll_control",
            "attributes": {
              "0x0000": {
                "attribute_name": "checkin_interval",
                "value": 13200
              }
            },
            "unsupported_attributes": {}
          },
          "0x0500": {
            "endpoint_attribute": "ias_zone",
            "attributes": {
              "0x0000": {
                "attribute_name": "zone_state",
                "value": 1
              },
              "0x0001": {
                "attribute_name": "zone_type",
                "value": 13
              },
              "0x0002": {
                "attribute_name": "zone_status",
                "value": 48
              },
              "0x0010": {
                "attribute_name": "cie_addr",
                "value": [
                  132,
                  69,
                  183,
                  38,
                  0,
                  75,
                  18,
                  0
                ]
              }
            },
            "unsupported_attributes": {}
          },
          "0x0b05": {
            "endpoint_attribute": "diagnostic",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0xfc81": {
            "endpoint_attribute": "manufacturer_specific",
            "attributes": {},
            "unsupported_attributes": {}
          }
        },
        "out_clusters": {
          "0x0019": {
            "endpoint_attribute": "ota",
            "attributes": {},
            "unsupported_attributes": {}
          }
        }
      }
    }
  }
}
  ```
  
</details>
IMHO the `IasZone` needs a proper way to manage the 'extra' status:
* https://github.com/home-assistant/core/issues/72828

What I would suggest to you here will be:
* import the `MotionWithReset` class
```python
from zhaquirks import MotionWithReset
```
* use it in the replacement part:
```python
    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
                INPUT_CLUSTERS: [
                    LinkindBasicCluster,
                    PowerConfiguration.cluster_id,
                    Identify.cluster_id,
                    PollControl.cluster_id,
                    MotionWithReset,
                    Diagnostic.cluster_id,
                    LINKIND_CLUSTER_ID,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            }
        },
    }
```

This class will reset the sensor status at 30 seconds (if no movement detected).
If not working you can implement a custom cluster to do the same.
I can't believe it, **seems to work** 💙
![Google Chrome - Einstellungen – Home Assistant_2023-01-25_00 25 20@2x](https://user-images.githubusercontent.com/62359912/214443490-f2907564-53b0-47e2-bc03-e95f45619d68.png)

It would be great if someone else verified the current state for a pull request. Even though I might end up creating a custom cluster for this (see below)... But if considered working, I would see this maybe as a basic Version for getting support in ZHA. 👇

<details>
  <summary>Current quirk</summary>
  
  ```
"""Linkind ZB-MotionSensor-D0003."""
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
    Basic,
    Identify,
    Ota,
    PollControl,
    PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.security import IasZone

from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODELS_INFO,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
)
from zhaquirks.linkind import LinkindBasicCluster
from zhaquirks import MotionWithReset

LINKIND_CLUSTER_ID = 0xFC81

class LinkindD0003(CustomDevice):
    """Linkind ZB-MotionSensor-D0003."""

    signature = {
        MODELS_INFO: [("lk", "ZB-MotionSensor-D0003")],
        # <SimpleDescriptor endpoint=1 profile=260 device_type=1026
        # device_version=1 
        # input_clusters=[0, 1, 3, 32, 1280, 2821, 64641]
        # output_clusters=[25]>
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    PowerConfiguration.cluster_id,
                    Identify.cluster_id,
                    PollControl.cluster_id,
                    IasZone.cluster_id,
                    Diagnostic.cluster_id,
                    LINKIND_CLUSTER_ID,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            }
        },
    }

    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
                INPUT_CLUSTERS: [
                    LinkindBasicCluster,
                    PowerConfiguration.cluster_id,
                    Identify.cluster_id,
                    PollControl.cluster_id,
                    MotionWithReset,
                    Diagnostic.cluster_id,
                    LINKIND_CLUSTER_ID,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            }
        },
    }
  ```
  
</details>

So, just to get my Head around this: The MotionWithReset is basically taking the IasZone.cluster_id and interpreting the Return values differently (I remember the Translation example from the GitHub-Page)?

Thank you so much @javicalle  🙏
And 2 additional questions (So we even might beat Z2M's attributes):  

1. In Z2M there is also a Tamper "Entity". Is there a way to "extract" this too? (I guess this would need a custom cluster, right?)

~~2. To set the timeout to 2 Minutes (if I remember this correct, this is the default Reporting-Interval for the linkind), something like this would be required?~~
```
class MotionCluster(MotionWithReset):
    """Motion cluster."""

    reset_s: int = 120
    send_occupancy_event: bool = True
```
~~(And afterward of course using MotionCluster instead of MotionWithReset in replacement part)~~
Edit: Not necessary, forget about it 😅

3. There is a Cluster which says, "current_zone_sensitivity_level". Would it be possible to set these values to? If I recall correctly, I saw some Tuya quirks defining an enum where values like 0=low 1=med... were defined. This would require a custom cluster, right?

I'm glad that you get it working.

> The MotionWithReset is basically taking the IasZone.cluster_id and interpreting the Return values differently (I remember the Translation example from the GitHub-Page)?

No. What is doing is starting a counter every time that a status report is recieved:
https://github.com/zigpy/zha-device-handlers/blob/d0732016c78c12b4f28930ea6affd385140af44e/zhaquirks/__init__.py#L267-L270

The counter (at `reset_s` seconds) will 'clear' the `IasZone` status (and trigger an event):
https://github.com/zigpy/zha-device-handlers/blob/d0732016c78c12b4f28930ea6affd385140af44e/zhaquirks/__init__.py#L242-L246

About your questions:

> 1. In Z2M there is also a Tamper "Entity". Is there a way to "extract" this too?

IMHO that is a discussion for the ZHA integration and not for the quirk side.

Currently the `ZoneStatus` can report a bunch of events/status:
https://github.com/zigpy/zigpy/blob/297a2b0f364fe7a31de3b4966d70d1a67d432358/zigpy/zcl/clusters/security.py#L41-L54

In ZHA, only the `Alarm_1` and `Alarm_2` are considerated.
I see 2 approachs here:
* that the `IasZone` sensor becomes a multi-state sensor and exposes all possible values
* that new sensors be implemented for the rest of the status (`IasTamper`, `IasBattery`, ...)

The first approach is less friendly to manage and in automatizations.
The second one have the problem that there is no way to know which status will report any device. Then what to do? Create all the entities for all the status? Just a few? Create in disabled mode?
In Z2M has been addressed in their own way and ZHA must do theirs.

> 3\. There is a Cluster which says, "current_zone_sensitivity_level". Would it be possible to set these values to? If I recall correctly, I saw some Tuya quirks defining an enum where values like 0=low 1=med... were defined. This would require a custom cluster, right?

IMHO the goal of any quirk is to fix any functionality of the device that does not work due to a bad implementation of the zigbee standard. Period.
That is a clear example: the device reports the IasZone status but device is not usefull because doesn't restore the 'clear' status. A quirk to the rescue.
Does the device reports/implements any 'sensitivity level'? If it does and isn't working, I would try to fix it. But if the device doesn't implements it, IMHO we should not try to implement it programmatically (or at least add it to the library).


Thank you so much @javicalle and the time you put in your answer 💙

That really helped me out understanding how to approach it the ZHA way and gave me the possibility to take a look at some Motion-Quirks which were already created (and understand them better).

Do you have a PayPal-Link where I cloud give you a little something for the time you took explaining this stuff to me? (And for some questions I might have in the future 😁)
I'm glad to have been helpful.
Can you create the PR with the working code?

> Do you have a PayPal-Link where I cloud give you a little something for the time you took explaining this stuff to me?

I appreciate the offer but I don't have.
@dmulcahey, are there any tip/coffee/beer jar for this offerings or donations? 

Resolving patch:
diff --git a/zhaquirks/linkind/motion.py b/zhaquirks/linkind/motion.py
new file mode 100644
--- /dev/null
+++ b/zhaquirks/linkind/motion.py
@@ -0,0 +1,78 @@
+"""Linkind Motion Sensors."""
+from zigpy.profiles import zha
+from zigpy.quirks import CustomDevice
+from zigpy.zcl.clusters.general import (
+    Basic,
+    Identify,
+    Ota,
+    PollControl,
+    PowerConfiguration,
+)
+from zigpy.zcl.clusters.homeautomation import Diagnostic
+from zigpy.zcl.clusters.security import IasZone
+
+from zhaquirks import MotionWithReset
+from zhaquirks.const import (
+    DEVICE_TYPE,
+    ENDPOINTS,
+    INPUT_CLUSTERS,
+    MODELS_INFO,
+    OUTPUT_CLUSTERS,
+    PROFILE_ID,
+)
+from zhaquirks.linkind import LinkindBasicCluster
+
+LINKIND_CLUSTER_ID = 0xFC81
+
+
+class MotionClusterLinkind(MotionWithReset):
+    """Motion cluster."""
+
+    reset_s: int = 60
+
+
+class LinkindD0003(CustomDevice):
+    """Linkind ZB-MotionSensor-D0003."""
+
+    signature = {
+        MODELS_INFO: [("lk", "ZB-MotionSensor-D0003")],
+        # <SimpleDescriptor endpoint=1 profile=260 device_type=1026
+        # device_version=1
+        # input_clusters=[0, 1, 3, 32, 1280, 2821, 64641]
+        # output_clusters=[25]>
+        ENDPOINTS: {
+            1: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    PowerConfiguration.cluster_id,
+                    Identify.cluster_id,
+                    PollControl.cluster_id,
+                    IasZone.cluster_id,
+                    Diagnostic.cluster_id,
+                    LINKIND_CLUSTER_ID,
+                ],
+                OUTPUT_CLUSTERS: [Ota.cluster_id],
+            }
+        },
+    }
+
+    replacement = {
+        ENDPOINTS: {
+            1: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
+                INPUT_CLUSTERS: [
+                    LinkindBasicCluster,
+                    PowerConfiguration.cluster_id,
+                    Identify.cluster_id,
+                    PollControl.cluster_id,
+                    MotionClusterLinkind,
+                    Diagnostic.cluster_id,
+                    LINKIND_CLUSTER_ID,
+                ],
+                OUTPUT_CLUSTERS: [Ota.cluster_id],
+            }
+        },
+    }


Test patch: