Open-Meteo Solar Forecast

I think you need to update these lines

{% set sum_value = value + sensor2[time] + sensor3[time] + sensor4[time] %}
1 Like

Thank you, I will have to wait until tomorrow to test it because at about 5 p. m. my rate limit had been exceeded again. :frowning:

I’ve decided to make my Open-Meteo instance public, you could use https://om.4gggg.com if you like. All you would need to do is set it as the Base URL, there is no API key required.

4 Likes

You can test you code directly in the developer tools. And yes you need the time do fetch the values.

URGENT: please update to the latest version, 0.1.11 IMMEDIATELY. A bug was found and addressed where sometimes, while attempting to refresh the state of the power sensors without fetching data from the server; an API request is made anyway. This could cause you to use up your quota if you used the flagship Open-Meteo instance.

Please update to v0.1.11. No other code changes were made for this release from 0.1.10.

8 Likes

@rany and @MelleD

The site is working and the Apex Charts, too.

Thank you very much.

2 Likes

But how @rany said keep in mind

Just keep in mind that sensor2[time] might not exist in some rare cases so you should make it default to 0 somehow.

So have to add checks for every sensor

1 Like

I do not know how to do this, unfortunately.

You could try to refer to this Open-Meteo Solar Forecast - #190 by rany

1 Like

Ok but I have got 4 sensors and do not know how to add them to this code.

Try it yourself first and ask questions if something is unclear, then you will learn something.
This also helps you with other problems and automations.

2 Likes

Basically you are right, but my problem is that I have already spent hundreds of hours creating and adapting many kinds of codes and automations for different purposes. And after a while I cannot remember much of it so I am starting more or less from scratch every time. And I do not have that much time.

And what if others have the same issue? And it’s not the best way to just let others do your work!

No offense, but perhaps others can easily help me out without effort and myself could be sitting hours with trial and error. I thought it was the purpose of a forum to help each other, maybe I know something that another user does not know and can help him, too. And I did already in other cases.

As I cannot see the result of this code-addition directly I may never know if it is working or not.

I can only guess: is this the right solution for a 3rd sensor?

{% set sensor1 = state_attr('sensor.energy_production_today_2', 'watts') %}
{% set sensor2 = state_attr('sensor.energy_production_today_3', 'watts') %}
{% set sensor3 = state_attr('sensor.energy_production_today_4', 'watts') %}
{% set ns = namespace(output={}) %}

{% for time, value in sensor1.items() %}
    {% set ns.output = dict({time: value}, **ns.output) %}
{% endfor %}

{% for time, value in sensor2.items() %}
    {% if time in ns.output %}
        {% set ns.output = dict({time: ns.output[time] + value}, **ns.output) %}
    {% else %}
        {% set ns.output = dict({time: value}, **ns.output) %}
    {% endif %}
{% endfor %}

{% for time, value in sensor3.items() %}
    {% if time in ns.output %}
        {% set ns.output = dict({time: ns.output[time] + value}, **ns.output) %}
    {% else %}
        {% set ns.output = dict({time: value}, **ns.output) %}
    {% endif %}
{% endfor %}
{{ ns.output }}

But there is a big difference between
“Please do this for me” or I tried this and it doesn’t work, I have a question. You have to show initiative or maybe it’s just the wrong system for you

Just letting other people do the work, I don’t think that’s the idea for a forum.

I think it is silly to modify a piece of code without having a clue just to present some kind of “own work”. To modify the code as I did I just had to copy and paste twice and change two numbers. That is not my understanding of “work”. If my addition of another sensor was right it was mere luck. Anybody else could have done that in a few seconds.
In the time you criticized me you could have done that a few times probably if this was the solution.
The problem for me is, that I do not know if my guess was right as I do not know how to confirm this either. The code is working so far even without this part.

By the way I did not say “please do this for me”, I just mentioned that I do not know how to add more sensors. If anything I just asked for a hint or an explanation.

@P1t try this

{% set sensor1 = state_attr('sensor.energy_production_today_2', 'watts') %}
{% set sensor2 = state_attr('sensor.energy_production_today_3', 'watts') %}
{% set sensor3 = state_attr('sensor.energy_production_today_4', 'watts') %}
{% set sensor4 = state_attr('sensor.energy_production_today_5', 'watts') %}

{% set ns = namespace(output={}) %}

{% for time, value in sensor1.items() %}
  {% set sum_value = value %}
  {% if time in sensor2 %}
    {% set sum_value = sum_value + sensor2[time] %}
  {% endif %}
  {% if time in sensor3 %}
    {% set sum_value = sum_value + sensor3[time] %}
  {% endif %}
  {% if time in sensor4 %}
    {% set sum_value = sum_value + sensor4[time] %}
  {% endif %}
  {% set ns.output = dict(ns.output, **{time: sum_value}) %}
{% endfor %}

{% for time, value in sensor2.items() %}
  {% if time not in sensor1 %}
    {% set sum_value = value %}
    {% if time in sensor3 %}
      {% set sum_value = sum_value + sensor3[time] %}
    {% endif %}
    {% if time in sensor4 %}
      {% set sum_value = sum_value + sensor4[time] %}
    {% endif %}
    {% set ns.output = dict(ns.output, **{time: sum_value}) %}
  {% endif %}
{% endfor %}

{% for time, value in sensor3.items() %}
  {% if time not in sensor1 and time not in sensor2 %}
    {% set sum_value = value %}
    {% if time in sensor4 %}
      {% set sum_value = sum_value + sensor4[time] %}
    {% endif %}
    {% set ns.output = dict(ns.output, **{time: sum_value}) %}
  {% endif %}
{% endfor %}

{% for time, value in sensor4.items() %}
  {% if time not in sensor1 and time not in sensor2 and time not in sensor3 %}
    {% set ns.output = dict(ns.output, **{time: value}) %}
  {% endif %}
{% endfor %}

{{ ns.output }}

1 Like

I noticed a reoccurring pattern in the last couple of days: The integration overestimates for the next day, at least 10kWh or more.

The reason: It wildly overestimates in the morning.

Today, for example, it estimated that we’ll already have had a solar yield of 15kWh at only 7.30am. In reality we didn’t even have 1kWh yet. The sun only came out 41 minutes ago…

If I expose the raw variables that generate the prediction (temp, wind speed, irradiance, pressure, etc) in the diagnostics would you be willing to share it with me? Right now this is unactionable for me as I don’t have such an issue and cannot debug it.

At any rate, for it to be so wildly off do you think that all the parameters are correct?

1 Like

@slipx06

Thank you, I will try but I do not know how to confirm that this addition is working correctly because I had no issues with the original code.

Kind regards