Sensor Layout before 2026.6

I think I am over complicating this. I am trying to fix the layout so that the error goes away. I have sensor in a separate folder.
sensor: !include sensors.yaml
It is asking for platform.

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

I can not have it in a separate file any more? Like I said before I am sure I am making this harder than it needs to be.

If you have defined your sensors in a separate file, you need to remove all references to them in your configuration.yaml Show us your config file and we will be able to point you to the issue(s).

If this is related to Template Sensors, please see:

1 Like

All the sensors have to be in the configuration.yaml file now correct? That is the way I am reading it.

No, not unless you want to move them there. The only thing that needs to move out of sensors.yaml are Template sensors… everything else can stay there.

The above-linked thread has dozens of examples showing the various ways to migrate legacy template sensor configuration to the current syntax. The Solution Post has links to migration guides for multiple config styles as well as a custom integration to perform the migration automatically.

That whole file is value_templates. I can’t wrap my head around it. I will figure out a different way to do this.

configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts: !include tts.yaml
homeassistant:
  customize: !include customize.yaml
  allowlist_external_dirs:
    - /media
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
recorder:
  purge_keep_days: 5
envisalink: !include envisalink.yaml
switch: !include switch.yaml
input_boolean: !include input_boolean.yaml
google_assistant: !include google_assistant_integ.yaml
http: !include http.yaml
calendar: !include calendar.yaml
shell_command: !include shell_command.yaml
multiscrape: !include multiscrape.yaml
device_tracker: !include device_tracker.yaml 
conversation: !include intents.yaml 
intent_script: !include intent_scripts.yaml
#iperf3: !include iperf3.yaml
binary_sensor: !include binary_sensor.yaml
rest: !include rest.yaml
mqtt: !include mqtt.yaml
notify: !include notify.yaml
template: !include sensors.yaml
assist_pipeline:

This is my sensors.yaml

