Repository: zigpy/zha-device-handlers

Issue:
[Device Support Request] _TZE200_iossyxra (Battery Roller Blind Motor)
**Is your feature request related to a problem? Please describe.**
Bought ZigBee Lithium Battery Roller Blind Motor. It does pair, but it does not expose any status, so I can't control it from HA

**Describe the solution you'd like**
Possibility to control it from HA

**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.**
```
"NodeDescriptor(byte1=1, byte2=64, mac_capability_flags=142, manufacturer_code=4098, 
maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, 
maximum_outgoing_transfer_size=82, descriptor_capability_field=0, 
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0051",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0xef00"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZE200_iossyxra",
  "model": "TS0601",
  "class": "zigpy.device.Device"
}
```

**Additional context**
Product: https://aliexpress.ru/item/4000764153310.html?spm=a2g39.orderlist.0.0.47ce4aa67PXmvK&_ga=2.58309290.1271432921.1626213995-1279367481.1621973111




Discussion:
After dancing with a tambourine, I found half-working solution with adding such code to  
**__init__.py**      `"_TZE200_iossyxra": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001},`into # TUYA Cover Custom Values block
and **ts0601.py** `("_TZE200_iossyxra", "TS0601"),`into class TuyaMoesCover0601(TuyaWindowCover)

After these device is detected correctly, but blind buttons functionality from HA doesn't working (Error calling service)

But it can works, using this code in service call at dev tools

```
service: zha.issue_zigbee_cluster_command
data:
  ieee: '84:71:27:ff:fe:0e:18:00'
  endpoint_id: 1
  cluster_id: 258
  cluster_type: in
  command_type: server
  command: 6
  args:
    - 0
    - 0
    - 1025
    - 0
    - - 0
      - 0 or 1 or 2
```

I think your quirk is OK but you need deleting the `__pycache__` in the tuya quirk folder or the system is using some old setting / code.

Also if the buttons is not working as expected try changing the settings for them in **init.py** so up is up and down is down and you can stopping the movement.
> I think your quirk is OK but you need deleting the `__pycache__` in the tuya quirk folder or the system is using some old setting / code.
> 
> Also if the buttons is not working as expected try changing the settings for them in **init.py** so up is up and down is down and you can stopping the movement.

Cache cleared, tried different combinations in init.py, but no luck.

With this `"_TZE200_iossyxra": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001}` set in HA result following:

<img width="381" alt="image" src="https://user-images.githubusercontent.com/51515620/128790064-4e14bf00-5fd8-4700-853c-7e74944b9fcb.png">

I think (= not knowing) the if the blind is not 100% open or closed and is not moving then your key mapping is wrong. Then is cant being stopped then its not moving and it can being commanded moving up and down but your picture is showing down is not possible activating (or the blind is 100% down and still moving but i dont  think so).

In the `TuyaWindowCoverControl` cluster you shall having direction and inverted.
https://github.com/zigpy/zha-device-handlers/blob/8c61c6da4e44906183a4d96e022e67f8c2ba005d/zhaquirks/tuya/__init__.py#L804-L805
Try changing them and see if its working OK

Also you can  try using the https://github.com/zigpy/zha-device-handlers/blob/8c61c6da4e44906183a4d96e022e67f8c2ba005d/zhaquirks/tuya/ts0601.py#L121
its looks having the same signature but have disabling the time cluster (that is normal for tuya devices) and perhaps its making the device working OK.

I dont have the device for testing  but little brainstorming i can helping with.
Is it still not working ?
Its 2 PR that is fixing the inverting mode and some communication with the tuya MCU ?
https://github.com/zigpy/zha-device-handlers/pull/1130 https://github.com/zigpy/zha-device-handlers/pull/1115
I added this line:
`"_TZE200_iossyxra": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001}`
to the file `ts0601_cover.py` and edited ´__init__.py´ file with the latest changes of the dev-branch, but I still get an error of calling the server. Anything I have missed?
I think the combination in https://github.com/zigpy/zha-device-handlers/issues/960#issuecomment-895637580 is wrong then if the blind is 100 or 0 % only one button shall being possible activating and if its not 100 or 0% both up and down shall being possible activating. Then the blinds is "on the move" the stop shall being possible activating.

Can you posting the error from the log ?
Hello,

I want to confirm that this product works with zha:
https://zigbee.blakadder.com/Zemismart_AM15.html

Custom Quirk:
```from zigpy.profiles import zha
from zigpy.zcl.clusters.general import Basic, Groups, Ota, Scenes, Time

from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODELS_INFO,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
)
from zhaquirks.tuya import (
    TuyaManufacturerClusterOnOff,
    TuyaManufacturerWindowCover,
    TuyaManufCluster,
    TuyaOnOff,
    TuyaSwitch,
    TuyaWindowCover,
    TuyaWindowCoverControl,
)

class TuyaZemismartSmartCover0601_2(TuyaWindowCover):
    """Tuya Zemismart curtain cover motor."""

    signature = {
        # "node_descriptor": "<NodeDescriptor byte1=1 byte2=64 mac_capability_flags=142 manufacturer_code=4098
        #                       maximum_buffer_size=82 maximum_incoming_transfer_size=82 server_mask=11264
        #                       maximum_outgoing_transfer_size=82 descriptor_capability_field=0>",
        # input_clusters=[0x0000, 0x000a, 0x0004, 0x0005, 0xef00]
        # output_clusters=[0x0019]
        # <SimpleDescriptor endpoint=1 profile=260 device_type=81 input_clusters=[0, 10, 4, 5, 61184] output_clusters=[25]>
        MODELS_INFO: [
            ("_TZE200_3i3exuay", "TS0601"),
        ],
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Time.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    TuyaManufCluster.cluster_id,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            },
        },
    }
    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    Time.cluster_id,
                    TuyaManufacturerWindowCover,
                    TuyaWindowCoverControl,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            },
        },
    }


class TuyaMoesCover0601(TuyaWindowCover):
    """Tuya blind controller device."""

    signature = {
        # "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098,
        #                    maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264,
        #                    maximum_outgoing_transfer_size=82, descriptor_capability_field=0)",
        # "endpoints": {
        # "1": { "profile_id": 260, "device_type": "0x0051", "in_clusters": [ "0x0000", "0x0004","0x0005","0xef00"], "out_clusters": ["0x000a","0x0019"] }
        # },
        # "manufacturer": "_TZE200_zah67ekd",
        # "model": "TS0601",
        # "class": "zigpy.device.Device"
        # }
        MODELS_INFO: [
            ("_TZE200_zah67ekd", "TS0601"),
            ("_TZE200_xuzcvlku", "TS0601"),
            ("_TZE200_rddyvrci", "TS0601"),
            ("_TZE200_iossyxra", "TS0601"),
        ],
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    TuyaManufCluster.cluster_id,
                ],
                OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
            }
        },
    }

    replacement = {
        ENDPOINTS: {
            1: {
                DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    TuyaManufacturerWindowCover,
                    TuyaWindowCoverControl,
                ],
                OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
            }
        }
    }
```
   
Adding this in line __init__.py for TUYA_COVER_COMMAND:
```
"_TZE200_iossyxra": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001},
```

Can someone implement this to work out of the box?

Resolving patch:
diff --git a/zhaquirks/tuya/__init__.py b/zhaquirks/tuya/__init__.py
--- a/zhaquirks/tuya/__init__.py
+++ b/zhaquirks/tuya/__init__.py
@@ -106,6 +106,7 @@
     "_TZE200_5sbebbzs": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001},
     "_TZE200_xaabybja": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001},
     "_TZE200_hsgrhjpf": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001},
+    "_TZE200_iossyxra": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001},
 }
 # Taken from zigbee-herdsman-converters
 # Contains all covers which need their position inverted by default
diff --git a/zhaquirks/tuya/ts0601_cover.py b/zhaquirks/tuya/ts0601_cover.py
--- a/zhaquirks/tuya/ts0601_cover.py
+++ b/zhaquirks/tuya/ts0601_cover.py
@@ -79,6 +79,7 @@ class TuyaZemismartSmartCover0601_3(TuyaWindowCover):
         # <SimpleDescriptor endpoint=1 profile=260 device_type=51 input_clusters=[0, 4, 5, 61184] output_clusters=[25]>
         MODELS_INFO: [
             ("_TZE200_fzo2pocs", "TS0601"),
+            ("_TZE200_iossyxra", "TS0601"),
         ],
         ENDPOINTS: {
             1: {


Test patch: