Cover completely reverse/invert

Yes if that’s the name of the attribute

I think that’s it… :see_no_evil: :sweat_smile:

The working code for the archive:

  - platform: template
    covers:
      cover_r_reversed:
        friendly_name: "Cover R Reversed"
        position_template: "{{ 100 - state_attr('cover.realcover_r', 'current_position') | int(100) }}"
        value_template: "{{ (100 - state_attr('cover.realcover_r', 'current_position') | int(100)) > 95 }}"
        open_cover:
          service: cover.close_cover
          data: {}
          target:
            entity_id: cover.realcover_r
        close_cover:
          service: cover.open_cover
          data: {}
          target:
            entity_id: cover.realcover_r
        stop_cover:
          service: cover.stop_cover
          data: {}
          target:
            entity_id: cover.realcover_r
        set_cover_position:
          service: cover.set_cover_position
          data:
            position: "{{100-position}}"
            entity_id: cover.realcover_r
        icon_template: >-
          {% if is_state('cover.realcover_r', 'closed') %}
            mdi:blinds-open
          {% else %}
            mdi:blinds
          {% endif %}

one more question about this… whats the 95 in value_template: "{{ (100 - state_attr('cover.realcover_r', 'current_position') | int(100)) > 95 }}" for?

3 Likes

Well, anything over 95 on the slider will consider it open

EDIT: You can remove that now probably. I added it based on your previous comments but it turns out the attribute was just wrong.

liket his:
value_template: "{{ (100 - state_attr('cover.realcover_r', 'current_position') | int(100)) }}"

?

no remove the whole line

  - platform: template
    covers:
      cover_r_reversed:
        friendly_name: "Cover R Reversed"
        position_template: "{{ 100 - state_attr('cover.realcover_r', 'current_position') | int(100) }}"
        open_cover:
          service: cover.close_cover
          data: {}
          target:
            entity_id: cover.realcover_r
        close_cover:
          service: cover.open_cover
          data: {}
          target:
            entity_id: cover.realcover_r
        stop_cover:
          service: cover.stop_cover
          data: {}
          target:
            entity_id: cover.realcover_r
        set_cover_position:
          service: cover.set_cover_position
          data:
            position: "{{100-position}}"
            entity_id: cover.realcover_r
        icon_template: >-
          {% if is_state('cover.realcover_r', 'closed') %}
            mdi:blinds-open
          {% else %}
            mdi:blinds
          {% endif %}
4 Likes

Thanks! Gone in 60 minutes - posts.

CU next time :-). Keep the spoon ready.

Thanks a lot to you both. Been using this thread to completely reverse buttons & positions in Home Assistant, for Tuya curtain modules that work fine, but display reversed status & position values in hass.io

I included all this in a “covers.yaml” file, and added just the include at the end of configuration.yaml:

cover: !include covers.yaml
1 Like

Hey everyone
When I try this, I get an error that “position is undefined”
I get that same error in the template editor if I paste in your version too.

My version:

      bedroom_large_left:
        friendly_name: "Bedroom Blinds Large Left"
        position_template: "{{ 100 - state_attr('cover.bedroom_blinds_c_left', 'current_position') | int(100) }}"
        value_template: "{{ (100 - state_attr('cover.bedroom_blinds_c_left', 'current_position') | int(100)) > 95 }}"
        open_cover:
          service: cover.close_cover
          data: {}
          target:
            entity_id: cover.bedroom_blinds_c_left
        close_cover:
          service: cover.open_cover
          data: {}
          target:
            entity_id: cover.bedroom_blinds_c_left
        set_cover_position:
          service: cover.set_cover_position
          data:
            position: "{{100-position}}"
            entity_id: cover.bedroom_blinds_c_left
        icon_template: >-
          {% if is_state('cover.bedroom_blinds_c_left', 'closed') %}
            mdi:blinds-open
          {% else %}
            mdi:blinds
          {% endif %}

You shouldn’t get that error in your configuration. You’ll get that error in the template editor area because position doesn’t exist in the template editor.

Your comment made YouTube. FINALLY! A CHEAP Zigbee SOLAR POWERED Smart Blind Motor - YouTube skip to 6:30

1 Like

Yep, I know.

1 Like

My “created” template code from above does not actually always work. E.g. when I have the cover half open and restart HA, It lost it’s state and I need to fully open or close it to reflect the actual state.

I admit: I am not a coder (templates). However I am a very enthusiastic HA user that like things working, even if that means I need to ask for help here.

Although I think, given the amount of questions and topics on templates, and especially this one, it is not easy at all.

1 Like

What’s the attribute current_position value at startup on cover.bedroom_blinds_c_left?

I have been playing with this for hours and I can’t make it work. My version does reverse the blind but I can’t restart HA, I always get the error:

The system cannot restart because the configuration is not valid: Error loading /config/configuration.yaml: mapping values are not allowed here in “/config/covers.yaml”, line 2, column 11

Here is mine (content of covers.yaml), it’s just a paste of the above but with my blind:

- platform: template
    covers: 
      dining_room_blind_reversed:
        friendly_name: "Dining room blind reversed"
        position_template: "{{ 100 - state_attr('cover.dining_room_blind_cover', 'current_position') | int(100) }}"
        open_cover:
          service: cover.close_cover
          data: {}
          target:
            entity_id: cover.dining_room_blind_cover
        close_cover:
          service: cover.open_cover
          data: {}
          target:
            entity_id: cover.dining_room_blind_cover
        stop_cover:
          service: cover.stop_cover
          data: {}
          target:
            entity_id: cover.dining_room_blind_cover
        set_cover_position:
          service: cover.set_cover_position
          data:
            position: "{{100-position}}"
            entity_id: cover.dining_room_blind_cover
        icon_template: >-
          {% if is_state('cover.dining_room_blind_cover', 'closed') %}
            mdi:blinds-open
          {% else %}
            mdi:blinds
          {% endif %}

I’m happy to have a bash at stuff but this is all new to me, I’m not a coder

  - platform: template
    covers: 
1 Like

Thank you. I can’t believe it’s that simple!

Thanks for the solution which is quite perfect in my case to swap the buttons.
However, it has a problem: it is based on the position_template.

I’m attaching a view of the normal and inverted (reversed) cover:

The reversed buttons and the icons are perfect with your solution, but I would like to invert also the slider percentage. I don’t think this is possible, right?

Just want to say that the solution provided worked perfectly for my tuya zigbee blinds, thanks! I got the blind motor installed and HA seeing the device with minimal effort, the only issue was HA showing the inverted state of the blinds and nothing I did could change it.

I think it helped that I didnt want the slider, just up and down.

How would I create the “opening” and “closing” status on this cover, independent of the original cover?