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?
petro
(Petro)
May 29, 2026, 12:02pm
3
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?
petro
(Petro)
May 29, 2026, 1:10pm
6
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.