Skip to content

Weather .get_forecasts for NWS station returns Failed to call service weather.get_forecasts. Unknown error #120573

Description

@kirbyschapman

The problem

I can't get weather forecasts from the NWS integration. The last one that worked was 6/26/2024.

What version of Home Assistant Core has the issue?

2024.5.5

What was the last working version of Home Assistant Core?

2024.5.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

NWS

Link to integration documentation on our website

https://www.home-assistant.io/integrations/nws/

Diagnostics information

I use get_forecasts to get the next several days for weather. The last one that was successfully retrieved was on June 20, 2024. Since then, I get the error listed in the title.

Example YAML snippet

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

Anything in the logs that might be useful for us?

2024-06-26 08:35:13.971 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: list index out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 501, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1047, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 1059, in async_get_forecasts_service
    native_forecast_list = await weather.async_forecast_hourly()
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 1237, in async_forecast_hourly
    return await self._async_forecast("hourly")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 1226, in _async_forecast
    list[Forecast] | None, getattr(self, f"_async_forecast_{forecast_type}")()
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/nws/weather.py", line 277, in _async_forecast_hourly
    return self._forecast(self.nws.forecast_hourly, HOURLY)
                          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pynws/simple_nws.py", line 369, in forecast_hourly
    return self._convert_forecast(self._forecast_hourly, self.filter_forecast)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pynws/simple_nws.py", line 421, in _convert_forecast
    time, weather = parse_icon(forecast_entry["icon"])
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pynws/simple_nws.py", line 153, in parse_icon
    time = icon_list[5]
           ~~~~~~~~~^^^
IndexError: list index out of range

Additional information

This is similar to other issues that have been closed, hence the reason I'm adding this issue. I'd been following the others, but I didn't see a solution that would work with my setup (?). At least one of those issues said the NWS data was unavailable. While mine was unavailable, it became available yesterday. But the get_forecasts service call produces an "unknown" error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions