Missing template by creating sensors

What can be wrong with this:
I have a yaml-file sensors.yaml

sensor:  *Missing property "platform"*
  - platform: template
    today_day:
      friendly_name: Vandaag
      value_template: >-
        {% set months = ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"] %}
        {% set days = ["Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"]  %}
        {{ days[now().weekday()] }} {{ now().day | string }} {{ months[now().month-1] }}

  - platform: template
    today_time:
      friendly_name: Tijd
      value_template: "{{ now().timestamp() | timestamp_custom('%H:%M') }}"
      icon_template: mdi:calendar-clock

  - platform: template
    alarm_status:
        friendly_name: "Alarm Status"
        value_template: >-
          {% if is_state('alarm_control_panel.alarmo', 'armed_away') %}
            Gewapend (weg)
          {% elif is_state('alarm_control_panel.alarmo', 'armed_home') %}
            Gewapend (thuis)
          {% elif is_state('alarm_control_panel.alarmo', 'disarmed') %}
            Uitgeschakeld
          {% else %}
            Onbekend
          {% endif %}

The cause of the error message is that you have include the unneeded top-level sensor configuration key, but you have also left out sensors under the template platform which is required.

- platform: template
  sensors: 
    today_day:
      friendly_name: Vandaag
      value_template: >-
        {% set months = ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"] %}
        {% set days = ["Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"]  %}
        {{ days[now().weekday()] }} {{ now().day | string }} {{ months[now().month-1] }}

    today_time:
      friendly_name: Tijd
      value_template: "{{ now().timestamp() | timestamp_custom('%H:%M') }}"
      icon_template: mdi:calendar-clock

    alarm_status:
      friendly_name: "Alarm Status"
      value_template: >-
        {% if is_state('alarm_control_panel.alarmo', 'armed_away') %}
          Gewapend (weg)
        {% elif is_state('alarm_control_panel.alarmo', 'armed_home') %}
          Gewapend (thuis)
        {% elif is_state('alarm_control_panel.alarmo', 'disarmed') %}
          Uitgeschakeld
        {% else %}
          Onbekend
        {% endif %}

Thx for your reply.
The things you changed that is how i had it working before.
Then i wanted to add the system monitor sensor and was a little bit confused.
That’s why i put the sensor on the toplevel but off course this gave me an error “Duplicate key”.

sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /config
      - type: memory_free

I did some research on the forum and found this thread:

So now i’m a little bit confused BUT the strange thing is that the sensors are working ???

The top-level sensor is already covered by the way the file is merged with the !include. You can add sensors of other platforms to the list being merged like:

- platform: template
  sensors: 
    today_day:
      friendly_name: Vandaag
      value_template: >-
        {% set months = ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"] %}
        {% set days = ["Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"]  %}
        {{ days[now().weekday()] }} {{ now().day | string }} {{ months[now().month-1] }}

    today_time:
      friendly_name: Tijd
      value_template: "{{ now().timestamp() | timestamp_custom('%H:%M') }}"
      icon_template: mdi:calendar-clock

    alarm_status:
      friendly_name: "Alarm Status"
      value_template: >-
        {% if is_state('alarm_control_panel.alarmo', 'armed_away') %}
          Gewapend (weg)
        {% elif is_state('alarm_control_panel.alarmo', 'armed_home') %}
          Gewapend (thuis)
        {% elif is_state('alarm_control_panel.alarmo', 'disarmed') %}
          Uitgeschakeld
        {% else %}
          Onbekend
        {% endif %}

- platform: systemmonitor
  resources:
    - type: disk_use_percent
      arg: /config
    - type: memory_free

You can event declare the platform for each individual sensor like you did in your first post. Just make sure the indentation is the same and that required keys like sensors are provided.

Example with declared platforms
- platform: template
  sensors: 
    today_day:
      friendly_name: Vandaag
      value_template: >-
        {% set months = ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"] %}
        {% set days = ["Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"]  %}
        {{ days[now().weekday()] }} {{ now().day | string }} {{ months[now().month-1] }}

- platform: template
  sensors: 
    today_time:
      friendly_name: Tijd
      value_template: "{{ now().timestamp() | timestamp_custom('%H:%M') }}"
      icon_template: mdi:calendar-clock

- platform: template
  sensors: 
    alarm_status:
      friendly_name: "Alarm Status"
      value_template: >-
        {% if is_state('alarm_control_panel.alarmo', 'armed_away') %}
          Gewapend (weg)
        {% elif is_state('alarm_control_panel.alarmo', 'armed_home') %}
          Gewapend (thuis)
        {% elif is_state('alarm_control_panel.alarmo', 'disarmed') %}
          Uitgeschakeld
        {% else %}
          Onbekend
        {% endif %}

- platform: systemmonitor
  resources:
    - type: disk_use_percent
      arg: /config
    - type: memory_free
1 Like

That’s it !!!
Thank you so much for your help.
I really appreciate this !!

One litlle question:
I copied this piece of code from the documentation:

sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /config
      - type: memory_free

but you deleted the keyword “sensor”
Is the documentation outdated or am i missing something ?

The documentation is not outdated… The general convention in the documentation is to give examples as if they are being added directly to configuration.yaml. Your file, sensor.yaml, is being merged into configuration.yaml, but it is not the configuration.yaml file; so the rules are slightly different.

Due to the way it is being merged, there is already an implied top-level sensor key.

Resources:
Thomas Loven’s Primer: YAML For Non-programmers
HA Docs: YAML
HA Docs: Splitting the Config

Got it.
Thx again :wink: