Repository: zigpy/zha-device-handlers

Issue:
[Device Support Request] Develco Frient MOSZB-140 Motion Sensor Pro
**Is your feature request related to a problem? Please describe.**
I am able to pair the device, the temperature sensor works, but the battery sensor does not. Unclear on the multiple binary_sensor's, they seem to always be on.

**Describe the solution you'd like**
Add quirks for the Frient devices as needed. There is apparently [ZigBee2MQTT support](https://www.zigbee2mqtt.io/devices/MOSZB-140.html).

**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.**
```json
{
  "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=0, manufacturer_code=4117, maximum_buffer_size=80, maximum_incoming_transfer_size=80, server_mask=0, maximum_outgoing_transfer_size=80, descriptor_capability_field=0, *allocate_address=False, *complex_descriptor_available=False, *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, *is_valid=True, *logical_type=<LogicalType.EndDevice: 2>, *user_descriptor_available=False)",
  "endpoints": {
    "1": {
      "profile_id": 49353,
      "device_type": "0x0001",
      "in_clusters": [
        "0x0003",
        "0x0005",
        "0x0006"
      ],
      "out_clusters": []
    },
    "34": {
      "profile_id": 260,
      "device_type": "0x0107",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0406"
      ],
      "out_clusters": []
    },
    "35": {
      "profile_id": 260,
      "device_type": "0x0402",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x000f",
        "0x0020",
        "0x0500"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    },
    "38": {
      "profile_id": 260,
      "device_type": "0x0302",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0402"
      ],
      "out_clusters": [
        "0x0003"
      ]
    },
    "39": {
      "profile_id": 260,
      "device_type": "0x0106",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0400"
      ],
      "out_clusters": []
    },
    "40": {
      "profile_id": 260,
      "device_type": "0x0107",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0406"
      ],
      "out_clusters": []
    },
    "41": {
      "profile_id": 260,
      "device_type": "0x0107",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0406"
      ],
      "out_clusters": []
    }
  },
  "manufacturer": "frient A/S",
  "model": "MOSZB-140",
  "class": "zigpy.device.Device"
}
```

**Additional context**
ZHA Issue: https://github.com/home-assistant/core/issues/49127
Zigbee-Herdsman Converter: https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/devices/develco.js



Discussion:
Wondering if the root cause is the same as that described by dmulcahey in https://github.com/zigpy/zha-device-handlers/issues/605 issue? That is, a a limitation in [ZHA integration](https://www.home-assistant.io/integrations/zha/) for Home Assistant which currently only support 1 sensor per cluster, and these type of devices requiring 2 or more sensor per cluster?
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.
It's not resolved, but I've switched to using zigbee2mqtt where it does work. 
Bought a Develco Frient Motion Sensor Pro today (MOSZB-140) and having the issues described here with latest HA+ZHA. Could the issue be resolved in the next release or is there anything I can provide to get it to work with ZHA? 
Support here is still missing.
Can anyone please help add support for this device which is a top amazon seller in the UK. 
Bump. The above issue is still there. Please assist, as this device is now sold in a lot of places.
hello, i have this motion sensor too and is not work well with my haos. pairing is difficult ant battery status not reconize and tamper switch don't work. how do this motion sensor work?

same probleme with open sensor frient. WISZB-121by frient A/S

HAOS
Home Assistant 2022.9.7
Supervisor 2022.09.1
Operating System 9.0
Frontend 20220907.2 - latest

ZHA with conbee2

Signature open sensor
```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.NONE: 0>, manufacturer_code=4117, maximum_buffer_size=80, maximum_incoming_transfer_size=80, server_mask=0, maximum_outgoing_transfer_size=80, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=False, *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": 49353,
      "device_type": "0x0001",
      "in_clusters": [
        "0x0003",
        "0x0005",
        "0x0006"
      ],
      "out_clusters": []
    },
    "35": {
      "profile_id": 260,
      "device_type": "0x0402",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x000f",
        "0x0020",
        "0x0500"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "frient A/S",
  "model": "WISZB-121",
  "class": "zigpy.device.Device"
}
```

Signature motion sensor
```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.NONE: 0>, manufacturer_code=4117, maximum_buffer_size=80, maximum_incoming_transfer_size=80, server_mask=10752, maximum_outgoing_transfer_size=80, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=False, *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": 49353,
      "device_type": "0x0001",
      "in_clusters": [
        "0x0003",
        "0x0005",
        "0x0006"
      ],
      "out_clusters": []
    },
    "34": {
      "profile_id": 260,
      "device_type": "0x0107",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0406"
      ],
      "out_clusters": []
    },
    "35": {
      "profile_id": 260,
      "device_type": "0x0402",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x000f",
        "0x0020",
        "0x0500"
      ],
      "out_clusters": [
        "0x0003",
        "0x000a",
        "0x0019"
      ]
    },
    "38": {
   "profile_id": 260,
      "device_type": "0x0302",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0402"
      ],
      "out_clusters": []
    },
    "39": {
      "profile_id": 260,
      "device_type": "0x0106",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0400"
      ],
      "out_clusters": []
    },
    "40": {
      "profile_id": 260,
      "device_type": "0x0107",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0406"
      ],
      "out_clusters": []
    },
    "41": {
      "profile_id": 260,
      "device_type": "0x0107",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0406"
      ],
      "out_clusters": []
    }
  },
  "manufacturer": "frient A/S",
  "model": "MOSZB-140",
  "class": "zigpy.device.Device"
}
```

Resolving patch:
diff --git a/zhaquirks/develco/motion.py b/zhaquirks/develco/motion.py
new file mode 100644
--- /dev/null
+++ b/zhaquirks/develco/motion.py
@@ -0,0 +1,213 @@
+"""Develco Motion Sensor Pro."""
+
+from zigpy.profiles import zha
+from zigpy.quirks import CustomDevice
+from zigpy.zcl.clusters.general import (
+    Basic,
+    BinaryInput,
+    Identify,
+    OnOff,
+    Ota,
+    PollControl,
+    PowerConfiguration,
+    Scenes,
+    Time,
+)
+from zigpy.zcl.clusters.measurement import (
+    IlluminanceMeasurement,
+    OccupancySensing,
+    TemperatureMeasurement,
+)
+from zigpy.zcl.clusters.security import IasZone
+
+from zhaquirks.const import (
+    DEVICE_TYPE,
+    ENDPOINTS,
+    INPUT_CLUSTERS,
+    MODELS_INFO,
+    OUTPUT_CLUSTERS,
+    PROFILE_ID,
+)
+from zhaquirks.develco import DEVELCO, FRIENT, DevelcoIasZone, DevelcoPowerConfiguration
+
+MANUFACTURER = 0x1015
+
+
+class MOSZB140(CustomDevice):
+    """Custom device Develco Motion Sensor Pro."""
+
+    manufacturer_id_override = MANUFACTURER
+
+    signature = {
+        # <SimpleDescriptor endpoint=1 profile=49353 device_type=1 device_version=1
+        # input_clusters=[3, 5, 6] output_clusters=[]>
+        # <SimpleDescriptor endpoint=34 profile=260 device_type=263 device_version=0
+        # input_clusters=[0, 3, 1030] output_clusters=[]>
+        # <SimpleDescriptor endpoint=35 profile=260 device_type=1026 device_version=0
+        # input_clusters=[0, 1, 3, 15, 32, 1280] output_clusters=[10, 25]>
+        # <SimpleDescriptor endpoint=38 profile=260 device_type=770 device_version=0
+        # input_clusters=[0, 3, 1026] output_clusters=[3]>
+        # <SimpleDescriptor endpoint=39 profile=260 device_type=262 device_version=0
+        # input_clusters=[0, 3, 1024] output_clusters=[]>
+        # <SimpleDescriptor endpoint=40 profile=260 device_type=263 device_version=0
+        # input_clusters=[0, 3, 1030] output_clusters=[]>
+        # <SimpleDescriptor endpoint=41 profile=260 device_type=263 device_version=0
+        # input_clusters=[0, 3, 1030] output_clusters=[]>
+        MODELS_INFO: [(DEVELCO, "MOSZB-140"), (FRIENT, "MOSZB-140")],
+        ENDPOINTS: {
+            1: {
+                PROFILE_ID: 0xC0C9,
+                DEVICE_TYPE: 1,
+                INPUT_CLUSTERS: [
+                    Identify.cluster_id,
+                    Scenes.cluster_id,
+                    OnOff.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [],
+            },
+            34: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    Identify.cluster_id,
+                    OccupancySensing.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [],
+            },
+            35: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    PowerConfiguration.cluster_id,
+                    Identify.cluster_id,
+                    BinaryInput.cluster_id,
+                    PollControl.cluster_id,
+                    IasZone.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [
+                    Time.cluster_id,
+                    Ota.cluster_id,
+                ],
+            },
+            38: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    Identify.cluster_id,
+                    TemperatureMeasurement.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [Identify.cluster_id],
+            },
+            39: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.LIGHT_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    Identify.cluster_id,
+                    IlluminanceMeasurement.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [],
+            },
+            40: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    Identify.cluster_id,
+                    OccupancySensing.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [],
+            },
+            41: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    Identify.cluster_id,
+                    OccupancySensing.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [],
+            },
+        },
+    }
+
+    replacement = {
+        ENDPOINTS: {
+            1: {
+                PROFILE_ID: 0xC0C9,
+                DEVICE_TYPE: 1,
+                INPUT_CLUSTERS: [
+                    Identify.cluster_id,
+                    Scenes.cluster_id,
+                    OnOff.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [],
+            },
+            34: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    Identify.cluster_id,
+                    OccupancySensing.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [],
+            },
+            35: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    DevelcoPowerConfiguration,
+                    Identify.cluster_id,
+                    BinaryInput.cluster_id,
+                    PollControl.cluster_id,
+                    DevelcoIasZone,
+                ],
+                OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
+            },
+            38: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    Identify.cluster_id,
+                    TemperatureMeasurement.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [Identify.cluster_id],
+            },
+            39: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.LIGHT_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    Identify.cluster_id,
+                    IlluminanceMeasurement.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [],
+            },
+            40: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    Identify.cluster_id,
+                    OccupancySensing.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [],
+            },
+            41: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    Identify.cluster_id,
+                    OccupancySensing.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [],
+            },
+        }
+    }


