Skip to content
This repository was archived by the owner on Dec 31, 2025. It is now read-only.

Conversation

@mrcheese123
Copy link

@mrcheese123 mrcheese123 commented May 1, 2025

Addressing erroneous array access in hc_weather_card causing out of bounds exception preventing the card from rendering. Forecast counting was starting at 1 instead of 0.

For reference, daily forecast returns the following array with 3 elements:

forecast:
  - condition: sunny
    datetime: "2025-05-01T19:00:00+00:00"
    wind_bearing: 0.0
    uv_index: 0.0
    temperature: 0
    templow: 0
    wind_speed: 0.0
    precipitation: 0
    humidity: 0
  - condition: sunny
    datetime: "2025-05-02T19:00:00+00:00"
    wind_bearing: 0.0
    uv_index: 0
    temperature: 0
    templow: 0
    wind_speed: 0.0
    precipitation: 0
    humidity: 0
  - condition: cloudy
    datetime: "2025-05-03T19:00:00+00:00"
    wind_bearing: 0.0
    uv_index: 0.0
    temperature: 0
    templow: 0
    wind_speed: 0.0
    precipitation: 0.0
    humidity: 0

Addressing erroneous array access in hc_weather_card causing out of bounds exception preventing the card from rendering.
@damianeickhoff
Copy link
Owner

@mrcheese123 trying to understand the out of bounds part. It is caused by the wrong counting or by too many forecast sensors?

@coasting24
Copy link
Contributor

coasting24 commented May 10, 2025

The reason that the first day in the weather forecast of hc_weather_card starts with record [1], i.e.
return states[entity.entity_id].attributes.forecast[1].temperature
is that the first record [0] in the custom weather sensor [sensor.weather_entity_forecast] actually holds the data of the current day.
So, in case your custom weather sensor provides four records [0]..[3], you do not have four forecast days, but just only three.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants