Deprecated E3DC sensor templates

Hi everyone,

I have 7 repairs mentioned regarding E3DC (my solar power system) sensor templates. I tried editing the templates to the new syntax, but I failed miserably because I just don’t get it.

The mentioned repairs need to be done at /homeassistant/packages/e3dc/sensors.yaml and all read like this:

Below is the current content of the sensors.yaml:

e3dc_sensors:
  sensor:
    # Templates
    - platform: template
      sensors:
        e3dc_grid_export_power:
          unique_id: e3dc_grid_export_power
          friendly_name: "E3DC Grid Export Power"
          unit_of_measurement: "W"
          device_class: power
          value_template: >
            {% set power = states('sensor.e3dc_grid_power') | int(0) %}
            {% if power > 0 %}
              0
            {% else -%}
              {{ power | abs }}
            {% endif %}
        e3dc_grid_import_power:
          unique_id: e3dc_grid_import_power
          friendly_name: E3DC Grid Import Power
          unit_of_measurement: W
          device_class: power
          value_template: >
            {% set power = states('sensor.e3dc_grid_power') | int(0) %}
            {% if power > 0 %}
              {{ power }}
            {% else -%}
              0
            {% endif %}
        e3dc_battery_charge_power:
          unique_id: e3dc_battery_charge_power
          friendly_name: E3DC Battery Charging Power
          unit_of_measurement: W
          device_class: power
          value_template: >
            {% set power = states('sensor.e3dc_battery_power') | float(0) %}
            {% if power >= 0 %}
              {{ power }}
            {% else %}
              {% set charge_power = states('sensor.e3dc_battery_charge_power') | float(0) + power %}
              {{ charge_power if charge_power > 0 else 0 }}
            {% endif %}
        e3dc_battery_discharge_power:
          unique_id: e3dc_battery_discharge_power
          friendly_name: E3DC Battery Discharging Power
          unit_of_measurement: W
          device_class: power
          value_template: >
            {% set power = states('sensor.e3dc_battery_power') | float(0) %}
            {% if power <= 0 %}
              {{ power | abs }} 
            {% else %}
              {% set discharge_power = states('sensor.e3dc_battery_charge_power') | float(0) - power %}
              {{ discharge_power if discharge_power > 0 else 0 }}
            {% endif %}
        e3dc_autarky:
          friendly_name: "E3DC Autarky"
          unique_id: e3dc_autarky
          unit_of_measurement: "%"
          value_template: "{{ (states('sensor.e3dc_autarky_and_consumption')|int(0) / 256)|round(0,'floor') }}"
        e3dc_own_consumption:
          friendly_name: "E3DC Own Consumption Ratio"
          unique_id: e3dc_own_consumption_ratio
          unit_of_measurement: "%"
          value_template: "{{ ((states('sensor.e3dc_autarky_and_consumption')|int(0) / 256 - states('sensor.e3dc_autarky')|int(0)) * 256)|round(0,'floor') }}"
        e3dc_emergency_power_state_text:
          friendly_name: E3DC Emergency Power State Text
          unique_id: e3dc_emergency_power_state_text
          value_template: >
            {% set eps = states('sensor.e3dc_emergency_power_state') %}
            {% if eps == '0' %}
              nicht unterst├╝tzt
            {% elif eps == '1' %}
              aktiv
            {% elif eps == '2' %}
              inaktiv
            {% elif eps == '3' %}
              nicht verf├╝gbar
            {% elif eps == '4' %}
              falsche Position
            {% else %}
              unbekannt
            {% endif %}
    # Integrations
    - platform: integration
      source: sensor.e3dc_grid_import_power
      name: E3DC Grid Import Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_grid_export_power
      name: E3DC Grid Export Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_solar_power
      name: E3DC Solar Energy
      unit_prefix: k
      round: 2
      method: left
#    - platform: integration
#      source: sensor.e3dc_external_power
#      name: E3DC External Power
#      unit_prefix: k
#      round: 2
#      method: left
    - platform: integration
      source: sensor.e3dc_battery_power
      name: E3DC Builtin Battery Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_battery_charge_power
      name: E3DC Battery Charge Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_battery_discharge_power
      name: E3DC Battery Discharge Energy
      unit_prefix: k
      round: 2
      method: left

I began cautious and just tried changing the first entry (e3dc grid export power), but it won’t let me reboot HA due to a misconfiguration error. After playing around with the indentations it would let me reboot, but the corresponding entity then says “not found”.

I have for now reverted the file to its previous state. Maybe someone can explain to me what exactly I have to do? Thanks!

First, don’t panic. You have 6 months to get this done. Plenty of time.

There is a pinned topic about this: Deprecation of legacy template entities in 2025.12

Have a read, particularly of the first post then if you still don’t get it ask there.

There are plenty of people monitoring the topic to help.

But basically you have a few options:

  1. The simplest: use the migration script to do it all for you. The details are in that pinned topic.

Or

  1. Comment out one of your sensors. Past the repair config for the same sensor into your configuration.yaml (not your sensors.yaml!), do a config check and restart. If it all goes well then repeat for the other sensors, noting that you only need the top level template: part once in your configuration.yaml. And you only have to do the platform: template sensors. Leave the other platform type sensors where they are in your sensors.yaml file.

Or

  1. There are other options for splitting templates out into a templates.yaml file in the pinned topic.

Thanks for your reply. I read the pinned topic (forgot to mention, sorry!), but before using the script (or trying again manually) I have some questions:

Is it possible that these entries will get “repaired” by an upcoming update of the integration?

After some ill-fated attempts I managed to update the template entries without HA giving an error prior to reboot. It then did no longer show any pending repairs, but some entities now showed up as missing. Is this to be expected or the result of me doing something wrong?

I am not quite sure which integration is causing the “7 repairs” message. It says e3dc (my solar power system). I can’t remember, but this might consist of 2 integrations. I recall that the official one did not deliver all needed entities and that I did install this HACS version as well.

My configuration.yaml is pretty basic:


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
homeassistant:
  packages: !include_dir_merge_named packages/

The mentioned repairs refer to homeassistant/packages/e3dc/sensors.yaml of which I posted the contents above. Is it supposed to be in this location or is this a sign of it being a HACS integration?

Nope. This is a one time breaking change that you have to address.

It is not expected. All your entities should be present after the change.

Nope. It is the template integration that is causing the repairs.

Ok you have a more complicated repair as you are using packages. Please seek help in the pinned topic.

Make a new file in that directory next to sensor.yaml named templates.yaml and in that file do

e3dc_sensors:
  template:

put all your migrated templates in there. You’ll likely need to add 2 spaces in front of every line and only copy past the template: line (do not include it in the copy/paste).

I just did as suggested and it seems to be working. I created templates.yaml

and put all the repair suggestions in there with only 1 template: section and hopefully correct indentation:

e3dc_sensors:
  template:
    - sensor:
      - unique_id: e3dc_grid_export_power
        unit_of_measurement: W
        device_class: power
        default_entity_id: sensor.e3dc_grid_export_power
        name: E3DC Grid Export Power
        state: "{% set power = states('sensor.e3dc_grid_power') | int(0) %} {% if power
        > 0 %}\n  0\n{% else -%}\n  {{ power | abs }}\n{% endif %}"
    - sensor:
      - unique_id: e3dc_grid_import_power
        unit_of_measurement: W
        device_class: power
        default_entity_id: sensor.e3dc_grid_import_power
        name: E3DC Grid Import Power
        state: "{% set power = states('sensor.e3dc_grid_power') | int(0) %} {% if power
        > 0 %}\n  {{ power }}\n{% else -%}\n  0\n{% endif %}"
    - sensor:
      - unique_id: e3dc_battery_charge_power
        unit_of_measurement: W
        device_class: power
        default_entity_id: sensor.e3dc_battery_charge_power
        name: E3DC Battery Charging Power
        state: "{% set power = states('sensor.e3dc_battery_power') | float(0) %} {% if
          power >= 0 %}\n  {{ power }}\n{% else %}\n  {% set charge_power = states('sensor.e3dc_battery_charge_power')
          | float(0) + power %}\n  {{ charge_power if charge_power > 0 else 0 }}\n{% endif
          %}"
    - sensor:
      - unique_id: e3dc_battery_discharge_power
        unit_of_measurement: W
        device_class: power
        default_entity_id: sensor.e3dc_battery_discharge_power
        name: E3DC Battery Discharging Power
        state: "{% set power = states('sensor.e3dc_battery_power') | float(0) %} {% if
          power <= 0 %}\n  {{ power | abs }} \n{% else %}\n  {% set discharge_power =
          states('sensor.e3dc_battery_charge_power') | float(0) - power %}\n  {{ discharge_power
          if discharge_power > 0 else 0 }}\n{% endif %}"
    - sensor:
      - unique_id: e3dc_autarky
        unit_of_measurement: '%'
        default_entity_id: sensor.e3dc_autarky
        name: E3DC Autarky
        state: '{{ (states(''sensor.e3dc_autarky_and_consumption'')|int(0) / 256)|round(0,''floor'')
          }}'
    - sensor:
      - unique_id: e3dc_own_consumption_ratio
        unit_of_measurement: '%'
        default_entity_id: sensor.e3dc_own_consumption
        name: E3DC Own Consumption Ratio
        state: '{{ ((states(''sensor.e3dc_autarky_and_consumption'')|int(0) / 256 - states(''sensor.e3dc_autarky'')|int(0))
          * 256)|round(0,''floor'') }}'
    - sensor:
      - unique_id: e3dc_emergency_power_state_text
        default_entity_id: sensor.e3dc_emergency_power_state_text
        name: E3DC Emergency Power State Text
        state: "{% set eps = states('sensor.e3dc_emergency_power_state') %} {% if eps
          == '0' %}\n  nicht unterst├╝tzt\n{% elif eps == '1' %}\n  aktiv\n{% elif eps
          == '2' %}\n  inaktiv\n{% elif eps == '3' %}\n  nicht verf├╝gbar\n{% elif eps
          == '4' %}\n  falsche Position\n{% else %}\n  unbekannt\n{% endif %}"

After rebooting HA there are no longer any repairs mentioned. Is it correct to leave the existing file …/packages/e3dc/sensors.yaml unchanged since it still contains the old syntax before it continues with

# Integrations
- platform: integration

HA didn’t seem to care as soon as it had the new …/packages/e3dc/templates.yaml

EDIT: HA did no longer offer any repairs after reboot, but some of my e3dc entities stopped working:

Hi everyone.

In the meantime I tested what happens if I remove the old syntax from homeassistant/packages/e3dc/sensors.yaml. I did remove this and rebooted, but nothing changed. I suppose HA already did ignore this part as soon as I made available homeassistant/packages/e3dc/templates.yaml with the suggested new syntax in it.

So some entities are still missing now and I’m not sure why. They do return if I revert to the deprecated way. What should I look at or try next?

Happy New Year everyone,

and sorry for bumping this thread. I have reverted the changes for now, but I am eager to try again once I have a little more info on what to look for next. Maybe someone can explain why I may be experiencing this behaviour and what might help to fix it?

There is something you are doing wrong in your configuration that you aren’t telling us. That’s the only option here. The modern style template entities have been around for almost 6 years now and the behavior is identical to legacy template entities. In fact, they both generate the same objects under the hood. So the only way they are differing in behavior is something that you are doing in your configuration. At this point, no one can fix it for you unless you supply your entire configuration here.

Hi Petro and thank you for your reply. I will happily provide everything needed to get this solved. It was not my intention to steal your time. I will break it down as condensed as possible. Please tell me what else you need and I can provide the contents of config files, logs, etc.

Current situation: 7 repairs mentioning deprecated sensor templates, all starting with e3dc_ which is my solar power system.

My configuration.yaml:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
homeassistant:
  packages: !include_dir_merge_named packages/

/homeassistant/packages/ contains:

My /homeassistant/packages/e3dc/sensors.yaml:

e3dc_sensors:
  sensor:
    # Templates
    - platform: template
      sensors:
        e3dc_grid_export_power:
          unique_id: e3dc_grid_export_power
          friendly_name: "E3DC Grid Export Power"
          unit_of_measurement: "W"
          device_class: power
          value_template: >
            {% set power = states('sensor.e3dc_grid_power') | int(0) %}
            {% if power > 0 %}
              0
            {% else -%}
              {{ power | abs }}
            {% endif %}
        e3dc_grid_import_power:
          unique_id: e3dc_grid_import_power
          friendly_name: E3DC Grid Import Power
          unit_of_measurement: W
          device_class: power
          value_template: >
            {% set power = states('sensor.e3dc_grid_power') | int(0) %}
            {% if power > 0 %}
              {{ power }}
            {% else -%}
              0
            {% endif %}
        e3dc_battery_charge_power:
          unique_id: e3dc_battery_charge_power
          friendly_name: E3DC Battery Charging Power
          unit_of_measurement: W
          device_class: power
          value_template: >
            {% set power = states('sensor.e3dc_battery_power') | float(0) %}
            {% if power >= 0 %}
              {{ power }}
            {% else %}
              {% set charge_power = states('sensor.e3dc_battery_charge_power') | float(0) + power %}
              {{ charge_power if charge_power > 0 else 0 }}
            {% endif %}
        e3dc_battery_discharge_power:
          unique_id: e3dc_battery_discharge_power
          friendly_name: E3DC Battery Discharging Power
          unit_of_measurement: W
          device_class: power
          value_template: >
            {% set power = states('sensor.e3dc_battery_power') | float(0) %}
            {% if power <= 0 %}
              {{ power | abs }} 
            {% else %}
              {% set discharge_power = states('sensor.e3dc_battery_charge_power') | float(0) - power %}
              {{ discharge_power if discharge_power > 0 else 0 }}
            {% endif %}
        e3dc_autarky:
          friendly_name: "E3DC Autarky"
          unique_id: e3dc_autarky
          unit_of_measurement: "%"
          value_template: "{{ (states('sensor.e3dc_autarky_and_consumption')|int(0) / 256)|round(0,'floor') }}"
        e3dc_own_consumption:
          friendly_name: "E3DC Own Consumption Ratio"
          unique_id: e3dc_own_consumption_ratio
          unit_of_measurement: "%"
          value_template: "{{ ((states('sensor.e3dc_autarky_and_consumption')|int(0) / 256 - states('sensor.e3dc_autarky')|int(0)) * 256)|round(0,'floor') }}"
        e3dc_emergency_power_state_text:
          friendly_name: E3DC Emergency Power State Text
          unique_id: e3dc_emergency_power_state_text
          value_template: >
            {% set eps = states('sensor.e3dc_emergency_power_state') %}
            {% if eps == '0' %}
              nicht unterst├╝tzt
            {% elif eps == '1' %}
              aktiv
            {% elif eps == '2' %}
              inaktiv
            {% elif eps == '3' %}
              nicht verf├╝gbar
            {% elif eps == '4' %}
              falsche Position
            {% else %}
              unbekannt
            {% endif %}
    # Integrations
    - platform: integration
      source: sensor.e3dc_grid_import_power
      name: E3DC Grid Import Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_grid_export_power
      name: E3DC Grid Export Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_solar_power
      name: E3DC Solar Energy
      unit_prefix: k
      round: 2
      method: left
#    - platform: integration
#      source: sensor.e3dc_external_power
#      name: E3DC External Power
#      unit_prefix: k
#      round: 2
#      method: left
    - platform: integration
      source: sensor.e3dc_battery_power
      name: E3DC Builtin Battery Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_battery_charge_power
      name: E3DC Battery Charge Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_battery_discharge_power
      name: E3DC Battery Discharge Energy
      unit_prefix: k
      round: 2
      method: left

Removing everything above # Integrations and rebooting gets rid of the 7 repairs being mentioned, but results in some entities no longer working:

This (no repairs mentioned + the entities no longer showing up) does not change when I supply the new file /homeassistant/packages/e3dc/templates.yaml containing the suggested changes from the mentioned repairs:

e3dc_sensors:
  template:
    - sensor:
      - unique_id: e3dc_grid_export_power
        unit_of_measurement: W
        device_class: power
        default_entity_id: sensor.e3dc_grid_export_power
        name: E3DC Grid Export Power
        state: "{% set power = states('sensor.e3dc_grid_power') | int(0) %} {% if power
        > 0 %}\n  0\n{% else -%}\n  {{ power | abs }}\n{% endif %}"
    - sensor:
      - unique_id: e3dc_grid_import_power
        unit_of_measurement: W
        device_class: power
        default_entity_id: sensor.e3dc_grid_import_power
        name: E3DC Grid Import Power
        state: "{% set power = states('sensor.e3dc_grid_power') | int(0) %} {% if power
        > 0 %}\n  {{ power }}\n{% else -%}\n  0\n{% endif %}"
    - sensor:
      - unique_id: e3dc_battery_charge_power
        unit_of_measurement: W
        device_class: power
        default_entity_id: sensor.e3dc_battery_charge_power
        name: E3DC Battery Charging Power
        state: "{% set power = states('sensor.e3dc_battery_power') | float(0) %} {% if
          power >= 0 %}\n  {{ power }}\n{% else %}\n  {% set charge_power = states('sensor.e3dc_battery_charge_power')
          | float(0) + power %}\n  {{ charge_power if charge_power > 0 else 0 }}\n{% endif
          %}"
    - sensor:
      - unique_id: e3dc_battery_discharge_power
        unit_of_measurement: W
        device_class: power
        default_entity_id: sensor.e3dc_battery_discharge_power
        name: E3DC Battery Discharging Power
        state: "{% set power = states('sensor.e3dc_battery_power') | float(0) %} {% if
          power <= 0 %}\n  {{ power | abs }} \n{% else %}\n  {% set discharge_power =
          states('sensor.e3dc_battery_charge_power') | float(0) - power %}\n  {{ discharge_power
          if discharge_power > 0 else 0 }}\n{% endif %}"
    - sensor:
      - unique_id: e3dc_autarky
        unit_of_measurement: '%'
        default_entity_id: sensor.e3dc_autarky
        name: E3DC Autarky
        state: '{{ (states(''sensor.e3dc_autarky_and_consumption'')|int(0) / 256)|round(0,''floor'')
          }}'
    - sensor:
      - unique_id: e3dc_own_consumption_ratio
        unit_of_measurement: '%'
        default_entity_id: sensor.e3dc_own_consumption
        name: E3DC Own Consumption Ratio
        state: '{{ ((states(''sensor.e3dc_autarky_and_consumption'')|int(0) / 256 - states(''sensor.e3dc_autarky'')|int(0))
          * 256)|round(0,''floor'') }}'
    - sensor:
      - unique_id: e3dc_emergency_power_state_text
        default_entity_id: sensor.e3dc_emergency_power_state_text
        name: E3DC Emergency Power State Text
        state: "{% set eps = states('sensor.e3dc_emergency_power_state') %} {% if eps
          == '0' %}\n  nicht unterst├╝tzt\n{% elif eps == '1' %}\n  aktiv\n{% elif eps
          == '2' %}\n  inaktiv\n{% elif eps == '3' %}\n  nicht verf├╝gbar\n{% elif eps
          == '4' %}\n  falsche Position\n{% else %}\n  unbekannt\n{% endif %}"```

It looks to me like this file gets ignored.

Thank you for your time and please advise!

You don’t have unique_id’s, are you restarting or reloading? You need to restart.

Secondly, your first 2 sensors have the wrong indentation. Did you copy/paste directly from the repair? The repair would not have output the data like it’s shown in your file.

There would be 2 spaces in front of that at a minimum, like your others.

I am restarting between each try via Settings/System in the HA GUI:

Thanks for the heads-up on indentation. I redid the templates.yaml file completely from scratch directly copying from the repair messages while only removing the additional template: lines. It currently looks like this:

template:
- sensor:
  - unique_id: e3dc_grid_export_power
    unit_of_measurement: W
    device_class: power
    default_entity_id: sensor.e3dc_grid_export_power
    name: E3DC Grid Export Power
    state: "{% set power = states('sensor.e3dc_grid_power') | int(0) %} {% if power
      > 0 %}\n  0\n{% else -%}\n  {{ power | abs }}\n{% endif %}"
- sensor:
  - unique_id: e3dc_grid_import_power
    unit_of_measurement: W
    device_class: power
    default_entity_id: sensor.e3dc_grid_import_power
    name: E3DC Grid Import Power
    state: "{% set power = states('sensor.e3dc_grid_power') | int(0) %} {% if power
      > 0 %}\n  {{ power }}\n{% else -%}\n  0\n{% endif %}"
- sensor:
  - unique_id: e3dc_battery_charge_power
    unit_of_measurement: W
    device_class: power
    default_entity_id: sensor.e3dc_battery_charge_power
    name: E3DC Battery Charging Power
    state: "{% set power = states('sensor.e3dc_battery_power') | float(0) %} {% if
      power >= 0 %}\n  {{ power }}\n{% else %}\n  {% set charge_power = states('sensor.e3dc_battery_charge_power')
      | float(0) + power %}\n  {{ charge_power if charge_power > 0 else 0 }}\n{% endif
      %}"
- sensor:
  - unique_id: e3dc_battery_discharge_power
    unit_of_measurement: W
    device_class: power
    default_entity_id: sensor.e3dc_battery_discharge_power
    name: E3DC Battery Discharging Power
    state: "{% set power = states('sensor.e3dc_battery_power') | float(0) %} {% if
      power <= 0 %}\n  {{ power | abs }} \n{% else %}\n  {% set discharge_power =
      states('sensor.e3dc_battery_charge_power') | float(0) - power %}\n  {{ discharge_power
      if discharge_power > 0 else 0 }}\n{% endif %}"
- sensor:
  - unique_id: e3dc_autarky
    unit_of_measurement: '%'
    default_entity_id: sensor.e3dc_autarky
    name: E3DC Autarky
    state: '{{ (states(''sensor.e3dc_autarky_and_consumption'')|int(0) / 256)|round(0,''floor'')
      }}'
- sensor:
  - unique_id: e3dc_own_consumption_ratio
    unit_of_measurement: '%'
    default_entity_id: sensor.e3dc_own_consumption
    name: E3DC Own Consumption Ratio
    state: '{{ ((states(''sensor.e3dc_autarky_and_consumption'')|int(0) / 256 - states(''sensor.e3dc_autarky'')|int(0))
      * 256)|round(0,''floor'') }}'
- sensor:
  - unique_id: e3dc_emergency_power_state_text
    default_entity_id: sensor.e3dc_emergency_power_state_text
    name: E3DC Emergency Power State Text
    state: "{% set eps = states('sensor.e3dc_emergency_power_state') %} {% if eps
      == '0' %}\n  nicht unterst├╝tzt\n{% elif eps == '1' %}\n  aktiv\n{% elif eps
      == '2' %}\n  inaktiv\n{% elif eps == '3' %}\n  nicht verf├╝gbar\n{% elif eps
      == '4' %}\n  falsche Position\n{% else %}\n  unbekannt\n{% endif %}"

Still there are the same entity not found errors as shown above. What do you mean by me not having unique_ids? Every sensor entry seems to have its own name next to unique_id:

disregard unique_id comment, I didn’t notice them before. So you can reload or restart.

Now you are missing the name inside your file.

image

That’s needed because of the way you’re including packages.

Thank you, I missed that. For the sake of completeness the templates.yaml now looks like this:

e3dc_sensors:
  template:
  - sensor:
    - unique_id: e3dc_grid_export_power
      unit_of_measurement: W
      device_class: power
      default_entity_id: sensor.e3dc_grid_export_power
      name: E3DC Grid Export Power
      state: "{% set power = states('sensor.e3dc_grid_power') | int(0) %} {% if power
        > 0 %}\n  0\n{% else -%}\n  {{ power | abs }}\n{% endif %}"
  - sensor:
    - unique_id: e3dc_grid_import_power
      unit_of_measurement: W
      device_class: power
      default_entity_id: sensor.e3dc_grid_import_power
      name: E3DC Grid Import Power
      state: "{% set power = states('sensor.e3dc_grid_power') | int(0) %} {% if power
        > 0 %}\n  {{ power }}\n{% else -%}\n  0\n{% endif %}"
  - sensor:
    - unique_id: e3dc_battery_charge_power
      unit_of_measurement: W
      device_class: power
      default_entity_id: sensor.e3dc_battery_charge_power
      name: E3DC Battery Charging Power
      state: "{% set power = states('sensor.e3dc_battery_power') | float(0) %} {% if
        power >= 0 %}\n  {{ power }}\n{% else %}\n  {% set charge_power = states('sensor.e3dc_battery_charge_power')
        | float(0) + power %}\n  {{ charge_power if charge_power > 0 else 0 }}\n{% endif
        %}"
  - sensor:
    - unique_id: e3dc_battery_discharge_power
      unit_of_measurement: W
      device_class: power
      default_entity_id: sensor.e3dc_battery_discharge_power
      name: E3DC Battery Discharging Power
      state: "{% set power = states('sensor.e3dc_battery_power') | float(0) %} {% if
        power <= 0 %}\n  {{ power | abs }} \n{% else %}\n  {% set discharge_power =
        states('sensor.e3dc_battery_charge_power') | float(0) - power %}\n  {{ discharge_power
        if discharge_power > 0 else 0 }}\n{% endif %}"
  - sensor:
    - unique_id: e3dc_autarky
      unit_of_measurement: '%'
      default_entity_id: sensor.e3dc_autarky
      name: E3DC Autarky
      state: '{{ (states(''sensor.e3dc_autarky_and_consumption'')|int(0) / 256)|round(0,''floor'')
        }}'
  - sensor:
    - unique_id: e3dc_own_consumption_ratio
      unit_of_measurement: '%'
      default_entity_id: sensor.e3dc_own_consumption
      name: E3DC Own Consumption Ratio
      state: '{{ ((states(''sensor.e3dc_autarky_and_consumption'')|int(0) / 256 - states(''sensor.e3dc_autarky'')|int(0))
        * 256)|round(0,''floor'') }}'
  - sensor:
    - unique_id: e3dc_emergency_power_state_text
      default_entity_id: sensor.e3dc_emergency_power_state_text
      name: E3DC Emergency Power State Text
      state: "{% set eps = states('sensor.e3dc_emergency_power_state') %} {% if eps
        == '0' %}\n  nicht unterst├╝tzt\n{% elif eps == '1' %}\n  aktiv\n{% elif eps
        == '2' %}\n  inaktiv\n{% elif eps == '3' %}\n  nicht verf├╝gbar\n{% elif eps
        == '4' %}\n  falsche Position\n{% else %}\n  unbekannt\n{% endif %}"

