Sensor required key 'platform' not provided

Hi, i've this problem with my code here ("Sensor: required key 'platform' not provided"), inside sensors.yaml:

template:
  - sensor:
  - name: Night or Day
    unique_id: night_or_day
    state: >
      {% if is_state('sun.sun', 'above_horizon') %}
        0
      {% else %}
        1
      {% endif %}
    icon: mdi:power-sleep
    
sensor:
  - platform: time_date
   display_options:
  - 'time'
  - 'date'

Any suggest?

Please review

Indentation is wrong in multiple spots

template:
  - sensor:
      - name: Night or Day
        unique_id: night_or_day
        state: >
          {% if is_state('sun.sun', 'above_horizon') %}
            0
          {% else %}
            1
          {% endif %}
        icon: mdi:power-sleep
    
sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'

Done. no folder was created...

Do you have a file editor installed?

That means you don't have legacy templates.

Template sensors (and all other template entities) go under the Template integration, not their domain integrations like sensor... so they do not belong in your sensors.yaml file.