Energy export daily sensor not available

Hello from Vienna,

I’m using Shelly 3em for analyzing the whole energy flow and Shelly em for analyzing the solar panel supply. So far so good. After installation and configuration of a script everything is running fine, except the sensor “Energy export daily” cannot be chosen at adjustments/dashboards because it simply not available. At the overview screen its available but without any unit like Wh or kWh.
Even restart, or simply waiting (recommendation from script writer) did not help . Any idea? Bug from HA?
thx for help
Rudi

Here the 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

# Text to speech
tts:
 - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor:
  - platform: template
    sensors: 

      # Template sensor for values of power import (active_power > 0)
      power_import:
        friendly_name: "Power Import"
        unit_of_measurement: 'W'
        value_template: >-
          {% if (states('sensor.shelly_em3_channel_a_power')|float + states('sensor.shelly_em3_channel_b_power')|float + states('sensor.shelly_em3_channel_c_power')|float) > 0 %}
            {{ states('sensor.shelly_em3_channel_a_power')|float + states('sensor.shelly_em3_channel_b_power')|float + states('sensor.shelly_em3_channel_c_power')|float }}
          {% else %}
            {{ 0 }}
          {% endif %}
        availability_template: "{{
            [ states('sensor.shelly_em3_channel_a_power'),
              states('sensor.shelly_em3_channel_b_power'),
              states('sensor.shelly_em3_channel_c_power')
            ] | map('is_number') | min
          }}"

      # Template sensor for values of power export (active_power < 0)
      power_export:
        friendly_name: "Power Export"
        unit_of_measurement: 'W'
        value_template: >-
          {% if (states('sensor.shelly_em3_channel_a_power')|float + states('sensor.shelly_em3_channel_b_power')|float + states('sensor.shelly_em3_channel_c_power')|float) < 0 %}
            {{ (states('sensor.shelly_em3_channel_a_power')|float + states('sensor.shelly_em3_channel_b_power')|float + states('sensor.shelly_em3_channel_c_power')|float) * -1 }}
          {% else %}
            {{ 0 }}
          {% endif %}
        availability_template: "{{
            [ states('sensor.shelly_em3_channel_a_power'),
              states('sensor.shelly_em3_channel_b_power'),
              states('sensor.shelly_em3_channel_c_power')
            ] | map('is_number') | min
          }}"

      # Template sensor for values of power consumption
      power_consumption:
        friendly_name: "Power Consumption"
        unit_of_measurement: 'W'
        value_template: >-
          {% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
          {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
            {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }}    
          {% else %}
            {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
          {% endif %}


  # Sensor for Riemann sum of energy import (W -> Wh)
  - platform: integration
    source: sensor.power_import
    name: energy_import_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy export (W -> Wh)
  - platform: integration
    source: sensor.power_export
    name: energy_export_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy consumption (W -> Wh)
  - platform: integration
    source: sensor.power_consumption
    name: energy_consumption_sum
    unit_prefix: k
    round: 2
    method: left

utility_meter:
  energy_import_daily:
    source: sensor.energy_import_sum
    name: Energy Import Daily
    cycle: daily
  energy_import_monthly:
    source: sensor.energy_import_sum
    name: Energy Import Monthly
    cycle: monthly
  energy_export_daily:
    source: sensor.energy_export_sum
    name: Energy Export Daily
    cycle: daily
  energy_export_monthly:
    source: sensor.energy_export_sum
    name: Energy Export Monthly
    cycle: monthly
  energy_consumption_daily:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Daily
    cycle: daily
  energy_consumption_monthly:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Monthly
    cycle: monthly

hmmm, no idea. Seems to me that I’m the only one with this issue

You need to define the correct device and state classes for your template sensors. The state_class can only be defined in the new template integration (unless you want to use a customize hack). You are using the legacy template sensor platform.

e.g. delete the template sensors above (leave the Riemann Sum sensors) and replace them with this in your configuration.yaml file

There is also an issue with your “Power Consumption” template sensor. See the comments in it below.

template:
  sensor: 
    
    # Template sensor for values of power import (active_power > 0)
    - name: "Power Import"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) > 0 %}
          {{ states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{
          [ states('sensor.shelly_em3_channel_a_power'),
            states('sensor.shelly_em3_channel_b_power'),
            states('sensor.shelly_em3_channel_c_power')
          ] | map('is_number') | min
        }}
    
    # Template sensor for values of power export (active_power < 0)
    - name: "Power Export"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) < 0 %}
          {{ (states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0))|abs }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{
          [ states('sensor.shelly_em3_channel_a_power'),
            states('sensor.shelly_em3_channel_b_power'),
            states('sensor.shelly_em3_channel_c_power')
          ] | map('is_number') | min
        }}
    
    # Template sensor for values of power consumption
    - name: "Power Consumption"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.power_export')|float(0) > 0 and states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0) < 0 %}
          {# You are missing a print statement here. #}
          {# if you want to keep the previous state use this: #}
          {{ this.state }}
        {% elif states('sensor.power_export')|float(0) > 0 and states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0) > 0 %}
          {{ states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0) }}    
        {% else %}
          {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
        {% endif %}
      availability: >
        {{
          [ states('sensor.power_export'),
            states('sensor.power_solargen'),
            states('sensor.power_import')
          ] | map('is_number') | min
        }}

Thank you so much for your response. Will test it tomorrow. As I’m a absolute beginner and no software programming expert, I will do my best.

here the result. got many errors. To be honest, have no glue how to fix that as I’m an absolute beginner on that…

Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']. 
Got [{'name': 'Power Import', 'unit_of_measurement': 'W', 'state_class': 'measurement', 'device_class': 'power', 'state': "{% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) > 0 %}\n  {{ states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) }}\n{% else %}\n  0\n{% endif %}\.... (See ?, line ?). 
# Loads default set of integrations. Do not remove.
default_config:

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

# Text to speech
tts:
 - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor:
  - platform: template
    sensors: 

    
    # Template sensor for values of power import (active_power > 0)
    - name: "Power Import"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) > 0 %}
          {{ states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{
          [ states('sensor.shelly_em3_channel_a_power'),
            states('sensor.shelly_em3_channel_b_power'),
            states('sensor.shelly_em3_channel_c_power')
          ] | map('is_number') | min
        }}
    
    # Template sensor for values of power export (active_power < 0)
    - name: "Power Export"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) < 0 %}
          {{ (states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0))|abs }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{
          [ states('sensor.shelly_em3_channel_a_power'),
            states('sensor.shelly_em3_channel_b_power'),
            states('sensor.shelly_em3_channel_c_power')
          ] | map('is_number') | min
        }}


      # Template sensor for values of power consumption
      power_consumption:
        friendly_name: "Power Consumption"
        unit_of_measurement: 'W'
        value_template: >-
          {% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
          {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
            {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }}    
          {% else %}
            {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
          {% endif %}


  # Sensor for Riemann sum of energy import (W -> Wh)
  - platform: integration
    source: sensor.power_import
    name: energy_import_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy export (W -> Wh)
  - platform: integration
    source: sensor.power_export
    name: energy_export_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy consumption (W -> Wh)
  - platform: integration
    source: sensor.power_consumption
    name: energy_consumption_sum
    unit_prefix: k
    round: 2
    method: left

utility_meter:
  energy_import_daily:
    source: sensor.energy_import_sum
    name: Energy Import Daily
    cycle: daily
  energy_import_monthly:
    source: sensor.energy_import_sum
    name: Energy Import Monthly
    cycle: monthly
  energy_export_daily:
    source: sensor.energy_export_sum
    name: Energy Export Daily
    cycle: daily
  energy_export_monthly:
    source: sensor.energy_export_sum
    name: Energy Export Monthly
    cycle: monthly
  energy_consumption_daily:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Daily
    cycle: daily
  energy_consumption_monthly:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Monthly
    cycle: monthly
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor:

  # Sensor for Riemann sum of energy import (W -> Wh)
  - platform: integration
    source: sensor.power_import
    name: energy_import_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy export (W -> Wh)
  - platform: integration
    source: sensor.power_export
    name: energy_export_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy consumption (W -> Wh)
  - platform: integration
    source: sensor.power_consumption
    name: energy_consumption_sum
    unit_prefix: k
    round: 2
    method: left

template:
  - sensors: 
  
      # Template sensor for values of power import (active_power > 0)
      - name: "Power Import"
        unit_of_measurement: 'W'
        state_class: measurement
        device_class: power
        state: >
          {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) > 0 %}
            {{ states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) }}
          {% else %}
            0
          {% endif %}
        availability: >
          {{
            [ states('sensor.shelly_em3_channel_a_power'),
              states('sensor.shelly_em3_channel_b_power'),
              states('sensor.shelly_em3_channel_c_power')
            ] | map('is_number') | min
          }}
      
      # Template sensor for values of power export (active_power < 0)
      - name: "Power Export"
        unit_of_measurement: 'W'
        state_class: measurement
        device_class: power
        state: >
          {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) < 0 %}
            {{ (states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0))|abs }}
          {% else %}
            0
          {% endif %}
        availability: >
          {{
            [ states('sensor.shelly_em3_channel_a_power'),
              states('sensor.shelly_em3_channel_b_power'),
              states('sensor.shelly_em3_channel_c_power')
            ] | map('is_number') | min
          }}
  
  
      # Template sensor for values of power consumption
      - name: "Power Consumption"
        unit_of_measurement: 'W'
        value_template: >-
          {% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
          {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
            {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }}    
          {% else %}
            {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
          {% endif %}

utility_meter:
  energy_import_daily:
    source: sensor.energy_import_sum
    name: Energy Import Daily
    cycle: daily
  energy_import_monthly:
    source: sensor.energy_import_sum
    name: Energy Import Monthly
    cycle: monthly
  energy_export_daily:
    source: sensor.energy_export_sum
    name: Energy Export Daily
    cycle: daily
  energy_export_monthly:
    source: sensor.energy_export_sum
    name: Energy Export Monthly
    cycle: monthly
  energy_consumption_daily:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Daily
    cycle: daily
  energy_consumption_monthly:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Monthly
    cycle: monthly

My HA shows exactly the same result and “Invalid config” message when I use the template above:

Blockquote
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data[‘sensors’].
Got [{‘name’: ‘Power Import’, ‘unit_of_measurement’: ‘W’, ‘state_class’: ‘measurement’, ‘device_class’: ‘power’, ‘state’: "{% if states(‘sensor.shelly_em3_channel_a_power’)|float(0) + states(‘sensor.shelly_em3_channel_b_power’)|float(0) + states(‘sensor.shelly_em3_channel_c_power’)|float(0) > 0 %}\n {{ states(‘sensor.shelly_em3_channel_a_power’)|float(0) + states(‘sensor.shelly_em3_channel_b_power’)|float(0) + states(‘sensor.shelly_em3_channel_c_power’)|float(0) }}\n{% else %}\n 0\n{% endif %}.… (See ?, line ?).

So I switched back to the configuration I found somewhere else, which is working fine except the “energy daily sensor” which for unknown reasons under developer tools > statistics does not show the measurement “kWh”. See attached screengrab. Neverless it records the daily export as expected.
Since the measurement “kWh” is available for the “energy monthly sensor” which was created with exactly the same configuration, I also think, that in HA something is not working as expected.
Finally it seems that the missing measurement “kWh” for the daily export sensor is the reason, that it cannot be selected in the energy dashboard.

Since as new user I can only upload a single screengrab here is the second one showing the sensor.

Opps. That should be:

template:
  - sensor: 

Hi Tom,

Thx for your reply. Unfortunately it still throws an error.

Blockquote
Invalid config for [template]: [value_template] is an invalid option for [template]. Check: template->sensor->2->value_template. (See /config/configuration.yaml, line 45).

Here is the source

@Valsi
Sorry for adding to your topic, but I am almost 100% sure, that we have the same problem.

Somehow you copied the old template. This:

Should be:

Look at my post again: Energy export daily sensor not available - #7 by tom_l

It seems, I tried to somehow fix the problem and made a screenshot from that fix.

Here it the configuration I used for my latest try:

sensor:

  # Sensor for Riemann sum of energy import (W -> Wh)
  - platform: integration
    source: sensor.power_import
    name: energy_import_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy export (W -> Wh)
  - platform: integration
    source: sensor.power_export
    name: energy_export_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy consumption (W -> Wh)
  - platform: integration
    source: sensor.power_consumption
    name: energy_consumption_sum
    unit_prefix: k
    round: 2
    method: left

template:
  - sensors: 
  
    # Template sensor for values of power import (active_power > 0)
    - name: "Power Import"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) > 0 %}
          {{ states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{
          [ states('sensor.shelly_em3_channel_a_power'),
            states('sensor.shelly_em3_channel_b_power'),
            states('sensor.shelly_em3_channel_c_power')
          ] | map('is_number') | min
        }}
      
    # Template sensor for values of power export (active_power < 0)
    - name: "Power Export"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) < 0 %}
          {{ (states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0))|abs }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{
          [ states('sensor.shelly_em3_channel_a_power'),
            states('sensor.shelly_em3_channel_b_power'),
            states('sensor.shelly_em3_channel_c_power')
          ] | map('is_number') | min
        }}
  
  
    # Template sensor for values of power consumption
    - name: "Power Consumption"
      unit_of_measurement: 'W'
      value_template: >-
        {% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
        {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
          {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }}    
        {% else %}
          {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
        {% endif %}

utility_meter:
  energy_import_daily:
    source: sensor.energy_import_sum
    name: Energy Import Daily
    cycle: daily
  energy_import_monthly:
    source: sensor.energy_import_sum
    name: Energy Import Monthly
    cycle: monthly
  energy_export_daily:
    source: sensor.energy_export_sum
    name: Energy Export Daily
    cycle: daily
  energy_export_monthly:
    source: sensor.energy_export_sum
    name: Energy Export Monthly
    cycle: monthly
  energy_consumption_daily:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Daily
    cycle: daily
  energy_consumption_monthly:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Monthly
    cycle: monthly

And this is the message I get

You still have not fixed this:

Alright, sorry, after 1000 tries I did not see that.

I have cleaned up everything, reentered the (now hopefully correct) configuration, but still it does not work.

Latest Configuration:

sensor:

  # Sensor for Riemann sum of energy import (W -> Wh)
  - platform: integration
    source: sensor.power_import
    name: energy_import_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy export (W -> Wh)
  - platform: integration
    source: sensor.power_export
    name: energy_export_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy consumption (W -> Wh)
  - platform: integration
    source: sensor.power_consumption
    name: energy_consumption_sum
    unit_prefix: k
    round: 2
    method: left

template:
  - sensor: 
  
    # Template sensor for values of power import (active_power > 0)
    - name: "Power Import"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) > 0 %}
          {{ states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{
          [ states('sensor.shelly_em3_channel_a_power'),
            states('sensor.shelly_em3_channel_b_power'),
            states('sensor.shelly_em3_channel_c_power')
          ] | map('is_number') | min
        }}
      
    # Template sensor for values of power export (active_power < 0)
    - name: "Power Export"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) < 0 %}
          {{ (states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0))|abs }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{
          [ states('sensor.shelly_em3_channel_a_power'),
            states('sensor.shelly_em3_channel_b_power'),
            states('sensor.shelly_em3_channel_c_power')
          ] | map('is_number') | min
        }}
  
  
    # Template sensor for values of power consumption
    - name: "Power Consumption"
      unit_of_measurement: 'W'
      value_template: >-
        {% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
        {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
          {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }}    
        {% else %}
          {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
        {% endif %}

utility_meter:
  energy_import_daily:
    source: sensor.energy_import_sum
    name: Energy Import Daily
    cycle: daily
  energy_import_monthly:
    source: sensor.energy_import_sum
    name: Energy Import Monthly
    cycle: monthly
  energy_export_daily:
    source: sensor.energy_export_sum
    name: Energy Export Daily
    cycle: daily
  energy_export_monthly:
    source: sensor.energy_export_sum
    name: Energy Export Monthly
    cycle: monthly
  energy_consumption_daily:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Daily
    cycle: daily
  energy_consumption_monthly:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Monthly
    cycle: monthly

Error in log instantly after checking DevTools > Check Configuration

Logger: homeassistant.config
Source: config.py:982
First occurred: 6:03:48 PM (1 occurrences)
Last logged: 6:03:48 PM
Invalid config for [template]: [value_template] is an invalid option for [template]. Check: template->sensor->2->value_template. (See /config/configuration.yaml, line 41).

And again. You did not fix what I told you to.

Also please have a read of this https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16 and format you posts correctly for the forum.

Unfortunately due to limitations I am not allowed to add further replies - will reuse this post for further information

First of all: Thx for your patience, now I got it …
The problem was already in that post #7. I have fixed it and configuration loads as expected.

Finally this is the configuration I used, the result is below

sensor:

  # Sensor for Riemann sum of energy import (W -> Wh)
  - platform: integration
    source: sensor.power_import
    name: energy_import_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy export (W -> Wh)
  - platform: integration
    source: sensor.power_export
    name: energy_export_sum
    unit_prefix: k
    round: 2
    method: left

  # Sensor for Riemann sum of energy consumption (W -> Wh)
  - platform: integration
    source: sensor.power_consumption
    name: energy_consumption_sum
    unit_prefix: k
    round: 2
    method: left

template:
  - sensor: 
  
    # Template sensor for values of power import (active_power > 0)
    - name: "Power Import"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) > 0 %}
          {{ states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{
          [ states('sensor.shelly_em3_channel_a_power'),
            states('sensor.shelly_em3_channel_b_power'),
            states('sensor.shelly_em3_channel_c_power')
          ] | map('is_number') | min
        }}
      
    # Template sensor for values of power export (active_power < 0)
    - name: "Power Export"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0) < 0 %}
          {{ (states('sensor.shelly_em3_channel_a_power')|float(0) + states('sensor.shelly_em3_channel_b_power')|float(0) + states('sensor.shelly_em3_channel_c_power')|float(0))|abs }}
        {% else %}
          0
        {% endif %}
      availability: >
        {{
          [ states('sensor.shelly_em3_channel_a_power'),
            states('sensor.shelly_em3_channel_b_power'),
            states('sensor.shelly_em3_channel_c_power')
          ] | map('is_number') | min
        }}
  
  
    # Template sensor for values of power consumption
    - name: "Power Consumption"
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: power
      state: >
        {% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
        {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
          {{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }}    
        {% else %}
          {{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
        {% endif %}

utility_meter:
  energy_import_daily:
    source: sensor.energy_import_sum
    name: Energy Import Daily
    cycle: daily
  energy_import_monthly:
    source: sensor.energy_import_sum
    name: Energy Import Monthly
    cycle: monthly
  energy_export_daily:
    source: sensor.energy_export_sum
    name: Energy Export Daily
    cycle: daily
  energy_export_monthly:
    source: sensor.energy_export_sum
    name: Energy Export Monthly
    cycle: monthly
  energy_consumption_daily:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Daily
    cycle: daily
  energy_consumption_monthly:
    source: sensor.energy_consumption_sum
    name: Energy Consumption Monthly
    cycle: monthly

Unfortunately the sensor “Energy export daily” still has no unit “kWh”, while the sensor “Energy export monthly”, which was recreated at the very same time, has the unit “kWh”. The sensor “Energy export daily” is working and collecting data, but still it cannot be selected for the Energy dashboard.

Update, 2023-05-26

Since I cannot add further replies (I am rated as beginner), I’ll add the reply to your latest post here:

  1. Yes, I have exported energy to the net.
  2. DevTools > Statistics checked: There is no Fix Issue Button. It shows “no issue”
  3. DevTools > Stats checked: Energy Export Daily does not show attributes “unit_of_measurement” and “device_class”. Even after removing and recreating the attributes have not changed as shown in the next screengrab.

Is there a way to add the missing attributes manually?

UPDATE
Because the beginners limitations for replies I have continued the discussion in this thread Energy export daily sensor not available 2

Have you exported any energy since making the change?

It won’t update until you do.

Also check Developer Tools → Statistics and press any Fix Issue buttons that are there.