Having trouble getting forecast from custom entity into a card on the UI

Hey mates,

I am struggling with some basics here I believe.

I have a forecast from DWD weather.XXX and I want to show the hourly forecast in a " Lovelace Mini Graph Card" for the next 12h.

I created a template to trigger updates every hour and created a sensor, but I can not manage to connect the temperature values with the card.

TEMPLATE with SENSOR:

template:
  - trigger:
      - platform: time_pattern
        minutes: /1
    action:
      - service: weather.get_forecasts
        data:
          type: hourly
        target:
          entity_id: weather.XXX
        response_variable: hourly
    sensor:
      - name: Weather Forecast Hourly
        unique_id: weather_forecast_hourly
        state: "{{ now().isoformat() }}"
        attributes:
          forecast: "{{ hourly['weather.XXX'].forecast }}"

Card Configuration

type: custom:mini-graph-card
entity: sensor.weather_forecast_hourly
attribute: forecast.temperature

Sample sensor data “weather_forecast_hourly”:

forecast: 
- datetime: '2024-04-19T18:00:00Z'
  condition: pouring
  wind_bearing: 289
  wind_gust_speed: 37
  uv_index: 1
  precipitation_probability: null
  temperature: 7
  wind_speed: 18.5
  precipitation: 0.7
- datetime: '2024-04-19T19:00:00Z'
  condition: pouring
  wind_bearing: 290
  wind_gust_speed: 35.2
  uv_index: 1
  precipitation_probability: null
  temperature: 7
  wind_speed: 18.5
  precipitation: 0.3

Any advise how to connect the sensor with the card? It feels I am missing the peace to iterate through the array.

thanks!

I am not a expert at Mini Graph Card, though I have used it a few times in the past. I don’t think it’s really set up to do what you are trying to do… this is the closest I could get:

image

Card config
type: custom:mini-graph-card
entities:
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.0.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.1.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.2.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.3.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.4.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.5.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.6.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.7.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.8.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.9.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.10.temperature
    color: blue
  - entity: sensor.weather_forecast_hourly
    attribute: forecast.11.temperature
    color: blue
show:
  graph: bar
  legend: false
  labels: true
  state: false
hours_to_show: 1
points_per_hour: 1
1 Like

image
I use the same code you have and get this… very strange.

From the documentation is see one example which I would like to replicate: