Invalid config for 'sensor' at configuration.yaml required key 'platform' not provided - new template syntax

Hi there community!

I updated to 2025.12 and got 37 repairs because of the Deprecation of legacy template entities. So I followed the repair instructions for my modbus integration.

Now when i check the systax, I get the warnings:

Configuration warnings
Invalid config for 'sensor' at configuration.yaml, line 14: required key 'platform' not provided
Invalid config for 'binary_sensor' at configuration.yaml, line 13: required key 'platform' not provided

in my conifguration.yaml:

modbus: !include modbus.yaml
binary_sensor: !include binary_sensor.yaml
sensor: !include sensor.yaml

binary_sensor.yaml

template:
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_emergency_power_possible
      name: E3DC Emergency Power possible
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(4) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_battery_loading_blocked
      name: E3DC Battery loading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(1) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_battery_unloading_blocked
      name: E3DC Battery unloading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(2) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_weather_based_loading
      name: E3DC weather based loading limiter
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(8) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_power_limiter
      name: E3DC power limiter
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(16) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_smartcharge_unloading_blocked
      name: E3DC SmartCharge unloading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(64) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_smartcharge_unloading_blocked
      name: E3DC SmartCharge unloading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(64) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_emergency_power_active
      name: E3DC Emergency Power Mode Active
      state: '{{ is_state(''sensor.e3dc_emergency_power_state'', ''1'') }}'
  - binary_sensor:
    - device_class: POWER
      default_entity_id: binary_sensor.e3dc_emergency_power_available
      name: E3DC Emergency Power Available
      state: '{{ is_state(''sensor.e3dc_emergency_power_state'', ''1'') or is_state(''sensor.e3dc_emergency_power_state'',''2'') }}'

sensor.yaml

template:
- sensor:
  - unit_of_measurement: '%'
    default_entity_id: sensor.e3dc_autarky
    name: E3DC Autarky
    state: '{{ (states(''sensor.e3dc_autarkie_eigenverbrauch'')|int / 256)|round(0,''floor'')}}'
- sensor:
  - unit_of_measurement: '%'
    default_entity_id: sensor.e3dc_own_consumption
    name: E3DC Own Consumption ratio
    state: '{{ ((states(''sensor.e3dc_autarkie_eigenverbrauch'')|int / 256 - states(''sensor.e3dc_autarky'')|int) * 256)|round(0,''floor'') }}'
# Grid out
- sensor:
  - unit_of_measurement: W
    device_class: POWER
    default_entity_id: sensor.e3dc_netz_leistung_out
    state: "{% if states('sensor.e3dc_netz_leistung') | int > 0 %}\n  0\n{% else -%}\n \ {{ (states('sensor.e3dc_netz_leistung') | int) | abs }} \n{% endif %}"
    name: e3dc_netz_leistung_out
# Grid in
- sensor:
  - unit_of_measurement: W
    device_class: POWER
    default_entity_id: sensor.e3dc_netz_leistung_in
    state: "{% if states('sensor.e3dc_netz_leistung') | int > 0 %}\n  {{ states('sensor.e3dc_netz_leistung') | int }}\n{% else -%}\n  0\n{% endif %}"
    name: e3dc_netz_leistung_in
# Battery out
- sensor:
  - unit_of_measurement: W
    device_class: POWER
    default_entity_id: sensor.e3dc_batterie_leistung_out
    state: "{% if states('sensor.e3dc_batterie_leistung') | int > 0 %}\n  0\n{% else -%}\n  {{ (states('sensor.e3dc_batterie_leistung') | int) | abs }} \n{% endif %}"
- sensor:
  - unit_of_measurement: W
    device_class: POWER
    default_entity_id: sensor.e3dc_batterie_leistung_in
    state: "{% if states('sensor.e3dc_batterie_leistung') | int > 0 %}\n  {{ states('sensor.e3dc_batterie_leistung') | int }}\n{% else -%}\n  0\n{% endif %}"
    name: e3dc_batterie_leistung_in
          
- platform: integration
  source: sensor.e3dc_batterie_leistung_out
  name: energy_battery_discharge
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_batterie_leistung_in
  name: energy_battery_charge
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_pv_leistung
  name: energy_solar_production
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_string_1_power
  name: energy_solar_production1
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_string_2_power
  name: energy_solar_production2
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_powermeter_1_L1
  name: energy_solar_powermeter1
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_powermeter_1_L2
  name: energy_solar_powermeter2
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_hausverbrauch
  name: energy_consumption
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_netz_leistung_in
  name: energy_grid_usage
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.e3dc_netz_leistung_out
  name: energy_grid_feed_in
  unit_prefix: k
  round: 2

I am not so familiar with the yaml syntax. What do I get wrong here?

Thx 4 any assistance

1 Like

You cannot just paste entities configured under the template integration into files like sensor.yaml and binary_sensor.yaml which are most likely included under the sensor and binary_sensor integrations respectively. They should be placed into configuration.yaml or a file properly split to be under the template integration.