template:
  - sensor:
      storm_bearing_direction:
        friendly_name: "Storm bearing direction"
        icon_template: "mdi:compass"
        value_template: >
          {% set directions = [
              'North','North North East','North East','East North East','East','East South East',
              'South East','South South East','South','South South West','South West',
              'West South West','West','West North West','North West','North North West','North'
          ] %}
          {% set degree = states('sensor.pirateweather_nearest_storm_bearing') | float %}
          {{ directions[((degree + 11.25) / 22.5) | int] }}
      wind_bearing_direction:
        friendly_name: "Wind bearing direction"
        icon_template: "mdi:compass"
        value_template: >
          {% set directions = [
              'North','North North East','North East','East North East','East','East South East',
              'South East','South South East','South','South South West','South West',
              'West South West','West','West North West','North West','North North West','North'
          ] %}
          {% set degree = states('sensor.pirateweather_wind_bearing') | float %}
          {{ directions[((degree + 11.25) / 22.5) | int] }}
      lightning_direction:
        friendly_name: "Lightning direction"
        icon_template: "mdi:weather-lightning"
        value_template: >
          {% set directions = [
              'North','North North East','North East','East North East','East','East South East',
              'South East','South South East','South','South South West','South West',
              'West South West','West','West North West','North West','North North West','North'
          ] %}
          {% set degree = states('sensor.lighting_detection_lightning_azimuth') | float %}
          {{ directions[((degree + 11.25) / 22.5) | int] }}
      nws_alert_type:
        friendly_name: "NWS alert type"
        value_template: "{{ state_attr('sensor.nws_alerts', 'Alerts')[0].Event }}"
      nws_alert_speak:
        friendly_name: "NWS alert headline"
        value_template: "{{ state_attr('sensor.nws_alerts', 'Alerts')[0].Headline }}"
      wind_shear:
        friendly_name: "Wind shear (m/s)"
        unit_of_measurement: "m/s"
        value_template: "{{ round((states('sensor.ads_ws1_average_wind_speed') | float - states('sensor.ads_ws1_wind_gust') | float), 2) }}"
      allergy_today:
        friendly_name: "Allergy today"
        value_template: >
          {% set allergy = states('sensor.allergy_index_today') | float %}
          {% if allergy <= 2.4 %} Low
          {% elif allergy <= 4.8 %} Low/High
          {% elif allergy <= 7.2 %} Medium
          {% elif allergy <= 9.6 %} Medium/High
          {% elif allergy <= 12.0 %} High
          {% else %} unavailable
          {% endif %}
      allergy_tomorrow:
        friendly_name: "Allergy tomorrow"
        value_template: >
          {% set allergy = states('sensor.allergy_index_tomorrow') | float %}
          {% if allergy <= 2.4 %} Low
          {% elif allergy <= 4.8 %} Low/High
          {% elif allergy <= 7.2 %} Medium
          {% elif allergy <= 9.6 %} Medium/High
          {% elif allergy <= 12.0 %} High
          {% else %} unavailable
          {% endif %}
      allergy_forecast:
        friendly_name: "Allergy forecast"
        value_template: >
          {% set allergy = states('sensor.allergy_index_forecasted_average') | float %}
          {% if allergy <= 2.4 %} Low
          {% elif allergy <= 4.8 %} Low/High
          {% elif allergy <= 7.2 %} Medium
          {% elif allergy <= 9.6 %} Medium/High
          {% elif allergy <= 12.0 %} High
          {% else %} unavailable
          {% endif %}
      home_to_work_delay:
        friendly_name: "Home → Work delay (min)"
        unit_of_measurement: "min"
        value_template: >
          {{
            ((states('sensor.df_electronics') | float(0) - 21) | round(0)) + 5
          }}
      speedtest_download_rounded:
        unit_of_measurement: "Mbps"
        value_template: >
          {{
            ((states('sensor.speedtest_download') | float(0) / 1) | round(2))
          }}
      speedtest_upload_rounded:
        unit_of_measurement: "Mbps"
        value_template: >
          {{
            ((states('sensor.speedtest_upload') | float(0) / 1) | round(2)) 
          }}
      storm_direction:
        friendly_name: "Storm direction"
        icon_template: "mdi:compass"
        value_template: >
          {% set directions = [
              'North','North North East','North East','East North East','East','East South East',
              'South East','South South East','South','South South West','South West',
              'West South West','West','West North West','North West','North North West','North'
          ] %}
          {% set degree = states('sensor.pirateweather_nearest_storm_bearing') | float %}
          {{ directions[((degree + 11.25) / 22.5) | int] }}
      wind_direction:
        friendly_name: "Wind bearing direction"
        icon_template: "mdi:compass"
        value_template: >
          {% set directions = [
              'North','North North East','North East','East North East','East','East South East',
              'South East','South South East','South','South South West','South West',
              'West South West','West','West North West','North West','North North West','North'
          ] %}
          {% set degree = states('sensor.pirateweather_wind_bearing') | float %}
          {{ directions[((degree + 11.25) / 22.5) | int] }}
      lightning_home:
        friendly_name: "Home Lightning direction"
        icon_template: "mdi:weather-lightning"
        value_template: >
          {% set directions = [
              'North','North North East','North East','East North East','East','East South East',
              'South East','South South East','South','South South West','South West',
              'West South West','West','West North West','North West','North North West','North'
          ] %}
          {% set degree = states('sensor.lighting_detection_lightning_azimuth') | float %}
          {{ directions[((degree + 11.25) / 22.5) | int] }}
      nws_type:
        friendly_name: "NWS alert type"
        value_template: "{{ state_attr('sensor.nws_alerts', 'Alerts')[0].Event }}"
      nws_speak:
        friendly_name: "NWS alert headline"
        value_template: "{{ state_attr('sensor.nws_alerts', 'Alerts')[0].Headline }}"
      wind_speed:
        friendly_name: "Wind shear (m/s)"
        unit_of_measurement: "m/s"
        value_template: "{{ round((states('sensor.ads_ws1_average_wind_speed') | float - states('sensor.ads_ws1_wind_gust') | float), 2) }}"
      allergy_now:
        friendly_name: "Allergy today"
        value_template: >
          {% set allergy = states('sensor.allergy_index_today') | float %}
          {% if allergy <= 2.4 %} Low
          {% elif allergy <= 4.8 %} Low/High
          {% elif allergy <= 7.2 %} Medium
          {% elif allergy <= 9.6 %} Medium/High
          {% elif allergy <= 12.0 %} High
          {% else %} unavailable
          {% endif %}
      allergy_tom:
        friendly_name: "Allergy tomorrow"
        value_template: >
          {% set allergy = states('sensor.allergy_index_tomorrow') | float %}
          {% if allergy <= 2.4 %} Low
          {% elif allergy <= 4.8 %} Low/High
          {% elif allergy <= 7.2 %} Medium
          {% elif allergy <= 9.6 %} Medium/High
          {% elif allergy <= 12.0 %} High
          {% else %} unavailable
          {% endif %}
      allergy_fore:
        friendly_name: "Allergy forecast"
        value_template: >
          {% set allergy = states('sensor.allergy_index_forecasted_average') | float %}
          {% if allergy <= 2.4 %} Low
          {% elif allergy <= 4.8 %} Low/High
          {% elif allergy <= 7.2 %} Medium
          {% elif allergy <= 9.6 %} Medium/High
          {% elif allergy <= 12.0 %} High
          {% else %} unavailable
          {% endif %}
      work_delay:
        friendly_name: "Home → Work delay (min)"
        unit_of_measurement: "min"
        value_template: >
          {{
            ((states('sensor.df_electronics') | float(0) - 21) | round(0)) + 5
          }}
      speedtest_download_round:
        unit_of_measurement: "Mbps"
        friendly_name: "Rounded Download Speedtest "
        value_template: >
          {{
            ((states('sensor.speedtest_download') | float(0) / 1) | round(2))
          }}
      speedtest_upload_round:
        friendly_name: ""
        unit_of_measurement: "Mbps"
        value_template: >
          {{
            ((states('sensor.speedtest_upload') | float(0) / 1) | round(2)) 
          }}

