Openweathermap - 1 hour forecast instead of 3?

Hey community,

is there a way to get a 1 hour forecast from openweathermap? I have an automation which controls my shutters based on the sun and the current weather + forecast. But the 3h forecast is to far in the future. I need something more closer, like 1h. Unfortunately the forecast was removed from the weather entities and the forecast_condition sensor from openweathermap only shows the forecast in 3h.

Do you know any option how to switch this to 1h? Or are there any other options to get the 1h forecast? Maybe from another weather integration?

BR Mark

It was not removed, what changed was the way to get them. Instead of an attribute, you now need to use a service. Just one of the examples on the forum:

However, the openweathermap integration does not support hourly forecasts, so you might want to switch weather services.

Okay… I do not really understand the code from the quote.

Is there a way to add a template sensor, which brings the weather forecast condition of a specific hour into an sensor? Because using the service to get the forecast is not possible in my scenario I think…

You think… but you do not show how you use it. Tell us what you had originally (or explain what you need more clearly) and we’ll help you change it. It is always possible, sometimes a bit harder, sometimes easy.

A specific hour is harder to do, and likely not what you need.

There’s also this, which includes an option to add weather in the mix.

But my personal favorite: don’t try to estimate when to apply covers, use a lux meter and measure.

A lux meter will only tell you when to close the cover, but not by how much. The integration you linked tells you exactly how far to close them, so you have maximum amount of light + no sun glare

Depends on where you place it. And estimations will only get you so far with changing weather conditions. But, I did refer to the integration because opinions and situations differ. I was just offering alternatives. And if you want to go all in, you could even do both! Low light, don’t bother, bright light, use cover position. No need for weather forecast.

But my most needed scenario is horizontal curtains + couch. That one is not covered by the blueprint.

Yes. But I see the lux sensor as complimentary to the sun position based control, not as a replacement. You can’t figure out the optimal position of a cover from measuring the amount of light. But you can use it as a condition to figure out when to apply control

I’m using the forecast as an additional condition to check in a script. Because the current weather condition should not trigger the shutters to close already, when 10 minutes later it’s sunny again.

I’ve tried to add a triggered template, but it doesn’t work. The new entity doesn’t even appear in my entities after restart.

Do you know, what I’m doing wrong?
(trigger condition is time_pattern for testing:

template:
  - trigger:
    - platform: time_pattern
      minutes: /1
    action:
      - service: weather.get_forecasts
        target:
          entity_id: weather.home
        data:
          type: hourly
        response_variable: hourly
    sensor:
      - name: Wettervorhersage 1 Stunde
        unique_id: weather_forecast_condition_1hour
        state: "{{ hourly.forecast[0].condition }}"

As in the example I posted, the way to get to the forecast also involves the name of the sensor:

state : "{{ hourly['weather.home'].forecast[0].condition }}"

You can check the output of the service in the services tab of the developer tools to see if weather.home supports hourly forecasts (if it is still metNorway it does).

You can also use the action in the script without the intermediate sensor. But this will work too, and is easier if you need it more often.

Yeah, I found that error already. I “debugged” the result using a test script:

alias: Test
sequence:
  - service: weather.get_forecasts
    metadata: {}
    data:
      type: hourly
    target:
      entity_id: weather.home
    response_variable: hourly
  - service: notify.mobile_app_device
    metadata: {}
    data:
      message: "{{ hourly['weather.home'].forecast[0].condition }}"
mode: single

This leads into:

message: 'lightning-rainy'

But the triggered template is not appearing when using that config:

template:
  - trigger:
    - platform: time_pattern
      minutes: /1
    action:
      - service: weather.get_forecasts
        target:
          entity_id: weather.home
        data:
          type: hourly
        response_variable: hourly
    sensor:
      - name: Wettervorhersage 1 Stunde
        unique_id: weather_forecast_condition_1hour
        state: "{{ hourly['weather.home'].forecast[0].condition }}"

hmmm, don’t realy spot any problems there. It is pretty much what I had, I only didn’t include the unique_id. Maybe the name needs quotes because of the number in it? Just a wild guess… I’d expect an error in the logs. Assuming you did reload the templates.