Splitting up configuration.yaml

Hi everyone, I would like to separate and keep my configuration file tidy but I’m having problems with the !include command.
I would like to separate the files of the different sensors into multiple files.
Furthermore I have to create binary sensors and when I go to divide them into different files they cause me errors.

I attach the configuration files, if anyone can help me, thank you very much!

this is the configuration.yaml


# 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

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
        - name: LSB_heating_energy42
          unique_id: LSB_heating_energy42
          slave: 42
          address: 3
          precision: 2
          unit_of_measurement: kWh
        - name: MSB_cooling_energy42
          unique_id: MSB_cooling_energy42
          slave: 42
          address: 4
          precision: 2
          unit_of_measurement: kWh
        - name: LSB_cooling_energy42
          unique_id: LSB_cooling_energy42
          slave: 42
          address: 5
          unit_of_measurement: kWh
        - name: Instantaneous_power42
          unique_id: Instantaneous_power42
          slave: 42
          address: 14
          precision: 2
          unit_of_measurement: kW
        - name: Instantaneous_flow42
          unique_id: Instantaneous_flow42
          slave: 42
          address: 15
          precision: 2
          unit_of_measurement: m3/h
        - name: Flow_temp42
          unique_id: Flow_temp42
          slave: 42
          address: 16
          precision: 2
          scale: 0.1
          unit_of_measurement: °C
          device_class: temperature
        - name: Return_temp42
          unique_id: Return_temp42
          slave: 42
          address: 17
          precision: 2
          scale: 0.1
          unit_of_measurement: °C
          device_class: temperature
        - name: Difference_temp42
          unique_id: Difference_temp42
          slave: 42
          address: 18
          precision: 2
          scale: 0.1
          unit_of_measurement: °C
          device_class: temperature
        - name: MSB_heating_mass_counter42
          unique_id: MSB_heating_mass_counter42
          slave: 42
          address: 27
          unit_of_measurement: m3
        - name: LSB_heating_mass_counter42
          unique_id: LSB_heating_mass_counter42
          slave: 42
          address: 28
          precision: 2
          unit_of_measurement: m3
        - name: MSB_cooling_mass_counter42
          unique_id: MSB_cooling_mass_counter42
          slave: 42
          address: 29
          precision: 2
          unit_of_measurement: m3
        - name: LSB_cooling_mass_counter42
          unique_id: LSB_cooling_mass_counter42
          slave: 42
          address: 30
          precision: 2
          unit_of_measurement: m3
        - name: Maximum_instantaneous_power42
          unique_id: Maximum_instantaneous_power42
          slave: 42
          address: 31
          precision: 2
          unit_of_measurement: kW
        - name: Maximum_instantaneous_flow42
          unique_id: Maximum_instantaneous_flow42
          slave: 42
          address: 32
          precision: 2
          unit_of_measurement: m3/h
        - name: Pulse_counterMSB42
          unique_id: Pulse_counterMSB42
          slave: 42
          address: 6
          precision: 2
          unit_of_measurement: m3
        - name: Pulse_counterLSB42
          unique_id: Pulse_counterLSB42
          slave: 42
          address: 7
          precision: 2
          unit_of_measurement: m3
        - name: Pulse_counter_MSBextra42
          unique_id: Pulse_counter_MSBextra42
          slave: 42
          address: 10
          precision: 2
          unit_of_measurement: m3
        - name: Pulse_counter_LSBextra42
          unique_id: Pulse_counter_LSBextra42
          slave: 42
          address: 11
          precision: 2
          unit_of_measurement: m3
          
    #CONTECA 41
        - name: MSB_heating_energy41
          unique_id: MSB_heating_energy41
          slave: 41
          address: 2
          precision: 2
          unit_of_measurement: kWh
        - name: LSB_heating_energy41
          unique_id: LSB_heating_energy41
          slave: 41
          address: 3
          precision: 2
          unit_of_measurement: kWh
        - name: MSB_cooling_energy41
          unique_id: MSB_cooling_energy41
          slave: 41
          address: 4
          precision: 2
          unit_of_measurement: kWh
        - name: LSB_cooling_energy41
          unique_id: LSB_cooling_energy41
          slave: 41
          address: 5
          unit_of_measurement: kWh
        - name: Instantaneous_power41
          unique_id: Instantaneous_power41
          slave: 41
          address: 14
          precision: 2
          unit_of_measurement: kW
        - name: Instantaneous_flow41
          unique_id: Instantaneous_flow41
          slave: 41
          address: 15
          precision: 2
          unit_of_measurement: m3/h
        - name: Flow_temp41
          unique_id: Flow_temp41
          slave: 41
          address: 16
          precision: 2
          scale: 0.1
          unit_of_measurement: °C
          device_class: temperature
        - name: Return_temp41
          unique_id: Return_temp41
          slave: 41
          address: 17
          precision: 2
          scale: 0.1
          unit_of_measurement: °C
          device_class: temperature
        - name: Difference_temp41
          unique_id: Difference_temp41
          slave: 41
          address: 18
          precision: 2
          scale: 0.1
          unit_of_measurement: °C
          device_class: temperature
        - name: MSB_heating_mass_counter41
          unique_id: MSB_heating_mass_counter41
          slave: 41
          address: 27
          unit_of_measurement: m3
        - name: LSB_heating_mass_counter41
          unique_id: LSB_heating_mass_counter41
          slave: 41
          address: 28
          precision: 2
          unit_of_measurement: m3
        - name: MSB_cooling_mass_counter41
          unique_id: MSB_cooling_mass_counter41
          slave: 41
          address: 29
          precision: 2
          unit_of_measurement: m3
        - name: LSB_cooling_mass_counter41
          unique_id: LSB_cooling_mass_counter41
          slave: 41
          address: 30
          precision: 2
          unit_of_measurement: m3
        - name: Maximum_instantaneous_power41
          unique_id: Maximum_instantaneous_power41
          slave: 41
          address: 31
          precision: 2
          unit_of_measurement: kW
        - name: Maximum_instantaneous_flow41
          unique_id: Maximum_instantaneous_flow41 
          slave: 41
          address: 32
          precision: 2
          unit_of_measurement: m3/h
        - name: Pulse_counter_MSBextra41
          unique_id: Pulse_counter_MSBextra41
          slave: 41
          address: 10
          precision: 2
          unit_of_measurement: m3
        - name: Pulse_counter_LSBextra41
          unique_id: Pulse_counter_LSBextra41
          slave: 41
          address: 11
          precision: 2
          unit_of_measurement: m3
        - name: Pulse_counterMSB41
          unique_id: Pulse_counterMSB41
          slave: 41
          address: 6
          precision: 2
          unit_of_measurement: m3
        - name: Pulse_counterLSB41
          unique_id: Pulse_counterLSB41
          slave: 41
          address: 7
          precision: 2
          unit_of_measurement: m3
        - name: Pulse_counterLSB41
          unique_id: Pulse_counterLSB41
          slave: 41
          address: 7
          precision: 2
          unit_of_measurement: m3
          
    #SENECA
        - name: Seneca_sonda_temp1
          unique_id: Seneca_sonda_temp1
          slave: 43
          address: 6
          data_type: float32
          precision: 2
          unit_of_measurement: °C
        - name: Seneca_sonda_temp2
          unique_id: Seneca_sonda_temp2
          slave: 43
          address: 8
          data_type: float32
          precision: 2
          unit_of_measurement: °C
          
    #LEGIOMIX
        - name: Legiomix_model
          unique_id: Legiomix_model
          slave: 40
          address: 0
        - name: Legiomix_ID_modbus
          unique_id: Legiomix_ID_modbus
          slave: 40
          address: 1
        - name: Legiomix_T1
          unique_id: Legiomix_T1
          slave: 40
          address: 2
          scale: 0.01
          precision: 2
          unit_of_measurement: °C
          device_class: temperature
        - name: Legiomix_T2
          unique_id: Legiomix_T2
          slave: 40
          address: 3
          precision: 2
          scale: 0.01
          unit_of_measurement: °C
          device_class: temperature
        - name: Legiomix_status
          unique_id: Legiomix_status
          slave: 40
          address: 6
        - name: Legiomix_adjustment_status
          unique_id: Legiomix_adjustment_status
          slave: 40
          address: 9
        - name: Legiomix_motor_status
          unique_id: Legiomix_motor_status
          slave: 40
          address: 10
        - name: Legiomix_configuration
          unique_id: Legiomix_configuration
          slave: 40
          address: 1005
        - name: Legiomix_disinfection_start_day
          unique_id: Legiomix_disinfection_start_day
          slave: 40
          address: 1011
        - name: Legiomix_setpoint_temperature
          unique_id: Legiomix_setpoint_temperature
          slave: 40
          address: 1006
          precision: 2
          scale: 0.01
          unit_of_measurement: °C
          device_class: temperature
        - name: Legiomix_disinfection
          unique_id: Legiomix_disinfection
          slave: 40
          address: 2001
        - name: Legiomix_motor_test
          unique_id: Legiomix_motor_test
          slave: 40
          address: 2004
        - name: Legiomix_alarms
          unique_id: Legiomix_alarms
          slave: 40
          address: 7
          
