Cover entities that are 0% = open and 100% = closed

If you are not happy with HA’s cover interpretation of 0 = closed and 100 = open then you are not alone.
In 2020 I sparked a WTH discussion about that topic. It triggered a heated debate:

That discussion also offered multiple workarounds based either on Template Cover entities or on entities created in Node RED flows. There are also a hand full of related questions about that in the forum that provide answers of different maturity level.

Today I want to collect all the bits and pieces and start a guide that boils it all down. Guides in this forum can be edited by other users. So be my guest. Please let us not start a discussion here (again) which opinion is right and which is wrong. I already apologize for marking HA´s original position values in red further down. People who come here in search for a solution are biased (I guess) and will understand.

Warnings and limitations:

As far as I understand there is still no 100% solution. I will also try to discribe these limits. Although I do all my automations in Node RED, in this case I use Template Covers. My solution does not have a tilt setting as my covers are not venetian blinds. If you need that, look deeper into the WTH discussion (and maybe add to this guide). My covers are based on the KNX integration of HA, but I guess it does not matter where the covers come from.

Now let’s start:

For each of your covers (and your cover groups) you need to create one inverted entity that controls the same cover but uses a percentage for 100 to 0 where the original cover uses 0 to 100. This is the config for the Template Cover entity cover.buro_inverted which is the mirror of the KNX cover cover.buro:

cover:

  - platform: template
    covers:
      buro_inverted:
        friendly_name: Rolladen Büro
        position_template: "{{ 100 - state_attr('cover.buro', 'current_position') | int(default=0) }}"
        set_cover_position:
          service: cover.set_cover_position
          data:
            position: "{{ 100 - position }}"
            entity_id: cover.buro
        open_cover:
          service: cover.open_cover
          data: {}
          target:
            entity_id: cover.buro
        close_cover:
          service: cover.close_cover
          data: {}
          target:
            entity_id: cover.buro
        stop_cover:
          service: cover.stop_cover
          data: {}
          target:
            entity_id: cover.buro
        icon_template: >-
          {% if is_state('cover.buro', 'closed') %}
            mdi:window-shutter
          {% else %}
            mdi:window-shutter-open
          {% endif %}

Note 1: It is in fact possible that the inverted entitiy has the same friendly_name as the original entity! For example my covers are both named “Rolladen Büro”. This will later be helpful.

Note 2: You may notice that I invert the percentage of the inverted cover, but I do not invert the open / close service calls. You will definitely find examples in the forum, where these are inverted too (close_cover: calls cover.open_cover of the original entity and vice versa. I do not think that this makes any sense though. HA’s cover entities handle open and close perfectly and there is no discussion about that. We are talking about percentage values only here

Where to use?

The inverted entities are perfect to be used with HA’s voice assistants like Assist, Alexa and Google Home. They work perfectly here. Just go to Settings → Voice assistants → Expose, and deactivate the original cover entities and activate the inverted ones for all assistants. Done.

In Lovelace it is not so simple and here comes the current…

Limitation

In Lovelace you are stuck between a rock and a hard place:

  1. If you use the old entities, your percentage values are “wrong”.
  2. If you use the new entities, your slider in entity’s details view is wrong.

Example 1.: old entity when cover is nearly closed

Example 2.: new entity when cover is nearly closed

There are many solutions for that, mostly involving some kind of custom cards.
But the slider in the important details view itself will always stay “kaputt”, which is unacceptable for me.
So I personally prefer to live with 1. (the old, well known “wrong” percentage values) in most parts of Lovelace. But you can also mix and match as you like.

My major problem have always been the voice assistants, and they are perfectly taken care of by the new inverted entities.

Enjoy!

1 Like

I have awnings (canopies) which extend outwards. The best paradigm for these would be “in/out”. Other people might prefer “up/down”, “open/closed”, “left/right”, “light/dark”… We also have vertical blinds, and it would be good to have consistency in the labels and paradigms. When we want to shut out the sun, the vertical blinds have to be Closed whereas the awning must be Open!

A simple-sounding structural solution would be to allow user-defined strings for 0% and 100%, or otherwise a choice of different paradigms (allowing for translations) together with an “invert” option.

But I have no idea how easy/difficult this would be to implement, or if it would have any undesirable side-effects.

I would prefer not to start another discussion about that here. There already is an extensive thread in the “What the heck…” section which I linked to in the guide above.

Pic shutter card (GitHub - samoswall/pic-shutter-card: Shutter card for Home Assistant Lovelace UI) has an option to simply invert the direction. Not a real solution for every purpose but perfect for me.
IMG_0190

Thank you,
That was very helpfull!!
Althought when I ask Alexa to set x rollershutter to 0% it executes 100%, what i’m doing wrong?
Up to 1% works good but when I ask Alexa to set 0% it execute 100%

Can we see your code?

1 Like

Yes, thanks a lot

cover: !include covers.yaml
- platform: template
  covers:
    kitchen1_inverted:
      friendly_name: Kitchen 1
      unique_id: kitchen1_inverted_cover
      position_template: "{{ 100 - state_attr('cover.005_kitchen', 'current_position') | int(default=0) }}"
      set_cover_position:
        service: cover.set_cover_position
        data:
          position: "{{ 100 - position }}"
        target:
          entity_id: cover.005_kitchen
      open_cover:
        service: cover.open_cover
        target:
          entity_id: cover.005_kitchen
      close_cover:
        service: cover.close_cover
        target:
          entity_id: cover.005_kitchen
      stop_cover:
        service: cover.stop_cover
        target:
          entity_id: cover.005_kitchen
      icon_template: >-
        {% if is_state('cover.005_kitchen', 'closed') %}
          mdi:window-shutter
        {% else %}
          mdi:window-shutter-open
        {% endif %}

And the other thing now is that I can’t expose this entity to Alexa, It doesn’t show up in the Alexa app for a reason.
Alexa had cashed that particular entity… I fixed that.

Any suggestion?

I’m sorry Mike, I do not see any problem with your code. Did you check the Logbook to see which commands are issued?