4 day weather forecast display using LVGL

I am building a display for the local weather and I had no problem displaying the information for todays weather. But I can’t figure out how to display a weather forecast for the next three days. It looks like recently a special object was added for this but I can’t access it.

This project seem to be able to do it but this code doesn’t work for me.

It says to use this code to create the forecast object. But I get errors when I put this in my configuration.yaml

- trigger:
    - platform: time_pattern
      minutes: /1
  action:
    - service: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.casa
      response_variable: previsioni
  sensor:
    - name: Previsioni
      unique_id: weather_forecast
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ previsioni['weather.casa']['forecast'] }}"

Is there a simple way to get a weather forecast on ESPHome. Or good directions for a complex way?

Update:
I got it working.

weather_demo

I created an example file SDL-weather-forcast.yaml

This topic has an example on how to get weather data to an e-ink display. That will work equally well on other displays:

Thanks you I did see that. Unfortunately Home assistant recently changed the way they do weather forecasts. So that 3 year old code no longer works.

This is the only project I can find that is using the current code

I think part of the issue is I’m using Accuweather and it looks like this does not work with the Homeassistant forecast system.

Your post here is very helpful

1 Like

I hacked around for a few hours and I got it. Part of the problem was I was using Accuweather and they only give you 25 lookups per day for free. So I was not able to do more testing with them. I switched to National Weather service but they only give you twice daily weather reports not daily. What I ended up doing is a bit convoluted I take the high temps from the first part of the day and low temp from the second.

Looks a bit weird but it works. A simple 3 day forecast. Now I just need to get this into ESPHome but I think that will be easy now.

template:
  - trigger:
      - trigger: time_pattern
        hours: /1
    action:
      - action: weather.get_forecasts
        data:
          type: twice_daily
        target:
          entity_id: weather.kmht
        response_variable: weathertodaykmht
    sensor:
      - name: weather_forcast_kmht
        state: "{{ now().isoformat() }}"
        attributes:
          condition_0: >
            {{ weathertodaykmht["weather.kmht"].forecast[0].condition }}
          temperature_hi_0: >
            {{ weathertodaykmht["weather.kmht"].forecast[0].temperature | round }}
          temperature_lo_0: >
            {{ weathertodaykmht["weather.kmht"].forecast[1].temperature | round }}            
          day_0: >
            {{ as_timestamp(weathertodaykmht["weather.kmht"].forecast[0].datetime) | timestamp_custom('%A') }}

          condition_1: >
            {{ weathertodaykmht["weather.kmht"].forecast[2].condition }}
          temperature_hi_1: >
            {{ weathertodaykmht["weather.kmht"].forecast[2].temperature | round }}
          temperature_lo_1: >
            {{ weathertodaykmht["weather.kmht"].forecast[3].temperature | round }}   
          day_1: >
            {{ as_timestamp(weathertodaykmht["weather.kmht"].forecast[2].datetime) | timestamp_custom('%A') }}
            
          condition_2: >
            {{ weathertodaykmht["weather.kmht"].forecast[4].condition }}
          temperature_hi_2: >
            {{ weathertodaykmht["weather.kmht"].forecast[4].temperature | round }}
          temperature_lo_2: >
            {{ weathertodaykmht["weather.kmht"].forecast[5].temperature | round }}   
          day_2: >
            {{ as_timestamp(weathertodaykmht["weather.kmht"].forecast[4].datetime) | timestamp_custom('%A') }}    

I figured Madeleine’s repro would have updated to the new format, but apparently it hasn’t. So spitting to a mile long thread was not what I had in mind when I redirected you (right before taking off to my dayjob). Next time I’ll be more specific, sorry for that. Glad you found my posts to highlight the changes needed.