Trying to split config and get templates to work

i am relativly new to home assistant with very little coding knowledge but trying to learn. i am setting up grow tent right now. i have had all my sensors working in the past and when i put them in the template checker they all still work, but are not available. i am trying to split up config to make it easier as i will have an entire house with allot on it eventually. so i have made my template sensors work when they were in a templates.yaml file but as soon as i split it up into templates folder with sensor.yaml, binary_sensor.yaml etc inside the templates folder i cant get them to work i have put my .yaml files with different names in different spots in or out of folder, i have used the !include: in config. here are a couple snippets of my yaml to see if anyone can help me figure out the problem. i have changed everything so much i am lost now as to how it was. this is 1 sensor in the sensor.yaml file which is not in a folder

- sensor:
    ###############     Air Temperature      ############
    - name: "tent_average_temp"
      unique_id: tent_average_temp
      unit_of_measurement: "°C"
      state: >-
        {{ ((states('sensor.bme280_canopy_temperature') | float + 
            states('sensor.bme280_flower_temperature') | float) / 2) | round(1) }}

this is my config with my !include:'s

###########   Include    #################

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template: !include templates.yaml
#binary_sensors: !include binary_sensors.yaml
sensor: !include sensor.yaml/

this is my templates.yaml with a buch od sensors

- binary_sensor:
    - name: "moisture_sensor_1_flood_detected"
      unique_id: moisture_sensor_1_flood_detected
      state: "{{ states('sensor.plant_1_moisture') | float > 20 }}"

    - name: "moisture_sensor_2_flood_detected"
      unique_id: moisture_sensor_2_flood_detected
      state: "{{ states('sensor.plant_2_moisture') | float > 20 }}"
      device_class: moisture

    - name: "moisture_sensor_3_flood_detected"
      unique_id: moisture_sensor_3_flood_detected
      state: "{{ states('sensor.plant_3_moisture') | float > 20 }}"
      device_class: moisture

    - name: "moisture_sensor_4_flood_detected"
      unique_id: moisture_sensor_4_flood_detected
      state: "{{ states('sensor.plant_4_moisture') | float > 20 }}"
      device_class: moisture

- sensor:
    ###############     Air Temperature      ############
    - name: "tent_average_temp"
      unique_id: tent_average_temp
      unit_of_measurement: "°C"
      state: >-
        {{ ((states('sensor.bme280_canopy_temperature') | float + 
            states('sensor.bme280_flower_temperature') | float) / 2) | round(1) }}

    ###############     Air Humidity      ############
    - name: "tent_average_humidity"
      unique_id: tent_average_humidity
      unit_of_measurement: "%"
      state: >-
        {{ ((states('sensor.bme280_canopy_humidity') | float + 
            states('sensor.bme280_flower_humidity') | float) / 2) | round(1) }}

sensor: !include sensor.yaml/

Is the / actually in your file?

Once you’ve fixed the / that @armedad pointed out,

You have the sensor: heading in the !include line of the main file, so remove it from here. Sensor file should start:

- name: blah

It’s a bit confusing because your templates.yaml should start with - sensor: or - binary_sensor as they are the “second level” under template:. The templates.yaml file you posted is correct.

Have you put them in a different folder? With the !include statements you’ve used (with the extra / removed), they should be in the same folder as configuration.yaml.

If you want to put them in folders and potentially split them up further, you can do something like this:

sensor: !include_dir_merge_list sensors
template: !include_dir_merge_list templates

Create a sensors and templates folder, then you can have multiple YAML files in each folder with whatever filename you want (ending in .yaml):

config/
  configuration.yaml 
  sensors/
    binary-sensors.yaml
    sensors.yaml
    car.yaml
  templates/
    templates.yaml
    heating-templates.yaml
    lights.yaml

ok i am definetly going with the !include_dir_merge_list version where i can split up my files for organization. i now have set up a tent_templates.yaml and a air_quality_templates.yaml file in a templates folder. everything works in the tent_templates.yaml but nothing works that is in the air_quality_templates.yaml. if i use
automation: !include automations.yaml

script: !include scripts.yaml

scene: !include scenes.yaml

sensor: !include_dir_merge_list sensors

template: !include_dir_merge_list templates

air_quality_template: !include_dir_merge_list air_quality_templates

i get this error Configuration warnings

`Integration error: air_quality_template - Integration 'air_quality_template' not found.` 
this is my air_quality_templates.yaml file
- sensor:
    ###############     Air Temperature      ############
    - name: "tent_average_temp"
      unique_id: tent_average_temp
      unit_of_measurement: "°C"
      state: >-
        {{ ((states('sensor.bme280_canopy_temperature') | float + 
            states('sensor.bme280_flower_temperature') | float) / 2) | round(1) }}

    ###############     Air Humidity      ############
    - name: "tent_average_humidity"
      unique_id: tent_average_humidity
      unit_of_measurement: "%"
      state: >-
        {{ ((states('sensor.bme280_canopy_humidity') | float + 
            states('sensor.bme280_flower_humidity') | float) / 2) | round(1) }}

    ###############     Air Pressure      ############
    - name: "tent_average_pressure"
      unique_id: tent_average_pressure
      unit_of_measurement: "PSI"
      state: >-
        {{ ((states('sensor.bme280_canopy_pressure') | float + 
            states('sensor.bme280_flower_pressure') | float) / 2) | round(1) }}

    ################# Dew Point -  VPD  #################
    - name: "Dew Point"
      unit_of_measurement: "°C"
      value_template: >-
      availability_template: >
        {{ states('sensor.tent_average_temp') not in ['unavailable', 'unknown'] and
        states('sensor.tent_average_humidity') not in ['unavailable', 'unknown'] }}
    - name: "VPD"
      unit_of_measurement: "kPa"
      value_template: >-
        {% set temperature = states('sensor.tent_average_temp') | float(default=0) %}
        {% set humidity = states('sensor.tent_average_humidity') | float(default=0) %}
        {% set saturation_vapor_pressure = 0.6108 * (e ** ((17.27 * temperature) / (temperature + 237.3))) %}
        {% set actual_vapor_pressure = saturation_vapor_pressure * humidity / 100 %}
        {% set vpd = saturation_vapor_pressure - actual_vapor_pressure %}
        {{ vpd | round(2) }}

this is a pic of my file layout

are there any issues with mixing different sensors with switches with cameras etc. in 1 .yaml templates file?
do i need to use templates in the name of the file?
this is a pic of the VPD sensor which is in the air_quality_templatesss.yaml file just showing it works.

i have seen the Templates and sensor templates pages but is there any good documentation on what exactly to put where as far as syntax etc goes?
Thanks for everything by the way!!!

Remove that line. This line:

template: !include_dir_merge_list templates

means “pull in all YAML files in the templates folder (or sub-folders) and join them all together”. You’ve introduced an unknown top-level heading with your new line.

Yes. If you want to split things that way, look into Packages instead.

No, any .yaml file in the templates folder will get read in.

ok i got the everything working. air_quality_templates.yaml was big indentation error. But as for mixing different entities in same file what is the issue. i do have binary sensors and sensors in 1 yaml and it is working? just getting into this but want to do it right the first time without even more ballistic learning curve. are packages not something i should look at in the future are they hard to setup and work around?
P.S Great thanks for your help so far!!

You can mix things that sit under the same top-level heading, template: in this case.