zigpy / zha-device-handlers

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.
Apache License 2.0
773 stars 702 forks source link

[Device Support Request] _TZE200_iossyxra (Battery Roller Blind Motor) #960

Closed VladNord closed 2 years ago

VladNord commented 3 years ago

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

VladNord commented 3 years ago

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
MattWestb commented 3 years ago

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.

VladNord commented 3 years ago

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:

image
MattWestb commented 3 years ago

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.

MattWestb commented 3 years ago

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

mj1985 commented 3 years ago

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?

MattWestb commented 3 years ago

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 ?

Chreece commented 2 years ago

Hello,

I want to confirm that this product works with zha: https://zigbee.blakadder.com/Zemismart_AM15.html

Custom Quirk:

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?

mgwoj commented 2 years ago

From what I understand, this AM-15 Zigbee2RF dongle should mimic the original RF remote controller. This controller exists in versions supporting up to 16 different channels. Do you know how to provide channel ID in the Open/Close commands?

VladNord commented 2 years ago

you can check this article. its in Russian, but anyway

https://sprut.ai/client/article/3650

mgwoj commented 2 years ago

Thank you @VladNord for this article, but this is how I have setup it currently using Sonoff RF Bridge. I am looking how to control motors using Zigbee2RF USB dongle which can be bought with those motors - see the first link from this thread. My question is how to provide channel when sending Up/Down commands.

mgwoj commented 2 years ago

I have a answer to my previous question from the original instruction for ZM-AM15-02:

Pair more motor It can be paired to several motors, but all motors should be control together.

So there is no ability to select only one motor, if you need to tune one motor, you have to turn off the other ones.

So now my question is how to initiate the pairing operation between this dongle and the motor without Tuya App?