Help with cover template

I created a template for a cover. Home assistant is telling me that the position is unknown in my dashboard. This is the code that I have:

- platform: template
  covers:
    danielle_s_shades:
      friendly_name: Danielle's shade
      position_template: >-
          {% set p = 100 - (state_attr('cover.danielles_shades_window_covering', 'current_position') | int)%}
          {% if p > 11 %} p
          {% else %} 0
          {% endif %}
      open_cover:
        service: cover.open_cover
        data:
          entity_id: cover.danielles_shades_window_covering
      close_cover:
        service: cover.close_cover
        data:
          entity_id: cover.danielles_shades_window_covering
      stop_cover:
        service: cover.stop_cover
        data:
          entity_id: cover.danielles_shades_window_covering
      set_cover_position:
        service: cover.set_cover_position
        data:
          entity_id: cover.danielles_shades_window_covering
          position: "{{ 100 - (position) }}"

What am I doing wrong?

You need to wrap the variable p in curly braces in the position template

...
        position_template: >-
          {% set p = 100 - (state_attr('cover.danielles_shades_window_covering', 'current_position') | int)%}
          {% if p > 11 %}{{ p }}
          {% else %} 0
          {% endif %}
...

I don’t really use covers, but the following seems to be missing a definition for the position variable

...
      position: "{{ 100 - (position) }}"
...

According to the docs template covers can use the this variable, so your template should likely be:

...
set_cover_position:
  - service: cover.set_cover_position
    data:
      position: "{{ 100 - this.attributes.position }}"
    target:
      entity_id: cover.danielles_shades_window_covering
...