Invalid config for [binary_sensor]

Hi everyone,
I get this error:
“Invalid config for [binary_sensor]: required key not provided @ data[‘platform’]. Got None. (See ?, line ?).”
when checking the configuration, I don’t understand why I entered the “platform” value.
Here is an excerpt of my code:


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
binary_sensor: !include_dir_list 485/

modbus:
  name: waveshare1
  type: tcp
  host: 192.168.1.90
  port: 4196
  sensors:
  
  #CONTECA 42
        - name: MSB_heating_energy42
          unique_id: MSB_heating_energy42
          slave: 42
          address: 2
          precision: 2
          unit_of_measurement: kWh
        

this is one of the binary_sensor:

binary_sensor:
  - platform: template
    sensors:
      alarm_bit_1:
        friendly_name: "ALARM Bit 1"
        value_template: >
          {% if states('sensor.Legiomix_alarms')|int|bitwise_and(1) > 0 %}
            ATTIVO
          {% else %}
            non attivo
          {% endif %}
      alarm_bit_3:
        friendly_name: "ALARM Bit 3"
        value_template: >
          {% if states('sensor.Legiomix_alarms')|int|bitwise_and(4) > 0 %}
            ATTIVO
          {% else %}
            non attivo
          {% endif %}
      alarm_bit_4:
        friendly_name: "ALARM Bit 4"
        value_template: >
          {% if states('sensor.Legiomix_alarms')|int|bitwise_and(8) > 0 %}
            ATTIVO
          {% else %}
            non attivo
          {% endif %}e

The templates that determine the state of your binary sensors should return true or false. e.g.

      alarm_bit_1:
        friendly_name: "ALARM Bit 1"
        value_template: >
          {{ states('sensor.Legiomix_alarms')|int|bitwise_and(1) > 0 }}

This will be translated to on or off in the frontend.

You can change how that state is displayed in the frontend by applying a device class, see: https://www.home-assistant.io/integrations/binary_sensor/#device-class

You should also be using the new format for template sensors instead of the legacy format.

When including files you need to remove the header.

You already have binary_sensor: in configuration.yaml, so you don’t put it in the file you’re including.