Closed badewanne1234 closed 1 month ago
I confirm the issue with the daily forecast. Same here.
Same. My nspanel stopped displaying weather forecast since the latest update. Appdaemon logs:
fdate = dp.parse(entity.attributes.forecast[item.stype]['datetime'])
TypeError: string indices must be integers
@letienne the attribute forecast
was deprecated in HA, this has nothing to do with the integration.
@badewanne1234 I don't see any error log in this ticket, nor can I see any error when I run a service call myself — everything just works here:
I suspect you are trying to retrieve "daily" attribute from the returned object, which is not an attribute in the response of the get_forecasts
action:
Sorry but you need to fix the automation / template sensor.
TLDR: remove .daily or .hourly. That's not valid.
Thank you for looking into this. Sorry, but I think you missed the point. I rolled back to an earlier version of your integration and it works fine.
All of us have have already modified our setup to manage the "new" way to handle forecasts a few months back as discussed here.
In my case:
template:
- trigger:
- platform: time_pattern
minutes: /15
action:
- service: weather.get_forecasts
data:
type: daily
target:
entity_id: weather.blabla
response_variable: daily
sensor:
- name: Weather Forecast Daily
unique_id: weather_forecast_daily
state: "{{ states('weather.blabla') }}"
attributes:
temperature: "{{ state_attr('weather.blabla', 'temperature') }}" # change to your weather entity
temperature_unit: "{{ state_attr('weather.blabla', 'temperature_unit') }}" # change to your weather entity
forecast: "{{ daily['weather.blabla'].forecast }}" # change to your weather entity
The following used to work fine, returning a yaml list that other integrations such as this one can handle.
forecast: "{{ daily['weather.blabla'].forecast }}"
.
But the latest commit returns another kind of array (see the brackets "[" instead of the "-" in badewanne's output) :
forecast: [{'datetime': '2024-08-25', (...) }]
.
Whereas the same with an "hourly" type, returns a proper yaml list.
I'm currently happy with the rolled-back code, but if there is anything that can be done in a future release it would be nice :)
Regards
I'm no python expert but I was able to 'fix' it by casting the "ATTR_FORECAST_CONDITION" to a string (yes I know, very ugly).
I think that for some reason your CODE_TO_CONDITION_MAP.get() is returning more than it should (the whole dictionary item):
'condition': <Condition.pouring: 'pouring'>
instead of simply
'pouring'
and that is why HA is having issues converting this into a proper forecast.
The answer was found here: https://community.home-assistant.io/t/new-weather-forecast-template/622642/57 and it links to https://www.home-assistant.io/integrations/weather/#service-weatherget_forecasts
This page lists all "conditions" that HA accepts.
I hope that you now have sufficient information to fix this issue :) thanks !
Thanks for putting the time to properly report this, @letienne! It was still on my //TODO list.
That conversion map for conditions seems to have broken the integration.
@Rudd-O would you mind to open this issue again, thank you
Ohhhh. I reproduced the issue successfully. Will issue a fix very soon.
It should be working now — I tested it locally. Please message if it failed so I can reopen the issue.
I can confirm its working, excellent, thank you!
I'm extracting the weather forecast (daily and now als hourly) into sensors since accessing the forecast data has been changed earlier this year.
The daily output is now broken since the update of the meteoswiss integration yesterday. Interestingly, only the daily forecast is broken, but not the freshly introduced hourly forecast.
Here is my config in the configuration.yaml for daily and for hourly:
The output of these sensors is as follows:
Daily:
Hourly
As you can see, the outputting format is broken for the daily sensor, whilst for hourly its OK. I have the exact same sensors (daily + hourly) as well for the
met.no
weather integration, and it works as it should for both, daily + hourly in the correct format.