Reverse binary contacts status

Hello,

I’ve been using Home Assistant for a few days and I’m hooked but still a beginner.

I managed to map the binary sensors to the dashboard. Unfortunately, the status was displayed incorrectly. I managed to reverse the status.

template:
   - sensor:
       - name: "test"
         states: >
          {{is_state('binary_sensor.fenster_buro_matthias_nord', 'off')}}

Unfortunately, the dashboard now shows “False” instead of “closed” and “True” instead of “Open”. I would like to have the window as the icon.
The following code didn’t work:

template:
  template:
   - binary_sensor:
       - device_class: window
       - name: "test"
         states: >
          {{is_state('binary_sensor.fenster_buro_matthias_nord', 'off')}}

Can someone help me please?

How can I extend this to the whole group “binary sensors”?

template:
  - binary_sensor:
      - name: test
        state: >
          {{is_state('binary_sensor.fenster_buro_matthias_nord', 'off')}}
        device_class: window

Thank you for the Solution.
Can I transfer the code to the whole group?

What do you mean by the “whole group”?

i created a group “binary sensors”

What is the relationship between the group you created and the Template Sensor posted above?

Thank you. There is no relationship because its a new sensor. So I think i have to create a lot of new sensor to show the invert state of the orignals.