I am trying to customize the energy dashboard to show my consumed power, generated solar power and the power that was fed back into the grid.
I found the following templates which should do exactly the things above:
https://community.home-assistant.io/t/shelly-3em-3-phase-net-metering-templates-for-import-export-and-consumption/390237
I copied the templates into my config and modified the sensor sources:
- platform: template
sensors:
# Gaszähler, kommend von ESPHome, aufbereiten für Energy
gasincubicmeter:
unique_id: gas_qubic_meter
value_template: "{{ states('sensor.gasverbrauch') | float }}"
unit_of_measurement: m³
device_class: gas
attribute_templates:
state_class: total_increasing
# 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.hausverbrauch_channel_a_power')|float + states('sensor.hausverbrauch_channel_b_power')|float + states('sensor.hausverbrauch_channel_c_power')|float) > 0 %}
{{ states('sensor.hausverbrauch_channel_a_power')|float + states('sensor.hausverbrauch_channel_b_power')|float + states('sensor.hausverbrauch_channel_c_power')|float }}
{% else %}
{{ 0 }}
{% endif %}
availability_template: "{{
[ states('sensor.hausverbrauch_channel_a_power'),
states('sensor.hausverbrauch_channel_b_power'),
states('sensor.hausverbrauch_channel_c_power')
] | map('is_number') | min
}}"
power_export:
friendly_name: "Power Export"
unit_of_measurement: "W"
value_template: >-
{% if (states('sensor.hausverbrauch_channel_a_power')|float + states('sensor.hausverbrauch_channel_b_power')|float + states('sensor.hausverbrauch_channel_c_power')|float) < 0 %}
{{ (states('sensor.hausverbrauch_channel_a_power')|float + states('sensor.hausverbrauch_channel_b_power')|float + states('sensor.hausverbrauch_channel_c_power')|float) * -1 }}
{% else %}
{{ 0 }}
{% endif %}
availability_template: "{{
[ states('sensor.hausverbrauch_channel_a_power'),
states('sensor.hausverbrauch_channel_b_power'),
states('sensor.hausverbrauch_channel_c_power')
] | map('is_number') | min
}}"
# Sensor for Riemann sum of energy import (W -> Wh)
- platform: integration
source: sensor.power_import
name: energy_import_sum
unit_prefix: k
round: 1
method: left
# Sensor for Riemann sum of energy export (W -> Wh)
- platform: integration
source: sensor.power_export
name: energy_export_sum_new
unit_prefix: k
round: 1
method: left
also the utility meters
utility_meter:
gasverbrauch_daily:
source: sensor.gasverbrauch
cycle: daily
energy_export_daily:
source: sensor.energy_export_sum_new
name: Energy Export Daily
cycle: daily
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_monthly:
source: sensor.energy_export_sum_new
name: Energy Export Monthly
cycle: monthly
restarted homeassistant, and all the sensors show up in entities.
But now the weird part, the Power Import sensor is working and showing current readings, also the energy_import_sum sensor is filled correctly and i can see the history of it, and also the utility meter “energy_import_daily” is working and showing the calculated values.
BUT the “Power Export” is behaving differently. While the “Power Export” Sensor is showing the values as expected
but the other two “energy_export_sum_new” and “energy_export_daily” do not show any data and seem to not be updated (last updated 9 hours ago while Power Export was fired recently)
I don’t understand what is going wrong here, why is import working and export not?
Any help is welcome
1 post - 1 participant