Impossible to set middle positions to Zigbee cover

Hello,

I have configured the following Zigbee cover using ZHA

{
  "node_descriptor": {
    "logical_type": 1,
    "complex_descriptor_available": 0,
    "user_descriptor_available": 0,
    "reserved": 0,
    "aps_flags": 0,
    "frequency_band": 8,
    "mac_capability_flags": 142,
    "manufacturer_code": 4417,
    "maximum_buffer_size": 66,
    "maximum_incoming_transfer_size": 66,
    "server_mask": 10752,
    "maximum_outgoing_transfer_size": 66,
    "descriptor_capability_field": 0
  },
  "endpoints": {
    "1": {
      "profile_id": "0x0104",
      "device_type": "0x0203",
      "input_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0102",
        "0xe001"
      ],
      "output_clusters": [
        "0x000a",
        "0x0019"
      ]
    },
    "242": {
      "profile_id": "0xa1e0",
      "device_type": "0x0061",
      "input_clusters": [],
      "output_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "_TZ3000_femsaaua",
  "model": "TS130F",
  "class": "zhaquirks.tuya.ts130f.TuyaTS130ESTC"
}

and calibrated the time using the cluster settings. The 0% and 100% work properly. However, I’m not able to set the cover to a middle position. For example, if I try to set it to from 0% to 30%, then it opens completely to 100%, but the app still shows 30%.

Is there something I can do?

I think the problem is related to this issue, where they fixed using a custom component and an automation. I was wondering if there is a native way to make it working.

In the TuyaCoveringCluster, I don’t see any field for setting the percentage position. However, when I move it manually, the position is updated properly.

Are you able to set a percentage in z2m or the Tuya app?

I don’t have a tuya app, I have directly paired them using the Sonoff Zigbee dongle and ZHA. I’m not using Zigbee2MQTT.

Doesn’t look like it’s an issue with ZHA, they do the same thing in z2m. Curtain switch positioning doesn't work (TS130F). · Issue #15079 · Koenkk/zigbee2mqtt · GitHub

Yes, indeed. Very strange.

I’m opting for a custom component to create a time based cover.

I compared all these devices with a working one of another home assistant apartment.

Both the working and non-working devices are very similar. Although they are from a different manufacturer, they are identical in everything.

I bought the working Zigbee cover controller a couple of years ago, and it always worked very well, even the percentage position. All the TuyaCluster settings are exactly the same (except for the calibration time). I only noticed that the working one have an earlier software version, and that it’s using a different aha quirk.

This is the working one

This is the non-working one

can I try to change the quirk to the working one? If yes, how?

Moreover, I’m pretty sure I can try to update the firmware, as there is a custom firmware update here. I tried to set the aha settings

zha:
  zigpy_config:
    ota:
      extra_providers:
        - type: z2m

in order to enable the z2m updates, but it doesn’t do anything for both thew working and non-working device.

Both of those quirks use the same cover cluster, so it wouldn’t actually change anything. It’s not working with z2m or zha, so unless it works properly with a Tuya hub, it’s a device issue. If it does work with a Tuya hub, someone would likely need to capture the traffic between the Tuya hub and the device to find out why it’s not working correctly with zha and z2m.

1 Like

Ok, I have noticed that if I hold press the physical buttons, the percentage position in home assistant is updated. If I press and release the physical buttons, then the cover move without keep pressing, but in this way the position is not updated in ha.

It seems that a firmware update may fix this issue. This is exactly the module I have. I bought the working one on AliExpress two years ago, and the non-working ones on Amazon ITA. All of them are LoraTap. I was wondering if I can perform the firmware upgrade, since it is available in the z2m repository, as I showed above. I don’t understand if the non-working devices have the latest version, but for sure the working one doesn’t.

Hello Alberto
I have a similar LoraTap module (it’s pink and not orange), but essentially the same.

I believe I have the same issue as you, the curtains close, open and stop correctly, but I can never set middle positions via HomeAssistant.

Did you ever figured out the solution?

I am using Deconz but that should not make any difference. The LoraTap controller does not support a set position function. The Tuya app does the job based on the opening and closing time.
So first calibrate the cover control or measure the time it takes to open or close the cover.

Than create a template cover in HA configuration:

      cover_15_inverted:
        friendly_name: "Cover 15 inverted"
        device_class: shutter
        position_template: "{{ 100 - (state_attr('cover.window_covering_device_15', 'current_position') | int) }}"
        open_cover:
          service: cover.open_cover
          target:
            entity_id: cover.window_covering_device_15
        close_cover:
          service: cover.close_cover
          target:
            entity_id: cover.window_covering_device_15
        stop_cover:
          service: cover.stop_cover
          target:
            entity_id: cover.window_covering_device_15
        set_cover_position:
          service: script.set_position_cover_15
          data:
            position: "{{ position }}"
cover.window_covering_device_15 

is the cover as discovered by the Zigbee hub and discovered in Home Assistant.

cover.cover_15_inverted

is the cover you are going to use in HA for your automations. Check first if you need to invert the percentages of open and close. For Deconz I had to invert the percentage. I don’t know about ZHA or Z2M.

Then create the script which converts a desired open/close percentage to a time the motor should roll and which direction:

set_position_cover_15:
  alias: Set position cover 15 inverted
  mode: restart
  sequence:
  - variables:
      current: '{{ 100 - (state_attr(''cover.window_covering_device_15'', ''current_position'')
        | int(0)) }}'
      target: '{{ position | int }}'
      total_time: 21.2
  - choose:
    - conditions:
      - condition: template
        value_template: '{{ target < current }}'
      sequence:
      - target:
          entity_id: cover.window_covering_device_15
        action: cover.close_cover
        data: {}
      - delay: '{{ (current - target) / 100 * total_time }}'
      - target:
          entity_id: cover.window_covering_device_15
        action: cover.stop_cover
        data: {}
    - conditions:
      - condition: template
        value_template: '{{ target > current }}'
      sequence:
      - target:
          entity_id: cover.window_covering_device_15
        action: cover.open_cover
        data: {}
      - delay: '{{ (target - current) / 100 * total_time }}'
      - target:
          entity_id: cover.window_covering_device_15
        action: cover.stop_cover
        data: {}

In my case it took 21.2 seconds to open/close the cover. Enter your own time here.
Then use “cover.cover_15_inverted” in your dashboards and automation. Not “cover.window_covering_device_15”

Nice to see you all having the same issue has someone figured out to set the native cover to any percent without the cover going to 0/100%? I tried loads of things from using Hacs integration of the time based cover to a synced time based cover but nothing works as it should. my problem is that i want to use the physical inputs for a switch to also control the motor which also syncronises to Hass but i want to use the setposition for automations but if i use a time based cover over it, it won’t read the position of the loratap.