This is so messed up that my binary_sensors.yaml just quit working.

Remove the template: Start your file with sensor: and adjust the indentations

That will not fix the problem.


You didn’t do any of the syntax conversions…

If you have Template Binary sensors in there, they also need to be converted.


My advise would be to return your sensors.yaml and it’s inclusion line in configuration.yaml to it’s previous state, then use the custom integration/conversion tool Petro provided. The tool will find all your existing legacy template configuration entries, convert their syntax keeping the original entity IDs and Names, and move them to appropriate files in a new folder. From downloading the integration to having everything sorted shouldn’t take more than 10 minutes.

Based on what you provided this is what it was previously
- platform: template
  sensors:
    storm_bearing_direction:
      friendly_name: "Storm bearing direction"
      icon_template: "mdi:compass"
      value_template: >
        {% set directions = [
            'North','North North East','North East','East North East','East','East South East',
            'South East','South South East','South','South South West','South West',
            'West South West','West','West North West','North West','North North West','North'
        ] %}
        {% set degree = states('sensor.pirateweather_nearest_storm_bearing') | float %}
        {{ directions[((degree + 11.25) / 22.5) | int] }}
    wind_bearing_direction:
      friendly_name: "Wind bearing direction"
      icon_template: "mdi:compass"
      value_template: >
        {% set directions = [
            'North','North North East','North East','East North East','East','East South East',
            'South East','South South East','South','South South West','South West',
            'West South West','West','West North West','North West','North North West','North'
        ] %}
        {% set degree = states('sensor.pirateweather_wind_bearing') | float %}
        {{ directions[((degree + 11.25) / 22.5) | int] }}
    lightning_direction:
      friendly_name: "Lightning direction"
      icon_template: "mdi:weather-lightning"
      value_template: >
        {% set directions = [
            'North','North North East','North East','East North East','East','East South East',
            'South East','South South East','South','South South West','South West',
            'West South West','West','West North West','North West','North North West','North'
        ] %}
        {% set degree = states('sensor.lighting_detection_lightning_azimuth') | float %}
        {{ directions[((degree + 11.25) / 22.5) | int] }}
    nws_alert_type:
      friendly_name: "NWS alert type"
      value_template: "{{ state_attr('sensor.nws_alerts', 'Alerts')[0].Event }}"
    nws_alert_speak:
      friendly_name: "NWS alert headline"
      value_template: "{{ state_attr('sensor.nws_alerts', 'Alerts')[0].Headline }}"
    wind_shear:
      friendly_name: "Wind shear (m/s)"
      unit_of_measurement: "m/s"
      value_template: "{{ round((states('sensor.ads_ws1_average_wind_speed') | float - states('sensor.ads_ws1_wind_gust') | float), 2) }}"
    allergy_today:
      friendly_name: "Allergy today"
      value_template: >
        {% set allergy = states('sensor.allergy_index_today') | float %}
        {% if allergy <= 2.4 %} Low
        {% elif allergy <= 4.8 %} Low/High
        {% elif allergy <= 7.2 %} Medium
        {% elif allergy <= 9.6 %} Medium/High
        {% elif allergy <= 12.0 %} High
        {% else %} unavailable
        {% endif %}
    allergy_tomorrow:
      friendly_name: "Allergy tomorrow"
      value_template: >
        {% set allergy = states('sensor.allergy_index_tomorrow') | float %}
        {% if allergy <= 2.4 %} Low
        {% elif allergy <= 4.8 %} Low/High
        {% elif allergy <= 7.2 %} Medium
        {% elif allergy <= 9.6 %} Medium/High
        {% elif allergy <= 12.0 %} High
        {% else %} unavailable
        {% endif %}
    allergy_forecast:
      friendly_name: "Allergy forecast"
      value_template: >
        {% set allergy = states('sensor.allergy_index_forecasted_average') | float %}
        {% if allergy <= 2.4 %} Low
        {% elif allergy <= 4.8 %} Low/High
        {% elif allergy <= 7.2 %} Medium
        {% elif allergy <= 9.6 %} Medium/High
        {% elif allergy <= 12.0 %} High
        {% else %} unavailable
        {% endif %}
    home_to_work_delay:
      friendly_name: "Home → Work delay (min)"
      unit_of_measurement: "min"
      value_template: >
        {{
          ((states('sensor.df_electronics') | float(0) - 21) | round(0)) + 5
        }}
    speedtest_download_rounded:
      unit_of_measurement: "Mbps"
      value_template: >
        {{
          ((states('sensor.speedtest_download') | float(0) / 1) | round(2))
        }}
    speedtest_upload_rounded:
      unit_of_measurement: "Mbps"
      value_template: >
        {{
          ((states('sensor.speedtest_upload') | float(0) / 1) | round(2)) 
        }}
    storm_direction:
      friendly_name: "Storm direction"
      icon_template: "mdi:compass"
      value_template: >
        {% set directions = [
            'North','North North East','North East','East North East','East','East South East',
            'South East','South South East','South','South South West','South West',
            'West South West','West','West North West','North West','North North West','North'
        ] %}
        {% set degree = states('sensor.pirateweather_nearest_storm_bearing') | float %}
        {{ directions[((degree + 11.25) / 22.5) | int] }}
    wind_direction:
      friendly_name: "Wind bearing direction"
      icon_template: "mdi:compass"
      value_template: >
        {% set directions = [
            'North','North North East','North East','East North East','East','East South East',
            'South East','South South East','South','South South West','South West',
            'West South West','West','West North West','North West','North North West','North'
        ] %}
        {% set degree = states('sensor.pirateweather_wind_bearing') | float %}
        {{ directions[((degree + 11.25) / 22.5) | int] }}
    lightning_home:
      friendly_name: "Home Lightning direction"
      icon_template: "mdi:weather-lightning"
      value_template: >
        {% set directions = [
            'North','North North East','North East','East North East','East','East South East',
            'South East','South South East','South','South South West','South West',
            'West South West','West','West North West','North West','North North West','North'
        ] %}
        {% set degree = states('sensor.lighting_detection_lightning_azimuth') | float %}
        {{ directions[((degree + 11.25) / 22.5) | int] }}
    nws_type:
      friendly_name: "NWS alert type"
      value_template: "{{ state_attr('sensor.nws_alerts', 'Alerts')[0].Event }}"
    nws_speak:
      friendly_name: "NWS alert headline"
      value_template: "{{ state_attr('sensor.nws_alerts', 'Alerts')[0].Headline }}"
    wind_speed:
      friendly_name: "Wind shear (m/s)"
      unit_of_measurement: "m/s"
      value_template: "{{ round((states('sensor.ads_ws1_average_wind_speed') | float - states('sensor.ads_ws1_wind_gust') | float), 2) }}"
    allergy_now:
      friendly_name: "Allergy today"
      value_template: >
        {% set allergy = states('sensor.allergy_index_today') | float %}
        {% if allergy <= 2.4 %} Low
        {% elif allergy <= 4.8 %} Low/High
        {% elif allergy <= 7.2 %} Medium
        {% elif allergy <= 9.6 %} Medium/High
        {% elif allergy <= 12.0 %} High
        {% else %} unavailable
        {% endif %}
    allergy_tom:
      friendly_name: "Allergy tomorrow"
      value_template: >
        {% set allergy = states('sensor.allergy_index_tomorrow') | float %}
        {% if allergy <= 2.4 %} Low
        {% elif allergy <= 4.8 %} Low/High
        {% elif allergy <= 7.2 %} Medium
        {% elif allergy <= 9.6 %} Medium/High
        {% elif allergy <= 12.0 %} High
        {% else %} unavailable
        {% endif %}
    allergy_fore:
      friendly_name: "Allergy forecast"
      value_template: >
        {% set allergy = states('sensor.allergy_index_forecasted_average') | float %}
        {% if allergy <= 2.4 %} Low
        {% elif allergy <= 4.8 %} Low/High
        {% elif allergy <= 7.2 %} Medium
        {% elif allergy <= 9.6 %} Medium/High
        {% elif allergy <= 12.0 %} High
        {% else %} unavailable
        {% endif %}
    work_delay:
      friendly_name: "Home → Work delay (min)"
      unit_of_measurement: "min"
      value_template: >
        {{
          ((states('sensor.df_electronics') | float(0) - 21) | round(0)) + 5
        }}
    speedtest_download_round:
      unit_of_measurement: "Mbps"
      friendly_name: "Rounded Download Speedtest "
      value_template: >
        {{
          ((states('sensor.speedtest_download') | float(0) / 1) | round(2))
        }}
    speedtest_upload_round:
      friendly_name: ""
      unit_of_measurement: "Mbps"
      value_template: >
        {{
          ((states('sensor.speedtest_upload') | float(0) / 1) | round(2)) 
        }}
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts: !include tts.yaml
homeassistant:
  customize: !include customize.yaml
  allowlist_external_dirs:
    - /media
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
recorder:
  purge_keep_days: 5
envisalink: !include envisalink.yaml
switch: !include switch.yaml
input_boolean: !include input_boolean.yaml
google_assistant: !include google_assistant_integ.yaml
http: !include http.yaml
calendar: !include calendar.yaml
shell_command: !include shell_command.yaml
multiscrape: !include multiscrape.yaml
device_tracker: !include device_tracker.yaml 
conversation: !include intents.yaml 
intent_script: !include intent_scripts.yaml
#iperf3: !include iperf3.yaml
binary_sensor: !include binary_sensor.yaml
rest: !include rest.yaml
mqtt: !include mqtt.yaml
notify: !include notify.yaml
sensor: !include sensors.yaml
assist_pipeline:
1 Like

Well, it would eliminate the the error message (line 17 in config - I had only looked at that. :innocent:

Your suggestion to move everything back to restore where the OP started from and apply the migration tool is the best way to go.

I am trying to get the migration tool working at the moment.