Add 2 entities to display the result in a panel

Hello,

I have solar panels mounted, 40 panels which produce electricity in 2 inverters. The case is that I have a panel for each inverter and I would like to add them to have the values in a single panel, how could I do it?

Use a template helper or template sensor to sum the two individual sensors (power or energy). Display that in your dashboard.

Thanks for the indications, I was able to do what I needed to do.

In the file “configuration.yaml” I have added:

template: !include templates.yaml

And I have created a “templates.yaml” file.

########## Sum of the 2 inverters as a single one
- sensor:
  - name: "energia_sum_inverters_kWh"
    unique_id: "sensor.energia_sum_inverters_kWh"
    unit_of_measurement: "kWh"
    device_class: power
    state: "{{ states('sensor.inverter_inverter_inverter_15kva_energy') | float + states('sensor.inverter_inverter_inverter_5kva_energy') | float }}"
########## Sum of the 2 inverters as one.
- sensor:
  - name: "inverter_sum_energy_inverter_W"
    unique_id: "sensor.energy_sum_inverters_W"
    unit_of_measurement: "W"
    device_class: power
    state: "{{ states('sensor.inverter_inverter_15kva') | float + states('sensor.inverter_inverter_5kva') | float }}"

My solar installation is shared among several neighbors, so that I have 29.57% of the production, and I have been able to create a sensor with my exact solar production.

########## My solar production
- sensor:
  - name: "energy_my_production_investors_kWh"
    unique_id: "sensor.energia_my_production_investors_kWh"
    unit_of_measurement: "kWh"
    device_class: power
    state: "{{ (states('sensor.inverter_inverter_inverter_15kva_energy') | float + states('sensor.inverter_inverter_inverter_5kva_energy') | float ) * 0.2957 }}"
########## My solar production
- sensor:
  - name: "energia_my_inverter_production_W"
    unique_id: "sensor.energia_my_production_investors_W"
    unit_of_measurement: "W"
    device_class: power
    state: "{{ (states('sensor.inverter_inverter_inverter_15kva') | float + states('sensor.inverter_inverter_inverter_5kva') | float ) * 0.2957}}"

I have even been able to round to 1 decimal place as the original inverter sensors come with.

########## My solar production
- sensor:
  - name: "energy_my_production_inverters_kWh"
    unique_id: "sensor.energy_my_production_investors_kWh"
    unit_of_measurement: "kWh"
    device_class: power
    state: "{{ ((states('sensor.inverter_inverter_inverter_15kva_energy') | float + states('sensor.inverter_inverter_inverter_5kva_energy') | float ) * 0.2957) | round (1) }}"
########## My solar production
- sensor:
  - name: "energia_my_inverter_production_inverter_W"
    unique_id: "sensor.energy_my_production_investors_W"
    unit_of_measurement: "W"
    device_class: power
    state: "{{ ( ((states('sensor.inverter_inverter_inverter_15kva') | float + states('sensor.inverter_inverter_inverter_5kva') | float ) * 0.2957 | round (1) }}"

Please format your config for the forum correctly, https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371

You will need an availability template if you ever want to use the sum sensor in calculations or the energy dashboard.

You got the energy sensor device class wrong.

You can use capital letters and spaces in the names. They will look better on your dashboards. These will have exactly the same entity ids:

    sensor:
        name: "Energia Sum Inverters kWh"
        unique_id: "sensor.energia_sum_inverters_kWh"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: "{{ states('sensor.inverter_inverter_inverter_15kva_energy') | float + states('sensor.inverter_inverter_inverter_5kva_energy') | float }}"
        availability: "{{ has_value('sensor.inverter_inverter_inverter_15kva_energy') and has_value('sensor.inverter_inverter_inverter_5kva_energy') }}"
    sensor:
        name: "Inverter Sum Energy Inverter W"
        unique_id: "sensor.energy_sum_inverters_W"
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        state: "{{ states('sensor.inverter_inverter_15kva') | float + states('sensor.inverter_inverter_5kva') | float }}"
        availability: "{{ has_value('sensor.inverter_inverter_15kva') and has_value('sensor.inverter_inverter_5kva') }}"

ok, changes made, thanks

My solar panel is in common with several neighbors and when indicating the calculated solar production the system shows me this scheme:

A doubt, is it possible to make a formula like this?

grid consumption = wat - production (if < 0 is 0)

That is, subtract 2 sensors, and when the number is negative put 0.

- sensor:
  - name: "Consumo de red"
    unique_id: "sensor.consumo_de_red"
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: "{% if (states('sensor.wat') | float - states('sensor.production') | float ) > 0 %}
  {{ (states('sensor.wat') | float - states('sensor.production') | float ) | round (2) }}
{% else %}
  {{ 0 }}
{% endif %}"

Yes but like this:

- sensor:
  - name: "Consumo de red"
    unique_id: "sensor.consumo_de_red"
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {% if (states('sensor.wat') | float - states('sensor.production') | float ) > 0 %}
        {{ (states('sensor.wat') | float - states('sensor.production') | float ) | round (2) }}
      {% else %}
        {{ 0 }}
      {% endif %}
    availability: >
        {{ has_value('sensor.wat') and has_value('sensor.production') }}

Single line version:

- sensor:
  - name: "Consumo de red"
    unique_id: "sensor.consumo_de_red"
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: "{{ [ 0, (states('sensor.wat') | float - states('sensor.production') | float ) | round (2) ] | max }}"
    availability: >
        {{ has_value('sensor.wat') and has_value('sensor.production') }}

The | max filter picks the maximum value in the list [0, your subtraction] and 0 is greater than all negative numbers.

The availability template is important here too. You only want the subtraction result when all the sensors in the template have a value.

In fact without an availability template your template will generate errors as you have not specified default values for the floating point conversion filters. e.g.

"3.1415" | float → 3.1415
"unavailable" | float → template error
"unavailable" | float(0) → 0

You don’t need to specify defaults if you use an availability template as this is evaluated before the state template and returns a state of unavailable if one of the sensors does not have a number in it.

works perfect! thanks, and added availability

1 Like

if I want to have a 24-hour reset cycle, how can I define it?

I’m not sure what you are asking. You don’t reset power sensors. Resetting only makes sense in relation to energy.

You would have to use the Riemann Sum Integration approximation to convert your power to energy (make sure to use method:left to reduce approximation errors).

Then you can feed that energy sensor to a utility meter with whatever reset cycle you want:

yes, I have this template.

########## Mi producciĂłn solar
- sensor:
  - name: "Inversor Mi Produccion Energia"
    unique_id: "sensor.energia_mi_produccion_inversores_kWh"
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    state: "{{ ((states('sensor.inverter_inversor_15kva_energy') | float + states('sensor.inverter_inversor_5kva_energy') | float ) * 0.2957) | round (1) }}"
    availability: "{{ has_value('sensor.inverter_inversor_15kva_energy') and has_value('sensor.inverter_inversor_5kva_energy') }}"

And I see that it accumulates the data, until when does it do it? infinitely? Can I choose when it resets?

Yes that counts up forever.

Feed that sensor to a utility meter (see my previous post). Choose the reset cycle you want in the utility meter.

then I have to create a helper with utilite meter that takes the data from this entity and resets it on a daily, monthly, or yearly basis… etc…? and if I want the 3 options to create 3 helpers?

That is correct.