Sensor Template: Invert Shutter position

In Home Assistant my shutter position is shown inverted respect what I meant for open and closed; so when it’s fully open the slider is at 100% position and when fully closed the slider is at 0% position.

Fully Open – 100% slider

For my way of thinking, I prefer to see the slider at 100% position when the shutter is fully closed so I’ve used the cover template to create two new entities, one for each shutter, that simply invert the position. Copy and paste following code to your configuration.yaml and replace your entitites name.

cover:
  - platform: template
    covers:
      tapparella_sala_invertita:
        friendly_name: "Tapparella Sala (Inverse)"
        position_template: >
          {{100 - (state_attr('cover.rolling_shutter_switch_1_2','current_position')|int)}}
        set_cover_position:
          service: cover.set_cover_position
          data_template:
            entity_id: cover.rolling_shutter_switch_1_2
            position: >
              {{100 - position}}
      tapparella_cucina_invertita:
        friendly_name: "Tapparella Cucina (Inverse)"
        position_template: >
          {{100 - (state_attr('cover.rolling_shutter_switch_2_2','current_position')|int)}}
        set_cover_position:
          service: cover.set_cover_position
          data_template:
            entity_id: cover.rolling_shutter_switch_2_2
            position: >
              {{100 - position}}    

Now I can easily put these new entities (cover.tapparella_sala_invertita and cover.tapparella_cucina_invertita) in my dashboard and use them to control my shutter replacing the default entities.

Fully Open – 0% slider