Limiting curtain position

Hi all,

I’m using Xiaomi aquara curtains and would like to limit the maximum open position. Since the curtains are opening in a 90 degree corner, they are sometimes getting stuck, so I would like to limit the curtain maximum open position just before the corner as a workaround. Currently I am able to open them, but I have to always use the slider to 90% or so. I would like to just be able to click ‘open’ and use google assistant to ‘open the curtains’ without having to state the position (‘open the curtains to 90%’).

The curtains are connected via Deconz and are visible in Home Assistant as ‘cover’. Any suggestions are appreciated, thanks!

Hi,
haven’t tried it, but I think you can create a template cover, which you can use instead of the original cover. In this template cover set the position to 90% when it is opened.
I think something like this could work:

cover:
  - platform: template
    covers:
      my_curtain:
        friendly_name: "My curtain"
        open_cover:
          service: cover.set_cover_position
          data:
            entity_id: cover.original_cover_id
            position: 90
        close_cover:
          service: cover.close_cover
          data:
            entity_id: cover.original_cover_id
        stop_cover:
          service: cover.stop_cover
          data:
            entity_id: cover.original_cover_id
        set_cover_position:
          service: cover.set_cover_position
          data:
            entity_id: cover.original_cover_id
            position: "{{ (position * 0.9) | round }}"
        position_template: "{{ (state_attr('cover.original_cover_id', 'current_position') / 0.9) | round }}"

Replace cover.original_cover_id with your cover id and my_curtain with something you like.

Thanks a lot, this worked flawlessly. I only needed to remove the line with the ‘value template’ for it to work, otherwise it gave a config error.

Cool, I edited my original answer, so that it is correct now :slight_smile: