Energy hourly balance for Solar Instalations

Thank you for this integration, I was struggling with being able to work with netted energy for a while. I was finally able to make sensors that reset every hour and tell whether there is import or export and calculate the cost based on the right tariff based on that. But then how to make that cumulative was the second question, this integration seems to do that :slight_smile:

However, I have one question or maybe feature request. While within the hour we know what the current netted balance is, couldn’t this be used to show the real time netted values? At the moment, the sensor updates only once per hour (as we have hourly netting use in Finland still). What I am hoping is that I would see the real time cumulative info with these sensors.

I already tried creating a template sensor that calculates your sensors and the one I created (that resets every hour). But the issue there is the 5s offset so I get a spike at the end of each hour (well, this disappears right after but still a bit annoying). So therefore I was thinking why not add this (possibility at least) directly to this integration :slight_smile:

That was the initial idea, but it doesn’t work. The problem is that the values would go up and down, since the balance changes during the hour and the total_increase sensors cannot lower their value.

Ok - and I guess for these sensor to work correct total increasing is the only way to set them up? My template sensor which is summing your import/export net sensors and hourly net seems to work except for the spikes at 59:55 mark at each hour. I tried adding this rule to the template sensor but it did not work:

      state: >
        {% set energy_base = float(states('sensor.net_exported'),0) %}
        {% set energy_h = float(states('sensor.net_hourly'),0) %}
        {% set last_seconds = now.minute == 59 and now.second >= 54 %}
        {% if energy_h < 0 and not last_seconds %}
          {% set energy_add = float(states('sensor.net_hourly'),0) %}
        {% else %}
          {% set energy_add = 0 %}
        {% endif %}
        {{ '%0.6f'|format( energy_base + energy_add ) }}

By defining “last_seconds” as time anything above 59:53 adding the hourly balance only if it is not last seconds of the hour I was hoping that it would not add the hourly sensor (that is, not adding after 59:53 when the integration does the adding). I think the safest way would be somehow to take this into consideration directly in the integration, but maybe it is not possible.

You can simplify the template with max/min functions

Exported
{{ '%0.6f' | format( float(states('sensor.net_exported'), 0) + max(float(states('sensor.net_hourly'), 0), 0) )}}

Imported
{{ '%0.6f' | format( float(states('sensor.net_imported'), 0) - min(float(states('sensor.net_hourly'), 0), 0) )}}

Hi! @MiguelAngelLV
Today’s update you posted caused a dramatic spike in CPU usage. And as a result, an increase in Load 1,5,15 and processor temperature.

balance

balance1

You can help ?

I publish a update that would fix the problem.

1 Like

Thank you very much, the fix solves the problem. Good job.

Edit … 14.05
however, the problem returned

net

Yup, same issue here. 1.4.0 is working fine.

I am testing “very well” a V1.6 before of publish that should fix (of truth) the problem.

2 Likes

Published the new updated. I hope that now “it is the good”

This time it looks really good.

1 Like

Has someone experienced any issue since the last Home Assistant update? It seems the energy registration stops early in the morning and it doesn’t come back until I restart HA:

Do you check you inverter/metter integration?

I’m not sure about what you mean, but they (2 inverters) seem to be ok; they are reporting power and energy with no issues trough HA and the values reported are consistent with the values reported by the vendor’s app.
Maybe I should uninstall the HACS hourly balance addon and see what happens.

For me it wasn’t issue with Miguel’s addon, on your screen you dont even have info about inverter’s production which is not provided via this addon. This was some other issue in your HA.

1 Like

You should check if the missing data is available in inverters sensors in HA.

Exactly

Yes, HA is reporting power and energy with no issues. As an example: HA reported (by an automation) the exact consumption at 08:00 as usual.
Ok, I know you can’t help me with so little information; I’ve only asked just in case someone other had issues. I’ll investigate more.
Thank you!

Same issue in my HA during last night, HA was updated on yesterdays evening to 2024.07.1. Issue was impacting whole data in HA (graphs and values in entities).
Just to double check because maybe it was different addon or root cause.
@MiguelAngelLV aren’t you using database in the same way as those?

Hey, can’t help much here (I’m a simple user just dealing with some custom sensors) but just in case: I’ve restored a backup previous to the last HA update and the issue didn’t reproduced so far.
Sorry for posting here; I just suspected this addon was somehow related, because that never happened before; this was my first HA update after installing the Energy hourly balance addon and the first time I had that issue, but I can’t assure whether it’s related.
If you want I check any log, config or whatever, I can happily do it.
And man, @MiguelAngelLV thank you for your hard work!

Nop. The component not use the database directly, it only create 3 sensors and HA is have the responsibility of save the data.

1 Like