Add first and last hour of the day to generate solar in Forecast.solar

I am looking to create automations based on when the first hour is supposed to generate electricity and the last hour of the day. At the moment, I can only do this using the next hour entity.

The associated hour and amount of solar would be great.

You can do this already with some templating, getting the first and last time when it is 0, this you can also use in automations.
First you need to setup a sensor to extract the data from one of the solar forecast providers, I have one that kicks back a key/value where key is a date and the value the watthours
Then you can do this for example

{% for i in state_attr('sensor.solar_forecast_watt_hours_period_2','result').items() %}
{% set x = state_attr('sensor.solar_forecast_watt_hours_period_2','result') | count %}
{% if loop.index == x-1 %}
{{ i[0] }} / {{ i[1] }}
    {% endif %}
{% endfor %}

{% for i in state_attr('sensor.solar_forecast_watt_hours_period_2','result').items() %}
{% set x = state_attr('sensor.solar_forecast_watt_hours_period_2','result') | count %}
{% if loop.index == 2 %}
{{ i[0] }} / {{ i[1] }}
    {% endif %}
{% endfor %}

Probably the jinja guru’s have a more concise solution, I just wanted to highlight that you can do a lot already yourselves

@vingerha Which entity has the attributes with the data in? I’ve checked the forecast for today, tomorrow and next hour but they don’t seem to have a list of forecast by the hour. I’m using forecast.solar.

I used forecast solar, it is free for max 10 calls per day, for my purpose I only need/extract watt_hours_period, using a rest sensor

Forecast.Solar | Homepage

1 Like

Oh I see! I missed using the rest integration to get the data. Thanks for this. I will take a look later.

I would still love to see this data in the integration itself if possible.

Too many variables / wishes here I guess, eg i would possibly only be interested if 0

It should be ok because the weather entity also has a list of forecast in the attributes.

and for those also no separate sensors , that is what I mean. you can creat your particulars and I personally donot see why this proposal applies to a large group justifying dev effort

I would be happy for a list of of periods and then use templates to extract the values I need as entities.

The advantage of having the data handled by the integration rather than a separate rest integration would be managing the API rate limits via the Forecast.solar integration.

I can’t comment on the dev effort and I hope others who have the same wish to vote on the request.

It is fairly easy to extract values from the forecast data and make your own sensor.

Here is an example of mine where I pull the forecast high for the day. FYI…the [0] in the value template is the day in first day in the forecast, [1] would be the next, then [2], etc.

  - platform: template
    sensors:
      temperature_high_forecast:
        friendly_name: "Forecast High Temperature"
        value_template: "{{state_attr('weather.home','forecast')[0].temperature }}"

Do read the OP question…

So then why not use the rest -sensor ?
This gives me below, it will be a bit of a thing to get data out as you’d need to iterate over it to split days but possibly (?) forecast.solar can extract on a sinlgly day-basis?
EDIT: I also used a commandline, curl with jq…jq might be easier than jinja here

@vingerha thanks for your workarounds. I am going to leave it here as a feature request and :crossed_fingers:someone will pick this up.