Templates, Covers, position template limit and state

New H.A. user here and this community forum is awesome for getting beyond the basics.

I have searched the forums for an answer to my issue, without success. I need to limit my IKEA FYRTUR blinds to opening only to 97%, due to the way I framed the windows. I did find an excellent post on here and have successfully created a cover template to control this for a group of four blinds. Works flawlessly and happy with it!

Given the hard limit of 97% on opening, I would like the blinds to report Open when they are at 97%. Instead, the state on the mushroom card reports Open - 97% when they are open. I would really like this to report Open 100% to simply and to get better buy in from others in the house!

I am confused with value template versus position template. Intuitively it would see that I need to set the value template here, but have not been successful at figuring this out.

Here is the yaml I have:

- platform: template
  covers:
    bedroom_blinds_limited_group:
      friendly_name: "Bedroom Blinds Open Limit"
      open_cover:
        service: cover.set_cover_position
        data:
          entity_id: cover.bedroom_blinds_group
          position: 97
      close_cover:
        service: cover.close_cover
        data:
          entity_id: cover.bedroom_blinds_group
      stop_cover:
        service: cover.stop_cover
        data:
          entity_id: cover.bedroom_blinds_group
      set_cover_position:
        service: cover.set_cover_position
        data:
          entity_id: cover.bedroom_blinds_group
          position: "{{ (position * 0.97) | round }}"
      position_template: "{{ state_attr('cover.bedroom_blinds_group', 'current_position') / 0.97 | round }}"
      icon_template: >-
          {% if is_state('sensor.bedroom_blinds_limited_group', 'open') %}
            mdi:blinds-open
          {% else %}
            mdi:roller-shade-closed
          {% endif %}

States are “open”, “opening”, “closed”, “closing”.
You want “closed” when the blinds are at 97%, I guess, so maybe

value_template: "{{ iif(state_attr('cover.bedroom_blinds_group', 'current_position')|float > 95), "closed", states('cover.bedroom_blinds_group')) }}"

Actually it’s IKEA’s crazy blinds, so 0% is closed and 100% is open. IKEA and zigbee2mqtt support setting a max limit length for closing. But in my case, I cannot allow the blinds to fully open or the end gets caught a molding in the window trim - so I’m attempting to redefine the state "open’ to be 97%, rather than 100%. As indicated, the YAML works to stop the blinds at 97%. I just need to figure out how to not make it appear as if the blinds are not fully open (by displaying 97%)…

Alternatively, if there is a way to only display the percentage open only if less than 97%, that would work. I do not require the percentage to display if the blind is fully open or fully closed. Only if somewhere in between 1% and 96%… Not sure if that approach is easier.

Invalid config for [cover.template]: invalid template (TemplateSyntaxError: unexpected ')') for dictionary value @ data['covers']['bedroom_blinds_limited_group']['value_template']. Got '"{{ if(state_attr(\'cover.bedroom_blinds_group\', \'current_position\') | float > 96), "open", states(\'cover.bedroom_blinds_limited_group\')) }}"'. (See ?, line ?).

I tried as you suggested, though is {{ iif(state… a typo? Tried like this, but no difference…

value_template: "{{ if(state_attr('cover.bedroom_blinds_group', 'current_position')|float > 95), open, states('cover.bedroom_blinds_group')) }}"

Lastly, sorry but I don’t understand some of the terminology in the templating language. what does “… | float > 95” actually mean? Versus the “| round” syntax in the position template that is working?

No, iif() is the immediate if function. It is a way to do a short-form if/then/else statement.

The float filter converts a numeric string into a floating point number that can have mathematical comparisons or operations performed on it. The round filter does the same thing but also rounds the resulting number to the number of decimals you define.

1 Like

Thanks - that helps improve the understanding!

I have the same problem right now. Can someone perhaps post the complete template?
Thank you very much

template_error here

  - platform: template
    sensors:
      cover_close_18:
        friendly_name: "COVER close 18"
        value_template: >-
          {{ iif(state_attr('cover.rollo_terrasse', 'current_position')|float < 19), "closed", states('cover.rollo_terrasse')) }}

@MackCreek You know you could limit the blinds by lowering the blinds to the desired state. Then doubletap on the lower button on the device. Then that position is reported as 100%. So no need to do calculations on HA.

When lowering the blinds, it wil automatically stop at that saved position.

As OP stated a few times, the problem is limiting maximum opening level, not maximum closing level. IKEA in their infinite wisdom do not allow to set a maximum opening level, just a maximum closing level. This leaves me with the exact same issue as OP. @MackCreek @tomg1970 if any of you figured it out, I would really appreciate if you could post the solution! :smile: :pray:

I don’t have a solution yet

Newbie here (first post), but I think I got my Frytur blinds to max open at 97% and close at 5%. Hope this helps

cover:
  - platform: template
    covers:
      living_room_door_shade_t:
        unique_id: livingroomdoorshadet
        friendly_name: "Living Room Door Shade T"
        entity_id: cover.living_room_door_shade_t
        device_class: curtain
        position_template: "{{ state_attr('cover.curtain_living_room_door_shade', 'current_position') | int }}"
        availability_template: "{% if is_state('cover.curtain_living_room_door_shade', 'unavailable') %} false {% else %} true {% endif %}"

        open_cover:
          service: cover.set_cover_position
          data:
            entity_id: cover.curtain_living_room_door_shade
            position: 97
        close_cover:
          service: cover.set_cover_position
          data:
            entity_id: cover.curtain_living_room_door_shade
            position: 5
        stop_cover:
          service: cover.stop_cover
          data:
            entity_id: cover.curtain_living_room_door_shade
        icon_template: >-
          {% if state_attr('cover.curtain_living_room_door_shade', 'current_position') > 6 %}
            mdi:blinds-open
          {% else %}
            mdi:roller-shade-closed
          {% endif %}