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
TLDR: Legacy template entities (alarm_control_panel, binary_sensor, cover, fan, light, lock, sensor, switch, vacuum, weather) are being deprecated in 2025.12. Legacy template entities will no longer work after 2026.6. I wanted to avoid the deprecation, however it’s apparent that it’s not possible due to future plans.
Do not use AI to migrate. AI will screw up the yaml. Use the tools provided in this post, if you use AI you are on your own.
The Deprecation
Please use this thread to ask ques…
2025.12 - 2026.6 Legacy Template Entity Deprecation
Legacy template entities (alarm_control_panel, binary_sensor, cover, fan, light, lock, sensor, switch, vacuum, weather) have been removed in 2026.6. You have to migrate to modern template entity syntax.
This change has been in the works for the past 6 months, and you should have received repairs for every legacy template when using versions 2025.12, 2026.1, 2026.2, 2026.3, 2026.4, and 2026.5. If you are still on those versions and you have t…
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
Format it properly
When sharing the code, share it as text and not an image. When you do that, remember that spacing is critical in YAML, and if you just throw the code on the page then it'll look ugly and nobody will know if the problem is because of spacing. We need you to use code blocks and appropriate markup.
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
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?