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.

1 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:

Hi,

when i take your template i get an error message.


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

Any news here? Like options to set entities with limits?

Hi, this is not a template. It is a configuration for a template cover, which uses templates to calculate states or parameters for service calls.

You have to put this in your config file, like configuration.yaml.