Repository: zigpy/zha-device-handlers

Issue:
[Device Support Request] _TZE200_gubdgai2 TS0601
**Is your feature request related to a problem? Please describe.**
I can connect it to ZHA, but it does not generate any sensors, switches or other.
It's a curtain motor.
Is it possible to integrate it?

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**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.**
<img width="306" alt="image" src="https://user-images.githubusercontent.com/58252398/122990600-71117980-d3a4-11eb-8e0a-0bc7ebae41da.png">


```
{
  "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, *allocate_address=True, *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": 260,
      "device_type": "0x0051",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0xef00"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZE200_gubdgai2",
  "model": "TS0601",
  "class": "zigpy.device.Device"
}
```

**Additional context**
I'm running Home Assistant Supervised 2021.6.6.


Discussion:
I was able to get the device to work.
However there are some oddities.
In the entity I can press the UP button, STOP button, but not the DOWN button.
But through the service: cover everything works.

ps: and the percentage shift does not work.

![immagine](https://user-images.githubusercontent.com/58252398/123326717-dd71b180-d539-11eb-8403-5dc576948847.png)

How did you get the upper and lower limits to work? The instructions I received do not work for me. How did you pair the device to home assistant?
> How did you get the upper and lower limits to work? The instructions I received do not work for me. How did you pair the device to home assistant?

To associate it with the zigbee: 
- press the set button once and it will flash red 
- immediately afterwards hold down the set again until it flashes again and starts flashing red
This step I managed. I paired it with a the zigbee home automation integration with a zigbee dongle directly in my Raspberry pi 4. It links with the following 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, *allocate_address=True, *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": 260,
      "device_type": "0x0051",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0xef00"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZE200_gubdgai2",
  "model": "TS0601",
  "class": "zigpy.device.Device"
}

But it does not give me options to go up, down or stop. I tried setting the upper and lower limit on the device itself as I thought this might be required, but I cannot get this to work. The instruction says to reset first by clicking on the set button and then the arrow up for 5 seconds. This does not always get a reset response. 
If i try to set the upper limit, I cannot bet a second light to blink. I both tried pressing the set button while the curtain is still going up, but this stops the curtain and pressing up then does not provide a response. And i tried setting it in the right position, pressing set and then up. Then the curtain just goes up. 

How did you get the lower and upper limit? Did you use the Tuya app for that?
Its one tuya device that is using the tuya cluster for commands (0xef00).
Therefor the device need one quirk for "converting" tuya commands to real Zigbee commands for working.
And the quirk loaded for the device is `"class": "zigpy.device.Device"` = no quirk.
> This step I managed. I paired it with a the zigbee home automation integration with a zigbee dongle directly in my Raspberry pi 4. It links with the following 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, *allocate_address=True, *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": 260,
> "device_type": "0x0051",
> "in_clusters": [
> "0x0000",
> "0x0004",
> "0x0005",
> "0xef00"
> ],
> "out_clusters": [
> "0x000a",
> "0x0019"
> ]
> }
> },
> "manufacturer": "_TZE200_gubdgai2",
> "model": "TS0601",
> "class": "zigpy.device.Device"
> }
> 
> But it does not give me options to go up, down or stop. I tried setting the upper and lower limit on the device itself as I thought this might be required, but I cannot get this to work. The instruction says to reset first by clicking on the set button and then the arrow up for 5 seconds. This does not always get a reset response.
> If i try to set the upper limit, I cannot bet a second light to blink. I both tried pressing the set button while the curtain is still going up, but this stops the curtain and pressing up then does not provide a response. And i tried setting it in the right position, pressing set and then up. Then the curtain just goes up.
> 
> How did you get the lower and upper limit? Did you use the Tuya app for that?

i can't use tuya app because i don't have a tuya bridge.

I changed __init__.py and ts0601.py to /usr/local/lib/python3.8/site-packages/zhaquirks/tuya

to line 87 of __init__.py I added:
```
     "_TZE200_gubdgai2": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001},
```
and to line 180 of ts0601.py I added:
```
             ("_TZE200_gubdgai2", "TS0601"),
```
i deleted 
```
rm -rf __pycache__
```
i restarted home assistant.


what I don't know is how and if possible to carry out a calibration and how to manage the percentages.
@pex81 if your device is working OK can you pleas making one PR so other user can getting there device working in ZHA  ?

If you have problem i can do it for you but i cant testing that the quirk is working OK then i dont have the device.


I think some users have problem getting the calibration working from ZHA and have making on the device and getting it working (i dot have the device so i dont knowing only have reading it).

Look on the earlier commits for blinds for more information.

I have posted one PR for adding the device and i hope its better then no quirk at all for the moment so user can start using the devices in ZHA.

Resolving patch:
diff --git a/zhaquirks/tuya/__init__.py b/zhaquirks/tuya/__init__.py
--- a/zhaquirks/tuya/__init__.py
+++ b/zhaquirks/tuya/__init__.py
@@ -89,6 +89,7 @@
     "_TZE200_rddyvrci": {0x0000: 0x0002, 0x0001: 0x0001, 0x0002: 0x0000},
     "_TZE200_3i3exuay": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001},
     "_TZE200_nueqqe6k": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001},
+    "_TZE200_gubdgai2": {0x0000: 0x0000, 0x0001: 0x0002, 0x0002: 0x0001},
 }
 # ---------------------------------------------------------
 # TUYA Switch Custom Values
diff --git a/zhaquirks/tuya/ts0601.py b/zhaquirks/tuya/ts0601.py
--- a/zhaquirks/tuya/ts0601.py
+++ b/zhaquirks/tuya/ts0601.py
@@ -229,6 +229,7 @@ class TuyaMoesCover0601(TuyaWindowCover):
             ("_TZE200_xuzcvlku", "TS0601"),
             ("_TZE200_rddyvrci", "TS0601"),
             ("_TZE200_nueqqe6k", "TS0601"),
+            ("_TZE200_gubdgai2", "TS0601"),
         ],  # Not tested
         ENDPOINTS: {
             1: {


Test patch: