How to create inverted cover based on existing

Hi,
Due to an issue with Somfy devices (showing as an awning and inverted position How to invert blinds sensor (from tahoma integration) - #15 by Alaric), I’m trying to create a new cover based on an existing cover and behaves:

  • inverted current_position
  • shows as a blind

I’ve read and tried several things based on the docs: Template Cover - Home Assistant and not able to get it the blind pysical to work.

configuration.yaml

cover: !include covers.yaml

covers.yaml

- platform: template
  covers:
    scullery_inverted:
      device_class: blind
      friendly_name: "scullery_screen_inverted"
      optimistic: true
      position_template: >
        {{ 100 - (state_attr("cover.sunea_scr_40_io","current_position") | int ) }}
      open_cover:
        - condition: state
          entity_id: cover.sunea_scr_40_io
          state: "closed"
      close_cover:
        - condition: state
          entity_id: cover.sunea_scr_40_io
          state: "open"
      stop_cover:
        - condition: state
          entity_id: cover.sunea_scr_40_io
          state: "stopped"
      set_cover_position:
        service: cover.set_cover_position
        data_template:
          entity_id: cover.sunea_scr_40_io
          position: "{{ 100 - position}}"

Any help would be appreciated very much.

open_cover, close_cover, stop_cover, and set_cover_position are all meant for scripts. You just put conditions in them without an action. So nothing is ever done for those controls.

position_template determines the overall state of your cover.

optimistic: true means that when you open the cover, the state will be assumed open (instead of based on the position_template).