Test patch:
diff --git a/tests/test_develco.py b/tests/test_develco.py
new file mode 100644
--- /dev/null
+++ b/tests/test_develco.py
@@ -0,0 +1,66 @@
+"""Tests for Develco/Frient A/S quirks."""
+
+import zhaquirks.develco.motion
+
+
+def test_motion_signature(assert_signature_matches_quirk):
+    """Test Develco Motion Sensor Pro signature is matched to its quirk."""
+    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.NONE: 0>, manufacturer_code=4117, maximum_buffer_size=80, maximum_incoming_transfer_size=80, server_mask=0, maximum_outgoing_transfer_size=80, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=False, *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": 49353,
+                "device_type": "0x0001",
+                "in_clusters": ["0x0003", "0x0005", "0x0006"],
+                "out_clusters": [],
+            },
+            "34": {
+                "profile_id": 260,
+                "device_type": "0x0107",
+                "in_clusters": ["0x0000", "0x0003", "0x0406"],
+                "out_clusters": [],
+            },
+            "35": {
+                "profile_id": 260,
+                "device_type": "0x0402",
+                "in_clusters": [
+                    "0x0000",
+                    "0x0001",
+                    "0x0003",
+                    "0x000f",
+                    "0x0020",
+                    "0x0500",
+                ],
+                "out_clusters": ["0x000a", "0x0019"],
+            },
+            "38": {
+                "profile_id": 260,
+                "device_type": "0x0302",
+                "in_clusters": ["0x0000", "0x0003", "0x0402"],
+                "out_clusters": ["0x0003"],
+            },
+            "39": {
+                "profile_id": 260,
+                "device_type": "0x0106",
+                "in_clusters": ["0x0000", "0x0003", "0x0400"],
+                "out_clusters": [],
+            },
+            "40": {
+                "profile_id": 260,
+                "device_type": "0x0107",
+                "in_clusters": ["0x0000", "0x0003", "0x0406"],
+                "out_clusters": [],
+            },
+            "41": {
+                "profile_id": 260,
+                "device_type": "0x0107",
+                "in_clusters": ["0x0000", "0x0003", "0x0406"],
+                "out_clusters": [],
+            },
+        },
+        "manufacturer": "frient A/S",
+        "model": "MOSZB-140",
+        "class": "develco.motion.MOSZB140",
+    }
+
+    assert_signature_matches_quirk(zhaquirks.develco.motion.MOSZB140, signature)