Energy export daily sensor not available 2

Hello,

This post ist the continuation of this thread Energy export daily sensor not available.

As beginner in the HA community I am not allowed to add further replies to the original thread.

The topic/problem is
Energy Export Daily sensor cannot be selected in Energie Dashboard.
Energy Export Daily sensor does not have a measurement unit.

The latest configuration is

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

The latest post from Moderator @tom_l

Blockquote
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.

  1. Yes, I have exported energy to the net and the sensor shows data.

  2. I have checked DevTools > Statistics: 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 configuration & sensors the attributes have not changed.

Since the process of removing the configuration & sensors, restarting HA, adding the configuration and restarting HA does not add the missing measurement unit and therefore does not solve the problem, is there a way to add the missing attributes “unit_of_measurement: kWH” and “device class: energy” manually?

Thx for your support

Yes, you can use customize.

I have the same problem with the Energy Export Daily Sensor! It does not show up whatever I do.
And right now i am producing more energy than i am consuming!

My configuration is as shown below:

in configuration.yaml:

template: !include templates.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

And at the bottom of the configuration.yaml i have:

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

In templates.yaml I have:

#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.shellyem3_mycustomnumber_channel_a_power')|float(0) + states('sensor.shellyem3_mycustomnumber_channel_b_power')|float(0) + states('sensor.shellyem3_mycustomnumber_channel_c_power')|float(0) > 0 %}
        {{ states('sensor.shellyem3_mycustomnumber_channel_a_power')|float(0) + states('sensor.shellyem3_mycustomnumber_channel_b_power')|float(0) + states('sensor.shellyem3_mycustomnumber_channel_c_power')|float(0) }}
      {% else %}
        0
      {% endif %}
    availability: >
      {{
        [ states('sensor.shellyem3_mycustomnumber_channel_a_power'),
          states('sensor.shellyem3_mycustomnumber_channel_b_power'),
          states('sensor.shellyem3_mycustomnumber_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.shellyem3_mycustomnumber_channel_a_power')|float(0) + states('sensor.shellyem3_mycustomnumber_channel_b_power')|float(0) + states('sensor.shellyem3_mycustomnumber_channel_c_power')|float(0) < 0 %}
        {{ (states('sensor.shellyem3_mycustomnumber_channel_a_power')|float(0) + states('sensor.shellyem3_mycustomnumber_channel_b_power')|float(0) + states('sensor.shellyem3_mycustomnumber_channel_c_power')|float(0))|abs }}
      {% else %}
        0
      {% endif %}
    availability: >
      {{
        [ states('sensor.shellyem3_mycustomnumber_channel_a_power'),
          states('sensor.shellyem3_mycustomnumber_channel_b_power'),
          states('sensor.shellyem3_mycustomnumber_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.solaranlage_switch_0_energy')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
      {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.solaranlage_switch_0_energy')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
        {{ (states('sensor.solaranlage_switch_0_energy')|float(0)) - states('sensor.power_export')|float(0) }}    
      {% else %}
        {{ states('sensor.power_import')|float(0) + states('sensor.solaranlage_switch_0_energy')|float(0) }}
      {% endif %}

No errors but also no available Energy Export Sensor! Energy Import and Energy Consumption Sensors are displayed! I cant find any errors here…just changed my Shelly3EM id to “mycustomnumber” in this text. “sensor.solaranlage_switch_0_energy” is my Shelly Plus Plug S energy sensor.
Where is the mistake?

Thank you

Adding the missing attributes for the sensor.energy_export_daily by manually customizing the sensor solves all problems. I have added the following lines at the end of the /config/configuration.yaml file:

homeassistant:
  customize:
    sensor.energy_export_daily:
      unit_of_measurement: kWh
      device_class: energy

Results after adding the customization

  1. The missing measurement unit “kWh” appears under DevTools > Statistics
  2. The missing attributes “unit of measurement” and “device_class” appear under DevTools > States (see screengrab)
  3. Finally the sensor “Energy Export Daily” can be selected for the Energy dashboard

@tom_l
Again thank you very much. This was really helpful.

@Dosperado

It seems you have the very same problem.

Could you please check the following

  1. If you go to DevTools > Statistics and look at the sensor sensor.energy_export_daily, does it have the statistics unit “kWh”?
  2. If you go to DevTools > States and look at the sensors attributes, does it have the following two attributes
unit_of_measurement: kWh
device_class: energy
  1. If you open your sensor, does it collect data as shown in the next screengrab?

If the answers to the 3 questions above are “no”, “no”, “yes”, then simply read
my previous post. It could solve your problems.

Btw. you asked “where is the mistake”.
I would guess, the creation of the sensor.energy_export_daily in HA is not working as expected.
It should add these attributes automatically, but for some reason it does not.
On my journey to have this problem solved I have found many posts of other users having the same problem.

Hello from Vienna,

this was a great hint. I did it and the daily sensor appeared in the overview with kwh. But I cannot select it at the dashboard. Still have monthly sensor selected.
It’s strange as the graph shows monthly sensor with value of daily sensor and monthly sensor with monthly values.
I’m really confused…

hmm,

sensor disappeared again…


its really strange

After restart of HA and one hour later

In any case I can confirm all three questions from @Arminius with yes, yes, yes…and daily sensor can be chosen at dashboard. Great!
But energy_export_sum still not available.
Its strange as now the bars show Energy Export Daily even in monthly view