Hourly Weather-Forecast between 10am and 6 pm

Hello everyone,

I would like to create a weather forecast template that shows me the hourly weather forecasts for the current (or next day) for the times between 10 am and 6 pm (specifically the attributes condition, cloud_coverage and temperature).

So, for example, if it is 7 a.m., I would need the values for the current day and, for example, at 7 p.m. those for the next day. In the course of this time, e.g. at 2 pm only the remaining forecasts until 6 pm of the current day.

As far as I could find out, only a relative daily or hourly forecast is possible.

Can any of you tell me if this is possible?

Many thanks in advance!
Braak

something like this, you need to test and tweak and possibly there is a more esthetic way to write the conditions :slight_smile:

template:
         
  - trigger:
      - platform: time_pattern
        minutes: /10
    action:
      - service: weather.get_forecasts
        data:
          type: hourly
        target:
          entity_id: weather.home
        response_variable: forecast
    sensor:
      - name: Weather Forecast Something
        unique_id: weather_forecast_something
        state: "{{ now().isoformat() }}"
        attributes:
          forecast: > 
            {% set ns = namespace(fc =[]) %}
            {% for item in forecast['weather.home'].forecast %}
            {% if ( 10 <= item.datetime[11:13]|int <= 18 ) and item.datetime|as_datetime < today_at('18:01')  %}
            {% set  ns.fc = ns.fc + [item] %}
            {% elif ( 10 <= item.datetime[11:13]|int <= 18 ) and now() > today_at('18:01') %} 
            {% set  ns.fc = ns.fc + [item] %}
            {% endif %}
            {% endfor %}
            {{ ns.fc }}

just updated it a bit

Wow, this looks promising!!

:star_struck:

I like the approach: at least for my templating skills it looks very aesthetic - thank you!! :heart:

I’ll get back as soon as kids are in bed and I can start tweaking… :wink: