home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.11k stars 29.79k forks source link

Cover position is inverted #49783

Closed eye-7 closed 3 years ago

eye-7 commented 3 years ago

The problem

I have connected a QS-Zigbee-C01 blind controller with ZHA. It "works", when I click on up arrow blind goes up and when I click on down arrow bling goes down. However, when blind goes up HA says "it is closing" and when blind is at the top state is closed and position 0. When blind is at the bottom state is opened and position is 100. I may accept to name things the opposite they are, but it has other implications i.e. when the blind is at top, HA consider it is closed and therefore disable go down button when really is the only direction it could go, so I can only use the possition slider to open it. How could it be fix? System is a fresh installation running on a Synology DS216J (package of synocomunity)

What is version of Home Assistant Core has the issue?

2021.1.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

ZHA

Link to integration documentation on our website

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

probot-home-assistant[bot] commented 3 years ago

Hey there @dmulcahey, @adminiuga, mind taking a look at this issue as its been labeled with an integration (zha) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

Adminiuga commented 3 years ago

zigbee device signature?

eye-7 commented 3 years ago

ZHA shows the following:

{
  "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)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0202",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0x0102"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZ3000_vd43bbfq",
  "model": "TS130F",
  "class": "zigpy.device.Device"
}

Really, as showed here #https://github.com/dresden-elektronik/deconz-rest-plugin/issues/3939, it has more clusters, i.e. calibration mode (0xF001) and Motor Reversal (0xF002) which are currently not supported by ZHA and the use of denconz is not an option for me as it is not availabe for my NAS CPU architecture. In any case, that's another topic.

Adminiuga commented 3 years ago

to have the 0xF001 calibration attribute, you would need to create a quirk in zigpy/zha-device-handlers. Can you read id 0x0007-Config Status and 0x0017-window covering mode attributes of the "Window Covering" cluster?

eye-7 commented 3 years ago

When I hit "get zigbee attribute" the following apperars:

No warning is shown and I checked the log and no info is shown either, so I not sure if this is the actual value or thats the response because it is not read. Regarding the calibration, I take note and I will investigate it. By the moment I solved it making the calibration in deconz running in windows and repairing it with the Synology taking advange that the device does not loose these parameters after reset.

eye-7 commented 3 years ago

Hello, I have installed two blinds more and I find always the same issue. I have tried to make the calibration in the opposite way, this is move from the top to the bottom and again to the top, but it didn't have any effect. Any suggestion?

Adminiuga commented 3 years ago

the cover does not support the configuration attribute which controls inverting. This would require a custom quirk in zha-device-handlers. Maybe one of the existing ones could be adopted

eye-7 commented 3 years ago

I have learn that in fact a quirk for this device already exists and as far as check, it seems it should solve all the issues listed above: https://github.com/zigpy/zha-device-handlers/pull/875 https://github.com/zigpy/zha-device-handlers/issues/869 As far as I read, quirks load automatically and in fact I have not found any option to enable them or not. I have check that zha-quick package is installed in the ha enviroment I figure out that I am missing some step, but I don't know which. Kind regards

Adminiuga commented 3 years ago

Check if it matches model and manufacturer. Tuya makes it difficult, by white label ing different vendors with different models

eye-7 commented 3 years ago

It matches, but I have found that this quirk is quite recent and was included at latest realase last week. I have installed 0.0.51 and current version is 0.0.57. I try updating zhaquirk package by pip (what is done sucessfully) but then when I restart HA i get the following:

Logger: homeassistant.setup Source: setup.py:138 First occurred: 22:34:41 (1 occurrences) Last logged: 22:34:41 Setup failed for zha: Requirements for zha not found: ['zha-quirks==0.0.51'].

By the moment I have downgrade again zhaquirk, and now it does not work also:

Logger: homeassistant.setup Source: setup.py:138 First occurred: 22:57:32 (1 occurrences) Last logged: 22:57:32 Setup failed for zha: Requirements for zha not found: ['zigpy==0.30.0'].

How can I restore previous configurationa or even better, how should I update this package to make it run in HA,? It is possible just to copy the quirk files into the directories?

Adminiuga commented 3 years ago

depends on HA installation method. Check the "testing" section of zha-device-handlers

Adminiuga commented 3 years ago

the existing quirk for TS130F has a different signature, that's why it doesn't match. Tuya is worse than xiaomi. to make it work, find tuya/ts130f.py file in your container and add the following

class TuyaTS130F2(CustomDevice):
    """Tuya smart curtain roller shutter."""

    signature = {
        # SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=0x0202, device_version=1, input_clusters=[0, 4, 5, 6, 10, 0x0102], output_clusters=[25]))
        MODELS_INFO: [("_TZ3000_vd43bbfq", "TS130F")],
        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,
                    WindowCovering.cluster_id,
                ],
                OUTPUT_CLUSTERS: [Time.cluster_id, 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,
                    TuyaCoveringCluster,
                ],
                OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
            },
        },
    }
Adminiuga commented 3 years ago

Install latest HA Core release with all the ZHA requirements from zha manifest file. Then modify the ts130f.py file in your venv.

eye-7 commented 3 years ago

It works! I have to reinstall the original zha packages as during the installation: https://community.home-assistant.io/t/zha-with-hacore-at-synology-ds216j/298333 Note that zhaquirk package at 0.51 version does not include the ts130f.py file, so I downloaded it, I have modified it following your indications and copied it at "Tuya" dir. Now status of the cover and rolling direction is correct.

By the way, now calibration(0xf001) is shown at TuyaCoverinCluster, but I am not sure how can I activate it or not. What value must be used and where should it be indicated?

Adminiuga commented 3 years ago

0.0.51 version was released for HA core 2020.12.0 version. You need to upgrade your ha core, otherwise something is very wrong with your installation or dependencies if you still using 0.0.51

Adminiuga commented 3 years ago

FYI, HA Core 2021.5.x uses zha-device-handlers==0.0.57 https://github.com/home-assistant/core/blob/2021.5.2/homeassistant/components/zha/manifest.json

Check your install and have correct dependencies installed. Open a PR to have your model included into TS130F quirk.

I'm going to close this issue here, since the dependencies are so out of the date and we cannot support it. This device is not following Zigbee ZCL specifications, so it requires a quirk update. Open an Issue or better submit a PR to zha-device-handlers repository. Possibly there other users with the same device #zigbee channel on HA discord server, check there