Smart blinds using a cover template in Home Assistant

Smart blinds using a cover template in Home Assistant

I recently upgraded to SmartWings smart roller blinds and have been thoroughly impressed with their performance. These blinds come in a variety of styles and support multiple smart home protocols, including Zigbee, Z-Wave, and Matter. However, I encountered an interesting (and annoying) quirk when integrating them with Home Assistant via Zigbee2MQTT: the blinds reported as "closed" when they were actually open, and vice versa.

After experimenting with various settings, I found the simplest solution was to use a covers template in Home Assistant. This approach allowed me to correct the reporting issue and ensure my blinds operated as expected.

covers.yaml
cover:
  - platform: template
    covers:
      bedroom_his_roller_blind:
        friendly_name: "Bedroom his roller blind"
        unique_id: cb4c5592-288c-4029-8431-af0123ffaf79
        value_template: >-
          {% if is_state('cover.bedroom_his_cover', 'open') %}
            closed
          {% elif is_state('cover.bedroom_his_cover', 'closed') %}
            open
          {% else %}
            {{ states('cover.bedroom_his_cover') }}
          {% endif %}
        open_cover:
          action: cover.open_cover
          target:
            entity_id: cover.bedroom_his_cover
        close_cover:
          action: cover.close_cover
          target:
            entity_id: cover.bedroom_his_cover
        stop_cover:
          action: cover.stop_cover
          target:
            entity_id: cover.bedroom_his_cover
        set_cover_position:
          action: cover.set_cover_position
          target:
            entity_id: cover.bedroom_his_cover
          data:
            position: "{{ 100 - position }}"
        position_template: "{{ 100 - state_attr('cover.bedroom_his_cover', 'current_position') }}"
        icon_template: >-
          {% if is_state('cover.bedroom_his_cover', 'open') %}
            mdi:blinds
          {% elif is_state('cover.bedroom_his_cover', 'closed') %}
            mdi:blinds-open
          {% else %}
            mdi:blinds
          {% endif %}

This template creates a new covers entity, and I will simply hide the original one to avoid confusion. The new cover entity inverts the state reporting of the blind and the position. I chose to have 100% reflect the blind fully rolled up, but some prefer the opposite. With this template, the new blinds from SmartWings now match my other smart blinds and I can use the consistently in automations.