But unfortunately entities are still missing. The upper 2 in this screenshot

are e3dc_grid_import_energy and e3dc_grid_export_energy

When I delete the new templates.yaml and revert sensors.yaml to its previous state, they will show up again after a reboot.

I’m not sure what to tell you.

There is something that you’re doing wrong here. Either looking at the wrong entities, or the include isn’t being included in the way you think it is, or there’s errors in the logs. So far you’re refuting all of those and that’s simply not possible. The only way for things to be “error free” is if they aren’t included correctly or they are working.

at this point, if what you’re saying is true, the only thing that can be the cause is your inclusion method. I’d revisit the documents and make sure you’re including things properly with include_dir_merge_named

I really appreciate your help. I never changed or edited anything in HA manually before, everything I use has been installed using the GUI only so no special/manual configuration took place.

The newly created templates.yaml seems to be included, because HA refuses a reboot when I edit something wrong in it and because the repair errors go away once it exists.

Just to clarify: I created the new templates.yaml and put all the repair suggestions in it as seen in my prior post. I also removed the old stuff from sensors.yaml, meaning I deleted everything above # Integrations so it currently looks like this:

    # Integrations
    - platform: integration
      source: sensor.e3dc_grid_import_power
      name: E3DC Grid Import Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_grid_export_power
      name: E3DC Grid Export Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_solar_power
      name: E3DC Solar Energy
      unit_prefix: k
      round: 2
      method: left
#    - platform: integration
#      source: sensor.e3dc_external_power
#      name: E3DC External Power
#      unit_prefix: k
#      round: 2
#      method: left
    - platform: integration
      source: sensor.e3dc_battery_power
      name: E3DC Builtin Battery Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_battery_charge_power
      name: E3DC Battery Charge Energy
      unit_prefix: k
      round: 2
      method: left
    - platform: integration
      source: sensor.e3dc_battery_discharge_power
      name: E3DC Battery Discharge Energy
      unit_prefix: k
      round: 2
      method: left

Do I need to move this content to the new templates.yaml file as well? Should I delete sensors.yaml then? Currently I have these:

I’m sorry, but I’m still not understanding this. If I do as suggested with the additional templates.yaml file containing the suggested “repairs” some of the e3dc entities will show up as missing. Once I revert all my changes to the “repairs needed” state they will show up and work again.

I think we’re close to a solution, but one step seems missing and I do not know HA well enough to find that out on my own.

