Weather Forecasts in AppDaemon

With the new Weather Forecast requiring a service to access the forecast data, I’m struggling to access this data in AppDaemon.

Here’s my Code:

forecast_str = self.call_service('weather/get_forecast', entity_id = 'weather.home', type = 'hourly', return_result=True)
self.log(f"Forecast String: {forecast_str}")

However, when I run this, I get an error:

2023-10-31 10:19:15.121092 WARNING HASS: Error calling Home Assistant service default/weather/get_forecast
2023-10-31 10:19:15.121465 WARNING HASS: Code: 500, error: 500 Internal Server Error

I’ve tested this in Developer Tools, and it works just fine. Not sure why it’s not working in AppDaemon.

service: weather.get_forecast
  entity_id: weather.home
  type: hourly

Any suggestions?

From what I found out, this currently seems to be unsupported. I’ve resorted to using the (deprecated) forecast attribute of the weather entity for now.

Reference: Weather `get_forecast` service returns 500 on 2023.9.0 · Issue #99820 · home-assistant/core · GitHub


Thank you for finding that. The custom weather integration I use has jumped both feet into the new way of doing things, and no longer has the deprecated forecast attribute. Props to them for being forward thinking, but it sucks for my integrations.

Hopefully it gets merged in soon.

Still no update on this one, right? With the release of 2024.3 on the horizon this gets more important as the forecast attributes are then removed.
I recently wanted to replace my usage of the attribute usage in AppDaemon, but since this service call is not working, this seems to not be possible.

Unfortunately, it looks like this still doesn’t work.

Since the integration I was using had already removed the deprecated forecast attribute, I needed to come up with my own way of getting this data to AppDaemon, so I used a template sensor as a DIY forecast:

  - trigger:
      - platform: time_pattern
        hours: /1
      - service: weather.get_forecasts
          type: hourly
          entity_id: weather.home
        response_variable: hourly
      - name: Home Forecast Hourly
        state: "{{ hourly['weather.home'].forecast[0].condition }}"
          forecast: "{{ hourly['weather.home'].forecast }}"

I was then able to use this sensor.home_forecast_hourly entity in AppDaemon without a problem.

Be aware that this automation triggers a “warning” in my logs, which relates to an open issue: Trigger Update Coordinator: Running script requires passing in a context · Issue #99914 · home-assistant/core · GitHub. Per this issue, this warning can be safely ignored, but it’s annoying all the same.

1 Like