I dont’t want to blow up my configuration.yaml but have it in seperate files. I thought, thats what includes are for. How do I manage this correctly?

Can you show an example?

At this point there are multiple examples in the deprecation notice thread linked above. If none of those show how to do it the way you want, see the link above about properly splitting your config…

Oh dear. I am new to this and absolutely no expert. I’m glad it worked with the old config syntax. I could really need some help…

but ok: from what I understand is I should do the following:

configuration.yaml

template: !include template.yaml

template.yaml

template:
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_emergency_power_possible
      name: E3DC Emergency Power possible
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(4) > 0 }}'
  - binary_sensor:
... 
<all the sensors>
<including all entries from binary_sensors.yaml>
...

Is that correct???

Except the part where you say “including all entries from binary_sensors.yaml”… if you had binary_sensor entities that were not using platform: template, those need to stay where they were.

ok. getting there…

you see the contents of binary_sensor.yaml above. Means the entries

- platform: integration
  source: sensor.e3dc_batterie_leistung_out
  name: energy_battery_discharge
  unit_prefix: k
  round: 2
... 

should stay in the binary_sensor.yaml?

Yes, the deprecation is only for the template platforms.

Add this line to your configuration.yaml:

template: !include ./yaml/templates.yaml

And then paste your repair code there

For instance templates.yaml would be like

- binary_sensor:
  - name: **************
  - state: *********

I’ve done that. But I recieve a check error:

Invalid config for 'template' at template.yaml, line 1: 'template' is an invalid option for 'template', check: template

but as far as I understood from you guys, it looks fine…

template.yaml

# from binary_sensor.yaml
template:
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_emergency_power_possible
      name: E3DC Emergency Power possible
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(4) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_battery_loading_blocked
      name: E3DC Battery loading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(1) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_battery_unloading_blocked
      name: E3DC Battery unloading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(2) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_weather_based_loading
      name: E3DC weather based loading limiter
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(8) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_power_limiter
      name: E3DC power limiter
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(16) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_smartcharge_unloading_blocked
      name: E3DC SmartCharge unloading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(64) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_smartcharge_unloading_blocked
      name: E3DC SmartCharge unloading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(64) > 0 }}'
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_emergency_power_active
      name: E3DC Emergency Power Mode Active
      state: '{{ is_state(''sensor.e3dc_emergency_power_state'', ''1'') }}'
  - binary_sensor:
    - device_class: POWER
      default_entity_id: binary_sensor.e3dc_emergency_power_available
      name: E3DC Emergency Power Available
      state: '{{ is_state(''sensor.e3dc_emergency_power_state'', ''1'') or is_state(''sensor.e3dc_emergency_power_state'',''2'') }}'
      
      
# from sensor.yaml
  - sensor:
    - unit_of_measurement: '%'
      default_entity_id: sensor.e3dc_autarky
      name: E3DC Autarky
      state: '{{ (states(''sensor.e3dc_autarkie_eigenverbrauch'')|int / 256)|round(0,''floor'')}}'
  - sensor:
    - unit_of_measurement: '%'
      default_entity_id: sensor.e3dc_own_consumption
      name: E3DC Own Consumption ratio
      state: '{{ ((states(''sensor.e3dc_autarkie_eigenverbrauch'')|int / 256 - states(''sensor.e3dc_autarky'')|int) * 256)|round(0,''floor'') }}'
  # Grid out
  - sensor:
    - unit_of_measurement: W
      device_class: POWER
      default_entity_id: sensor.e3dc_netz_leistung_out
      state: "{% if states('sensor.e3dc_netz_leistung') | int > 0 %}\n  0\n{% else -%}\n \ {{ (states('sensor.e3dc_netz_leistung') | int) | abs }} \n{% endif %}"
      name: e3dc_netz_leistung_out
  # Grid in
  - sensor:
    - unit_of_measurement: W
      device_class: POWER
      default_entity_id: sensor.e3dc_netz_leistung_in
      state: "{% if states('sensor.e3dc_netz_leistung') | int > 0 %}\n  {{ states('sensor.e3dc_netz_leistung') | int }}\n{% else -%}\n  0\n{% endif %}"
      name: e3dc_netz_leistung_in
  # Battery out
  - sensor:
    - unit_of_measurement: W
      device_class: POWER
      default_entity_id: sensor.e3dc_batterie_leistung_out
      state: "{% if states('sensor.e3dc_batterie_leistung') | int > 0 %}\n  0\n{% else -%}\n  {{ (states('sensor.e3dc_batterie_leistung') | int) | abs }} \n{% endif %}"
  - sensor:
    - unit_of_measurement: W
      device_class: POWER
      default_entity_id: sensor.e3dc_batterie_leistung_in
      state: "{% if states('sensor.e3dc_batterie_leistung') | int > 0 %}\n  {{ states('sensor.e3dc_batterie_leistung') | int }}\n{% else -%}\n  0\n{% endif %}"
      name: e3dc_batterie_leistung_in

whats wrong?

Remove the template: from the top of the file. That is not needed when using that inclusion method.

Technically, you can also remove most of the domain keys too…

template.yaml:

# from binary_sensor.yaml
  - binary_sensor:
    - default_entity_id: binary_sensor.e3dc_emergency_power_possible
      name: E3DC Emergency Power possible
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(4) > 0 }}' 
    - default_entity_id: binary_sensor.e3dc_battery_loading_blocked
      name: E3DC Battery loading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(1) > 0 }}'
    - default_entity_id: binary_sensor.e3dc_battery_unloading_blocked
      name: E3DC Battery unloading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(2) > 0 }}' 
    - default_entity_id: binary_sensor.e3dc_weather_based_loading
      name: E3DC weather based loading limiter
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(8) > 0 }}' 
    - default_entity_id: binary_sensor.e3dc_power_limiter
      name: E3DC power limiter
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(16) > 0 }}'
    - default_entity_id: binary_sensor.e3dc_smartcharge_unloading_blocked
      name: E3DC SmartCharge unloading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(64) > 0 }}'
    - default_entity_id: binary_sensor.e3dc_smartcharge_unloading_blocked
      name: E3DC SmartCharge unloading blocked
      state: '{{ states(''sensor.e3dc_ems_state'')|int|bitwise_and(64) > 0 }}'  
    - default_entity_id: binary_sensor.e3dc_emergency_power_active
      name: E3DC Emergency Power Mode Active
      state: '{{ is_state(''sensor.e3dc_emergency_power_state'', ''1'') }}' 
    - device_class: POWER
      default_entity_id: binary_sensor.e3dc_emergency_power_available
      name: E3DC Emergency Power Available
      state: '{{ is_state(''sensor.e3dc_emergency_power_state'', ''1'') or is_state(''sensor.e3dc_emergency_power_state'',''2'') }}'
      
      
# from sensor.yaml
  - sensor:
    - unit_of_measurement: '%'
      default_entity_id: sensor.e3dc_autarky
      name: E3DC Autarky
      state: '{{ (states(''sensor.e3dc_autarkie_eigenverbrauch'')|int / 256)|round(0,''floor'')}}'
    - unit_of_measurement: '%'
      default_entity_id: sensor.e3dc_own_consumption
      name: E3DC Own Consumption ratio
      state: '{{ ((states(''sensor.e3dc_autarkie_eigenverbrauch'')|int / 256 - states(''sensor.e3dc_autarky'')|int) * 256)|round(0,''floor'') }}'
  # Grid out
    - unit_of_measurement: W
      device_class: POWER
      default_entity_id: sensor.e3dc_netz_leistung_out
      state: "{% if states('sensor.e3dc_netz_leistung') | int > 0 %}\n  0\n{% else -%}\n \ {{ (states('sensor.e3dc_netz_leistung') | int) | abs }} \n{% endif %}"
      name: e3dc_netz_leistung_out
  # Grid in
    - unit_of_measurement: W
      device_class: POWER
      default_entity_id: sensor.e3dc_netz_leistung_in
      state: "{% if states('sensor.e3dc_netz_leistung') | int > 0 %}\n  {{ states('sensor.e3dc_netz_leistung') | int }}\n{% else -%}\n  0\n{% endif %}"
      name: e3dc_netz_leistung_in
  # Battery out
    - unit_of_measurement: W
      device_class: POWER
      default_entity_id: sensor.e3dc_batterie_leistung_out
      state: "{% if states('sensor.e3dc_batterie_leistung') | int > 0 %}\n  0\n{% else -%}\n  {{ (states('sensor.e3dc_batterie_leistung') | int) | abs }} \n{% endif %}"
    - unit_of_measurement: W
      device_class: POWER
      default_entity_id: sensor.e3dc_batterie_leistung_in
      state: "{% if states('sensor.e3dc_batterie_leistung') | int > 0 %}\n  {{ states('sensor.e3dc_batterie_leistung') | int }}\n{% else -%}\n  0\n{% endif %}"
      name: e3dc_batterie_leistung_in

1 Like

ok, that did the trick. Thanks so much for your help. Appreciate it! :ok_hand:

I have hundreds of template sensors and binary sensors. If only these helpful new configs could be automatically put in a template file along with an include line in the config file and the old sensors commented out. Its going to take ages to go through all these one by one.

That would never have been allowed by the core devs…

The contemporary syntax for sensors and binary sensors was introduced over 4 years ago… and you still have 6 months until the old syntax stops working…

1 Like

This change actually happened like more than a year ago, and you have 6 more months to fix it…

This change was no biggie to me. The repair warning included the correct YAML that was needed. I copy/pasted into my config.yaml file and commented out the old ones and it was all good.

Least stressful breaking change ever!