Convert Garage "cover" to binary sensor output

I’m trying to group my garage cover sensor and a binary motion sensor for lighting automation. In order to do this, I’m trying to create a binary sensor that is operated by the garage door cover. It seems easy but I just can’t get it to work. Here’s what I have:

  - binary_sensor:
      - name: BigGarageDoorBinarySensor
        state: >
          {% if is_state('cover.house_big_door', 'opened') %}
          {% else %}
          {% endif %}

I did something similar, except for door locks. I went about it slightly differently, but I think the major issue you have is the extra spaces that could be showing up in your output. Here’s how I went about it:

- binary_sensor:
    - name: "Office Door Status"
      state: >-
        {%- if states("lock.office_door") == "locked" -%}
        {%- else -%}
        {%- endif -%}

I have this in a config/templates.yaml file and in my standard configuration.yaml I have this line:

template: !include templates.yaml

In the template, note the use of >- and all of the {%- and -%} which cause the templates to strip leading and trailing white spaces

Thanks for the suggestions! Come to find out that my state data label was incorrect. The HASS UI for the MyQ shows “Opened” for the status. When I looked at the state information in the developer area, the data in the state label was “open” instead of “Opened”.

I appreciate the added info about splitting the template file out of the configuration file. I totally missed that and was setting myself up to have a very messy coding experience.

This works for me:

  - binary_sensor:
    - name: 'Garage door left'
      device_class: garage_door
      state: "{{ is_state('cover.garage_door_left', 'open') }}"