Templating icon states with multiple entities

Looking for some help! I would like to show an open door icon when a specific door is ‘open’, and a closed door icon for when it’s ‘closed’. I would like the icon applied to each door to show the correct state for that particular door, and not have it apply the ‘open’ icon for both doors if only one door is open. Can someone look at the below code and give me some tips?

cover:
  - platform: template
    covers:
      doors:
        friendly_name: "Doors"
        entity_id:
          - binary_sensor.door_front_contact
          - binary_sensor.door_side_contact
        value_template: "{{is_state('sensor.doors', 'open')}}"
        icon_template: >-
          {% if is_state('sensor.doors', 'open') %}
            mdi:door
          {% else %}
            mdi:door-closed
          {% endif %}

I’m not 100% sure what you mean by this:

I would like the icon applied to each door to show the correct state for that particular door, and not have it apply the ‘open’ icon for both doors if only one door is open.

Do you mean have another entity for both doors with that state logic?

If so, create these binary sensors

binary_sensor:
- platform: template
  sensors:

    doors:
      friendly_name: 'Both Doors'
      entity_id:
        - binary_sensor.door_front_contact
        - binary_sensor.door_side_contact
      value_template: "{{ is_state('binary_sensor.door_front_contact', 'on') and is_state('binary_sensor.door_side_contact', 'on') }}"
      device_class: door

    front_door:
      friendly_name: 'Front Door'
      entity_id:
        - binary_sensor.door_front_contact
      value_template: "{{ is_state('binary_sensor.door_front_contact', 'on')  }}"
      device_class: door

    side_door:
      friendly_name: 'Side Door'
      entity_id:
        - binary_sensor.door_side_contact
      value_template: "{{ is_state('binary_sensor.door_side_contact', 'on')  }}"
      device_class: door

In this case you get three entities, a ‘side’ and a ‘front’ door and a ‘both doors’. The "Both Doors’ entity will only be shown as open if the side and front doors are open.

If however you mean this logic:

I would like the icon applied to each door to show the correct state for that particular door, and not have it apply the ‘open’ icon for both doors if only one door is open.

Applies to the individual side and front doors then you want this:

binary_sensor:
- platform: template
  sensors:

    front_door:
      friendly_name: 'Front Door'
      entity_id:
        - binary_sensor.door_front_contact
        - binary_sensor.door_side_contact
      value_template: "{{ is_state('binary_sensor.door_front_contact', 'on')  }}"
      icon_template: >-
        {% is_state('binary_sensor.door_front_contact', 'on') and is_state('binary_sensor.door_side_contact', 'on') %}
          mdi:door
        {% else %}
          mdi:door-closed
        {% endif %}

    side_door:
      friendly_name: 'Side Door'
      entity_id:
        - binary_sensor.door_front_contact
        - binary_sensor.door_side_contact
      icon_template: >-
        {% is_state('binary_sensor.door_front_contact', 'on') and is_state('binary_sensor.door_side_contact', 'on') %}
          mdi:door
        {% else %}
          mdi:door-closed
        {% endif %}

In this case the side and front doors will only be shown as open if they are both open. However their state will still each be open and closed. They just won’t be shown that way in the front end. I don’t know why you would want this so it seems unlikely but I thought I would include it just in case.

I’ve written ‘doors’ so many times it has lost all meaning.