binary_sensor: !include_dir_list 485/



this is one of the binary file:

- 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 %}
      alarm_bit_5:
        friendly_name: "ALARM Bit 5"
        value_template: >
          {% if states('sensor.Legiomix_alarms')|int|bitwise_and(16) > 0 %}
            ATTIVO
          {% else %}
            non attivo
          {% endif %}
      alarm_bit_6:
        friendly_name: "ALARM Bit 6"
        value_template: >
          {% if states('sensor.Legiomix_alarms')|int|bitwise_and(32) > 0 %}
            ATTIVO
          {% else %}
            non attivo
          {% endif %}
      alarm_bit_7:
        friendly_name: "ALARM Bit 7"
        value_template: >
          {% if states('sensor.Legiomix_alarms')|int|bitwise_and(64) > 0 %}
            ATTIVO
          {% else %}
            non attivo
          {% endif %}
      alarm_bit_8:
        friendly_name: "ALARM Bit 8"
        value_template: >
          {% if states('sensor.Legiomix_alarms')|int|bitwise_and(128) > 0 %}
            ATTIVO
          {% else %}
            non attivo
          {% endif %}
      alarm_bit_9:
        friendly_name: "ALARM Bit 9"
        value_template: >
          {% if states('sensor.Legiomix_alarms')|int|bitwise_and(128) > 0 %}
            ATTIVO
          {% else %}
            non attivo
          {% endif %}
      alarm_bit_10:
        friendly_name: "ALARM Bit 10"
        value_template: >
          {% if states('sensor.Legiomix_alarms')|int|bitwise_and(128) > 0 %}
            ATTIVO
          {% else %}
            non attivo
          {% endif %}e

You’re using the old format of template sensors, and if you’re on 2023.11, I think they might be completely deprecated by now. The new format can be found here. But you haven’t mentioned what error you’re getting.

Actually, that configuration produces sensor entities, not binary_sensor entities.

They’re still viable; there has been no notice of deprecation. According to the documentation, they’re simply “no longer recommended”.