Binary sensor door template stays off

Hi everybody.

I seem to have a problem with my door sensor. it always says its off or closed.
frontdoor
The icon however does change. what did i do wrong??
Below is an extract from my configuration.yaml

Thanks!

binary_sensor:
   - platform: template
     sensors:
       front_door:
         device_class: door
         icon_template: >
           {% if is_state('sensor.fibaro_system_fgdw002_door_opening_sensor_2_access_control', '22') %}
             mdi:door-open
           {% else %}
             mdi:door-closed
           {% endif %}
         value_template: >
           {% if is_state('sensor.fibaro_system_fgdw002_door_opening_sensor_2_access_control', '22') %}
             Open
           {% elif is_state('sensor.fibaro_system_fgdw002_door_opening_sensor_2_access_control', '23') %}
             Closed
           {% else %}
             Error
           {% endif %}

From the docs:

The state of a Template Binary Sensor can only be on or off

So the value_template should return true or false, not open, closed or error.

Thanks!
I changed the template to a non binary sensor and that worked.
Still a bit confused, as it seems that the binary template should be the one to use for a door.

Yes, it is the one, but it can only be on/true or off/false.
The device class: door shows the state as open (on/true) or closed (off/false)