Invalid Configuration in configuration.yaml

I’ve been updating my configuration.yaml and sensors.yaml and I keep getting this error:

“Invalid config for 'sensor' at configuration.yaml, line 14: required key 'platform' not provided”

I’ve followed the instructions, but I’m at a loss. I would upload the files, but it seems the .yaml files are not recognized ( grayed out).

Plese help.

You'll have to post the config entries you have under 'sensor:' on line 14 of whichever file is offending for us to be able to help you out.

Also please ensure the the yaml you post is wrapped in a codeblock.

You will need to update your YAML. -'platform has been depreciated!

These threads will assist you :down_arrow:

Far too much code for. the editor. This the top of my sensor.yaml. All the sensors in the file have been remade.

template:

  • sensor:
    • name: Garage Overhead
      state: >-
      {% if(state_attr('cover.garage_overhead', 'is_closed') | lower == 'true') %}
      Closed
      {% else %}
      Open
      {% endif %}
    • name: Bayshore Printer Ststus
      state: >-
      {% if(states('sensor.bayshore_status') | lower == 'off') %}
      {% else %}
      {{ states('sensor.bayshore_status') }}
      {% endif %}
    • name: Lorenzo Not Out Back
      state: >-
      {% if(states('sensor.my_dang_iphone') | lower != 'patio') and states('sensor.my_dang_iphone') | lower != 'backyard' %}
      true
      {% else %}
      false
      {% endif %}
    • name: Living Room Homepod Volume
      state: >-
      {% set volume = state_attr('media_player.living_room_homepod_2', 'volume_level') %}
      {{ volume }}
    • name: Proxmox CPU Temp
      state: >-
      {% set t = states("input_number.cpu_temp") | multiply(0.001) | round(1) %}
      {{((t)*1.8)+32 | int}}

Here is the top of my configuration.yaml:

default_config:

cloud:

# Text to speech
tts:

  • platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml ←- Error here line 14
light groups: !include light-groups.yaml
zone: !include zones.yaml

As @HappyCadaver pointed out, please use code blocks

You can use blocked back ticks ``` or the built in preformatted option in the reply window.

I’ll try it again sensors.yaml

``

template:

  • sensor:
    • name: Garage Overhead
      state: >-
      {% if(state_attr('cover.garage_overhead', 'is_closed') | lower == 'true') %}
      Closed
      {% else %}
      Open
      {% endif %}
    • name: Bayshore Printer Ststus
      state: >-
      {% if(states('sensor.bayshore_status') | lower == 'off') %}
      {% else %}
      {{ states('sensor.bayshore_status') }}
      {% endif %}
    • name: Lorenzo Not Out Back
      state: >-
      {% if(states('sensor.my_dang_iphone') | lower != 'patio') and states('sensor.my_dang_iphone') | lower != 'backyard' %}
      true
      {% else %}
      false
      {% endif %}
    • name: Living Room Homepod Volume
      state: >-
      {% set volume = state_attr('media_player.living_room_homepod_2', 'volume_level') %}
      {{ volume }}
    • ``

Configuration.yaml

``

cloud:

tts:

  • platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml
light groups: !include light-groups.yaml
zone: !include zones.yaml

``

Use 3 back ticks at the top and bottom for multiple line code blocks

should there be something between these lines ...like "Off" ?

Saw it too and agree, but it wouldn't cause the main issue in the OP :up_arrow:

The template sensor state would just report a blank string.

sensors.yaml

template:
  - sensor:
    - name: Garage Overhead
      state: >-
            {% if(state_attr('cover.garage_overhead', 'is_closed') | lower == 'true') %}
                Closed
            {% else %}
                Open
            {% endif %}
    - name: Bayshore Printer Ststus
      state: >-
             {% if(states('sensor.bayshore_status') | lower == 'off') %}
                Off
                {% else %}    
                {{ states('sensor.bayshore_status') }}
             {% endif %}
    - name: Lorenzo Not Out Back
      state: >-
            {% if(states('sensor.my_dang_iphone') | lower != 'patio') and states('sensor.my_dang_iphone') | lower != 'backyard' %}
                true
            {% else %}
                false
            {% endif %}
    - name: Living Room Homepod Volume
      state: >-
            {% set volume = state_attr('media_player.living_room_homepod_2', 'volume_level') %}
            {{ volume }}
```

configuration.yaml

default_config:

cloud:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml <-- Error here at line 14
light groups: !include light-groups.yaml
zone: !include zones.yaml
```

should be “light:!include light-groups.yam"

There is no such “ light groups: " just use light:

Now that I can read. You are using template sensors and not sensors in the sense of platform implementation. It's been a while since I went to packages but I think what you want here on line 14 is:

template: !include templates.yaml

This now becomes the top template key for all the template sensors that you have created.
Now change the name of the sensors.yalm file to templates.yaml. And last but not least you need to remove the top level template in your now newly named templates.yaml file (since it's already declared in your configuration.yaml file) and move everything back 2 spaces to begin at the margin... like this:

- sensor:
  - name: Garage Overhead
    state: >-
          {% if(state_attr('cover.garage_overhead', 'is_closed') | lower == 'true') %}
              Closed
          {% else %}
              Open
          {% endif %}
  - name: Bayshore Printer Ststus
    state: >-
           {% if(states('sensor.bayshore_status') | lower == 'off') %}
              Off
              {% else %}    
              {{ states('sensor.bayshore_status') }}
           {% endif %}
  - name: Lorenzo Not Out Back
    state: >-
          {% if(states('sensor.my_dang_iphone') | lower != 'patio') and states('sensor.my_dang_iphone') | lower != 'backyard' %}
              true
          {% else %}
              false
          {% endif %}
  - name: Living Room Homepod Volume
    state: >-
          {% set volume = state_attr('media_player.living_room_homepod_2', 'volume_level') %}
          {{ volume }}

I'm guessing that your reading from the Splitting the configuration file docs which seem a bit dated to me (the HA team is working on that).

@petro are the examples in that documentation still valid with recent changes to templating?

Thanks it works now.

Yes