Hi poenn,
I was stumbling over the same issue and I think, I got it solved. Hopefully this will help you and everyone having trouble solving this.
I think you have two issues:

  1. in your new file template.yaml you configure each sensor with an own “sensor:” object. In fact, all sensors should be within one sensor object.
  2. it seems that the original repair instructions from HA were not correct. For me it gave these instructions:
  • sensor:
    • unit_of_measurement: W
      default_entity_id: sensor.e3dc_external_power
      name: E3DC External Power
      state: ‘{ states(’‘sensor.e3dc_external_power’‘) | float | abs }}’
      if you take a close look, there is one “{” missing before “states”. Thus, the file would be corrupt.
      So I corrected all this and have this new sensors.yaml file created. Check out if it helps for you:

e3dc_sensors:
  template:
    - sensor:
        - name: "E3DC External Power"
          unit_of_measurement: "W"
          state: "{{ states('sensor.e3dc_external_power') | float(0) | abs }}"

        - name: "E3DC Grid Export Power"
          unique_id: e3dc_grid_export_power
          unit_of_measurement: "W"
          device_class: power
          state: >
            {% set power = states('sensor.e3dc_grid_power') | int(0) %}
            {% if power > 0 %}
              0
            {% else %}
              {{ power | abs }}
            {% endif %}

        - name: "E3DC Grid Import Power"
          unique_id: e3dc_grid_import_power
          unit_of_measurement: "W"
          device_class: power
          state: >
            {% set power = states('sensor.e3dc_grid_power') | int(0) %}
            {% if power > 0 %}
              {{ power }}
            {% else %}
              0
            {% endif %}

        - name: "E3DC Battery Charging Power"
          unique_id: e3dc_battery_charge_power
          unit_of_measurement: "W"
          device_class: power
          state: >
            {% set power = states('sensor.e3dc_battery_power') | float(0) %}
            {% if power >= 0 %}
              {{ power }}
            {% else %}
              {% set charge_power = states('sensor.e3dc_battery_charge_power') | float(0) + power %}
              {{ charge_power if charge_power > 0 else 0 }}
            {% endif %}

        - name: "E3DC Battery Discharging Power"
          unique_id: e3dc_battery_discharge_power
          unit_of_measurement: "W"
          device_class: power
          state: >
            {% set power = states('sensor.e3dc_battery_power') | float(0) %}
            {% if power <= 0 %}
              {{ power | abs }}
            {% else %}
              {% set discharge_power = states('sensor.e3dc_battery_charge_power') | float(0) - power %}
              {{ discharge_power if discharge_power > 0 else 0 }}
            {% endif %}

        - name: "E3DC Autarky"
          unique_id: e3dc_autarky
          unit_of_measurement: "%"
          state: "{{ (states('sensor.e3dc_autarky_and_consumption') | int(0) / 256) | round(0, 'floor') }}"

        - name: "E3DC Own Consumption Ratio"
          unique_id: e3dc_own_consumption_ratio
          unit_of_measurement: "%"
          state: >
            {{
              (
                (states('sensor.e3dc_autarky_and_consumption') | int(0) / 256
                 - states('sensor.e3dc_autarky') | int(0)
                ) * 256
              ) | round(0, 'floor')
            }}

        - name: "E3DC Emergency Power State Text"
          unique_id: e3dc_emergency_power_state_text
          state: >
            {% set eps = states('sensor.e3dc_emergency_power_state') %}
            {% if eps == '0' %}
              nicht unterstützt
            {% elif eps == '1' %}
              aktiv
            {% elif eps == '2' %}
              inaktiv
            {% elif eps == '3' %}
              nicht verfügbar
            {% elif eps == '4' %}
              falsche Position
            {% else %}
              unbekannt
            {% endif %}

        - name: "E3DC SG Ready State Text"
          unique_id: e3dc_sg_ready_state_text
          state: >
            {% set sgrs = states('sensor.e3dc_sg_ready_state') %}
            {% if sgrs == '1' %}
              sperrbetrieb
            {% elif sgrs == '2' %}
              normalbetrieb
            {% elif sgrs == '3' %}
              pv-überschussbetrieb
            {% elif sgrs == '4' %}
              betrieb für abriegelung
            {% else %}
              unbekannt
            {% endif %}

Best regards
Dennis

Thank you, Dennis!

I just tried it and replaced the contents of my /homeassistant/packages/e3dc/sensors.yaml with the code you provided. One restart later it sadly is the same outcome as with my own attempts:

The repair errors are gone, but 3 entities are missing.

The missing entities are:

sensor.e3dc_battery_discharge_energy
sensor.e3dc_grid_import_energy
sensor.e3dc_grid_export_energy

If I revert the changes, they will return as will the repair errors. Do you have any idea what might be causing this?

Hi,
yes, I think your dashboard is referencing the wrong entities. Maybe in the previous version they were named like you say. But with the new ones (check the file I provided), they are called differently.
e.g.

e3dc_battery_discharge_energy

is named

e3dc_battery_discharge_power

now.
So just replace the word “energy” with “power” in your dashboard entity referencing and then it should find them.

Best regards
Dennis