Does ZHA not support tilt for covers/blinds?

Hi,

I’m trying to correctly add a cover/blinds device to ZHA. Position related attributes and commands work, but tilt doesn’t.

What’s weird about this is that I can query the current tilt position without problems using the Zigbee Clusters GUI. The attribute current_position_tilt_percentage (0x0009) in the cluster WindowCovering (0x0102 in endpoint 6) returns the value. So the device seems to report it correctly, but ZHA isn’t using it.

I’ve tried adding the following to configuration.yaml, but all it does is change the icon of the entities.

homeassistant:
  # Customize all entities in a domain
  customize_domain:
    cover:
      device_class: blind

Since I’m a software developer myself (although not in Python) I had a look at the code. There is no mention of “tilt” at all in core/cover.py at a29afc3731fb48a875144f06e6054a604985cf60 · home-assistant/core · GitHub. Does that mean that ZHA doesn’t support tilt for covers at all?

Related device support request: [Device Support Request] Insta GmbH Nexentro Blinds Actuator Mini · Issue #1397 · zigpy/zha-device-handlers · GitHub

I agree, the ZHA code is missing, the relevant attributes and commands available in the zigpy cluster definition.

HA supports this type of functionnality according to the constants : core/homeassistant/components/cover at 4bb2c6e00fd60e768a7f52c2745fb62c88748b61 · home-assistant/core · GitHubinit.py#L73-L80

So that means that the zha cover implementation needs to be extended.

2 Likes

Thanks for the confirmation!

How can I go from here to get this implemented?

I’d offer to implement this myself, but since I know neither Python nor the HA code base, and don’t have a second Zigbee USB stick to debug it, that would be very time consuming or maybe not even possible for me :frowning:

But if anyone is willing to implement it I’d be happy to help with testing!

The manifest for zha lists @dmulcahey and @adminiuga as the code owners.

I suggest that you add a follow up message on the github issue that you mentionned.

@cremor While there is no guarantees of replies from developers it could be a good idea to also start a new ZHA development discussion here → https://github.com/zigpy/zigpy/discussions/

Also, start a new separate dedicated feature request for any missing feature or function for community tracking regardless of response → https://community.home-assistant.io/c/feature-requests/13

For reference that means extending support in cover.py for zha component inside Home Assistant core:

https://github.com/home-assistant/core/blob/ead5b3e2c066fad5a8609c4eddd6dd6f777b6edc/homeassistant/components/zha/cover.py

https://github.com/home-assistant/core/tree/dev/homeassistant/components/zha

Temporary workaround until there is native tilt support for cover in ZHA could be to experiment with automatisations using ZHA toolkit and dumpfheimer framework for generic exposure of device configuration attributes. See → https://github.com/zigpy/zigpy/discussions/934 and https://github.com/mdeweerd/zha-toolkit + "zha-toolkit" - Toolkit providing low and high level Zigbee commands through ZHA/zigpy

Done, thanks for the suggestion.

Would this really be the correct place? Zigpy already supports tilt for covers (I can see and read the attributes in the Zigbee cluster on the device page). It’s just ZHA that is missing functionality.

Done, thanks for the suggestion: Support tilt for covers in ZHA

I’d need to have a look at this, but would that also let me set the tilt position (so a replacement for “cover.set_cover_tilt_position”)?

@cremor ZHA-Toolkit will let you set tilt positions - you can send zigbee commands using zha-toolkit.

2 Likes

Thanks to the documentation of zha-toolkit I now figured out that I don’t even need zha-toolkit to set the tilt position. (Btw, I would have figured this out way earlier if home-assistant/frontend#10633 would have been fixed already.)
The following script works:

alias: Set cover tilt position
mode: single
icon: mdi:boom-gate-up
fields:
  entity:
    name: Entity
    required: true
    selector:
      entity:
        domain: cover
  value:
    name: Value
    required: true
    selector:
      number:
        min: 0
        max: 100
sequence:
  - service: zha.issue_zigbee_cluster_command
    data:
      ieee: '{{ (device_attr(entity, "identifiers") | list).0.1 }}'
      endpoint_id: 6
      cluster_id: 258
      command: 8
      command_type: server
      args:
        - '{{ 100 - value }}'

(Getting the IEEE would be easier/nicer with zha-toolkit, but that’s fine for me now.)

Endpoint, cluster and command ids are the ones from the Zigbee standard, so nothing device or vendor specific is needed. Zigpy also already supports those as a go_to_tilt_percentage command: zigpy/closures.py at 0c4b9a8a25c5eef5b008d66c2e56aae3f8d5e769 · zigpy/zigpy · GitHub
It’s just ZHA which is not using the functionality provided by Zigpy.

I’ll check how to use zha-toolkit to get the current tilt position as an attribute later.

For that you can use attr_read, define the state_id and possibly the state_attr if you want to keep multiple values in a single state. On every read, the state_id(/state_attr) will be updated and you can use that like any other state.
You could also add that to your sequence : read the attribute after sending the command (unless you can have the device report the attribute value).

P.S.: zha-toolkit can also about not using it :wink: I am happy to see that this piece in the documentation was actually useful to somebody.

2 Likes

Well, there is a “ZHA development” catagory for new discussions and ZHA devs are also zigpy devs too.

https://github.com/zigpy/zigpy/discussions/new

Good point, thanks. I’ve now created a new discussion: ZHA does not support tilt for covers · Discussion #936 · zigpy/zigpy · GitHub

Is it safe to use attr_read to create an additional property in the existing state/entity of the cover device? Or should I use it to create a new state?