Open-Meteo Solar Forecast

Hello and thanks for the integration as well as the code to merge more than one sensor. I am experiencing a strange behavior on the Apex chart: the forecasted and remaining Wh differ.

It looks like the template sensor for today’s forecast is missing one string. Here is the template code for three strings:

    - name: "Energy Production today all (Template)"
      unique_id: energy_production_today_all
      state: >
        {{ (states('sensor.energy_production_today_3') | float(default=0) + states('sensor.energy_production_today_4') | float(default=0) + states('sensor.energy_production_today_5') | float(default=0)) | round(2) }}
      unit_of_measurement: "kWh"
      device_class: energy
      attributes:
        watts: >-
         {% set sensor1 = state_attr('sensor.energy_production_today_3', 'watts') %}
         {% set sensor2 = state_attr('sensor.energy_production_today_4', 'watts') %}
         {% set sensor3 = state_attr('sensor.energy_production_today_5', 'watts') %}
          {% set ns = namespace(output={}) %}
          {% for time, value in sensor1.items() %}
            {% set sum_value = value + sensor2[time] + sensor3[time] %}
            {% set ns.output = dict({time: sum_value}, **ns.output) %}
          {% endfor %}
          {{ ns.output }}
        wh_period: >-
         {% set sensor1 = state_attr('sensor.energy_production_today_3', 'wh_period') %}
         {% set sensor2 = state_attr('sensor.energy_production_today_4', 'wh_period') %}
         {% set sensor3 = state_attr('sensor.energy_production_today_5', 'wh_period') %}
          {% set ns = namespace(output={}) %}
          {% for time, value in sensor1.items() %}
            {% set sum_value = value + sensor2[time] + sensor3[time] %}
            {% set ns.output = dict({time: sum_value}, **ns.output) %}
          {% endfor %}
          {{ ns.output }}

and here the code for the remaining sum sensor:

    - name: "energy production remaining day (Template)"
      unique_id: energy_production_remaining_day
      state: >
        {{ (states('sensor.energy_production_today_remaining_3') | float(default=0) + states('sensor.energy_production_today_remaining_5') | float(default=0) + states('sensor.energy_production_today_remaining_4') | float(default=0)) | round(2) }}
      unit_of_measurement: "kWh"
      device_class: energy

I just double-checked that the sensors are available… Any idea why this happens?

New Release: Release 0.1.16 · rany2/ha-open-meteo-solar-forecast · GitHub

  • Improves cell temperature calculation (should reduce over/under-estimations)
  • Add damping support for morning and/or evening
2 Likes

First of all thanks for the great integration

I am being a right numpty I am sure.

I have two stings of panels, so sensor.energy_production_today and sensor.energy_production_today_2

I am trying to use the template sensor to create totals but totally getting it wrong and don’t know why. Do I add it via the Helpers screen or do I create sensors.yaml which seams like the better way but I keep getting configuration errors I have tried both but obviously doing something wrong.

If possible could some one show me the full code they have in there sensors.yaml file please, it would be really appreciated.

if you look two posts above yours there is a yaml example of how to combine strings (three, but you’ll get the idea) Open-Meteo Solar Forecast - #268 by Monster_D

if you are still having trouble best to post our own yaml and let others have a look that way.

I get that but how do I start the sensors.yaml file? do I use

platform: template
  - sensors:

or

template
  - sensors:

etc. for some reason I can’t figure which I should use and whatever I try gives me config error

Fairly sure it’s Template Sensors we need here so it’s the second option you have.
Full details are here Template - Home Assistant

If you are using a split configuration (think you are based on the “sensors.yaml” question) then you first need to have the template: platform defined in your configuration.yaml and then your sensors.yaml (maybe call it template_sensors.yaml to avoid confusion with the actual sensor platform) file with the code from your second example (tho comment out the “template” line as you now already have this in configuration.yaml) along with the code from the post I referenced earlier…

(this probably reads a lot better in my head than on here but hopefully points you in right direction)

Thanks, befoer I got to read your reply I managed to sort it by putting straight into the main configuration.yaml

I appreciate your time responding

no worries…sometimes it’s easier to “just do”…most of the time HA will tell you what’s wrong itself and I find it a good way to figure it out.

If you do have this template in your main configuration.yaml and plan to add more it’ll get fairly big fairly quickly and can be difficult to manage…off topic in this thread but maybe consider splitting out your config into separate folders/files to make it more manageable…see Splitting up the configuration - Home Assistant for more details and how to…

1 Like

Sorry for being a right numpty, this is first time creating template sensors. I have the code in my configuration.yaml and works fine but when I try to split into sensors.yaml I get errors.

Orriginal code in my configuration.yaml:

template:
  - sensor:
    - name: "energy_production_today_all"
      state: >
        {{ (states('sensor.energy_production_today') | float(default=0) + states('sensor.energy_production_today_2') | float(default=0)) | round(2) }}
      unit_of_measurement: "kWh"
      device_class: energy
      attributes:
        watts: >-
          {% set sensor1 = state_attr('sensor.energy_production_today', 'watts') %}
          {% set sensor2 = state_attr('sensor.energy_production_today_2', 'watts') %}
          {% set ns = namespace(output={}) %}
          {% for time, value in sensor1.items() %}
            {% set sum_value = value + sensor2[time] %}
            {% set ns.output = dict({time: sum_value}, **ns.output) %}
          {% endfor %}
          {{ ns.output }}
        wh_period: >-
          {% set sensor1 = state_attr('sensor.energy_production_today', 'wh_period') %}
          {% set sensor2 = state_attr('sensor.energy_production_today_2', 'wh_period') %}
          {% set ns = namespace(output={}) %}
          {% for time, value in sensor1.items() %}
            {% set sum_value = value + sensor2[time] %}
            {% set ns.output = dict({time: sum_value}, **ns.output) %}
          {% endfor %}
          {{ ns.output }}

Now I have commented out the above lines and inserted the !include line for sensors and put the following in sensors.yaml :

  - platform: template
    sensors:
      energy_production_today_all:
        state: >
          {{ (states('sensor.energy_production_today') | float(default=0) + states('sensor.energy_production_today_2') | float(default=0)) | round(2) }}
        unit_of_measurement: "kWh"
        device_class: energy
        attributes:
          watts: >-
            {% set sensor1 = state_attr('sensor.energy_production_today', 'watts') %}
            {% set sensor2 = state_attr('sensor.energy_production_today_2', 'watts') %}
            {% set ns = namespace(output={}) %}
            {% for time, value in sensor1.items() %}
              {% set sum_value = value + sensor2[time] %}
              {% set ns.output = dict({time: sum_value}, **ns.output) %}
            {% endfor %}
            {{ ns.output }}
          wh_period: >-
            {% set sensor1 = state_attr('sensor.energy_production_today', 'wh_period') %}
            {% set sensor2 = state_attr('sensor.energy_production_today_2', 'wh_period') %}
            {% set ns = namespace(output={}) %}
            {% for time, value in sensor1.items() %}
              {% set sum_value = value + sensor2[time] %}
              {% set ns.output = dict({time: sum_value}, **ns.output) %}
            {% endfor %}
            {{ ns.output }}

But when I run the ‘check config’ it gives the following errors:

Invalid config for 'template' from integration 'sensor' at sensors.yaml, line 4: required key 'value_template' not provided
Invalid config for 'template' from integration 'sensor' at sensors.yaml, line 5: 'state' is an invalid option for 'sensor.template', check: sensors->energy_production_today_all->state
Invalid config for 'template' from integration 'sensor' at sensors.yaml, line 9: 'attributes' is an invalid option for 'sensor.template', check: sensors->energy_production_today_all->attributes

I have actually got two template sensors, both exactly same code apart from one for today and one for tomorrow so didn’t both pasting both and I get the above errors for both sensors.

what does the “include” line look like in your configuration.yaml…it’s “template” you need to include not “sensor” (a different platform) so it should be something like
template: !include_dir_merge_list includes/template_sensors which is what I use.
My config then let’s me use any yaml file in a directory called includes/template_sensor. I do this so I can have multiple yaml files for different template types all in the one directory but still split somewhat…
(there are a few ways to do this so others may have different opinions but that works for me)

once you have that setup the individual template sensor files will be as you have above but with the first line commented out (the template line in your first yaml snippet as this is now already in configuration.yaml)

edit: ignore your second yaml snippet as this is wrong/the wrong way to go about it (AFAIK)

1 Like

Thanks Gavin, all sorted and working

1 Like

Installed this forecast a couple of days ago, so not much data to go on, but it seems that the forecast is way off in the mornings and surprisingly accurate the rest of the day.

There are two damping parameters that can be set, but I fail to find any documentation for them.
Is the damping factor a float, that is 0.0 - 1.0?
How does it affect the forecast?

Please see how the dampening is calculated here: open-meteo-solar-forecast/src/open_meteo_solar_forecast/open_meteo_solar_forecast.py at 95e6388bf3ff16e6092fe630d273250b25ce53ea · rany2/open-meteo-solar-forecast · GitHub

Thank you for the link.
So the damping factor is indeed 0.0 - 1.0. Furthermore, if I understand correctly, it is applied linearly from sunrise to ~noon and ~noon to sunset respectively.

I’ll play around with it a bit and see if the forecast improves.

This integration is truly wonderful thank you so much for contributing it to the community! I apologize if this has been answered before but I did not see the answer.

Using the default recommended Value for DC efficiency (0.93) the projected generation at mid-day is massively higher than reality. Morning and evening are extremely close without any tweaking. I’ve dropped this DC Efficiency value down to 0.78 to bring things in line with reality and my system is now tracking extremely close to the predictions.

I suppose the question I have is why is this happening? The predictions with my current settings seem to be reliable so I’m very pleased but it is puzzling?

My system is composed of REC420AA panels and Enphase IQ8M-72-2-US micro-inverters that are supposedly 97.8% peak efficiency according to their spec sheet (I understand this is a best-case theoretical value).

The Azimuth and Declination values I’ve entered appear to be accurate as the predicted generation by https://pvwatts.nrel.gov/ aligns very closely to my actual production using the same values I’ve entered into the Open-Meteo Integration.

Thanks again!

There are days when the forecast curve looks really good and sometimes it looks like the curve is off by an hour.
Good:



Issue:




Has anyone seen this before and has an idea/solution?