Set position on cover template not working

I made a template into the configuration.yaml file long time agoin fact, got some help form the community.

The point is that on the last update i received a warning that the template will be deprecated, so I moved on to the template helper system and I managed to get it work, almost work.

To be set up I have to day that the reason for templating my cover cover.2
is because I installed a door sensor and I wanted to prevent the cover from closing if the door is opened, and for replace the close button in the cover card for a script which takes into account the door open/close state I decided to do the template.

Well the point is that everything works but the set position .

I submit some captures of the recently created template.


Read this. Many people had the same questions. After you read thru that if you still have a question ask there.

What’s not working with if? Can you share your legacy template?

Hi, thaks for your work and quick reply.

What doesn`t work is the option to set a position, which shows the following error when trying to use it on the dash.

the previous template, is this one

template:
  - cover:
      - open_cover:
          - target:
              entity_id:
                - cover.2
            action: cover.open_cover
        close_cover:
          - action: script.cerrar_persiana_2
        stop_cover:
          - target:
              entity_id:
                - cover.2
            action: cover.stop_cover
        set_cover_position:
          - target:
              entity_id:
                - cover.2
            data:
              position: "{{ position }}"
            action: cover.set_cover_position
        default_entity_id: cover.persiana_2_segura
        icon:
          "{% if is_state('cover.2', 'open') %}\n  mdi:blinds-open\n{% else %}\n  mdi:blinds\n{%
          endif %}"
        name: Persiana 2 Segura
        position: "{{ state_attr('cover.2', 'current_position') }}"

well , have to say that I think I solved myself, after re-reading the previous template, and the error itself, I have realized that there were a part missing

position: "{{ position }}"

in the data field, the point is that I didn´t know where to writer down that, but editing in yaml mode I found it.

I think that was the problem, I´ll wait for you to agree.

Yep that would cause that error

1 Like

should I mark that as “solution” ?