Met.no integration fails

I just upgraded to 0.115.1. I had an old ‘yr’ weather integration still set up that was deprecated and when I noticed the error I deleted it from my config and found info on the Met.no integration.

I’ve added it manually through the integrations panel and it seems to work, but I have no weather information and I see this in the logs;

Logger: homeassistant.components.weather
Source: components/met/weather.py:218
Integration: Weather (documentation, issues)
First occurred: 6:51:21 PM (2 occurrences)
Last logged: 7:12:19 PM
Error while setting up met platform for weather

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 201, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 310, in async_add_entities
    await asyncio.gather(*tasks)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 481, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 522, in add_to_platform_finish
    self.async_write_ha_state()
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 322, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/weather/__init__.py", line 177, in state_attributes
    if self.forecast is not None:
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/met/weather.py", line 218, in forecast
    ha_item[ATTR_FORECAST_CONDITION]
KeyError: 'condition'

Is this a bug or do I have something misconfigured?

What exactly do you mean by “adding it manually” ?
Did you have Met.no working before you upgraded HA to 0.115.1 ? Or did you upgrade with the old YR integration active?

I upgraded with the old YR inegration active. I then deleted it from my yaml and tried to add the Met.no integration through the UI.

Perhaps reverting back to 0.114 - then remove the Yr integration, and add the Met.no integration. If you can get that successfully done in 0.114 then the upgrade to 0.115 will succeed.
I’m not suggesteing this because I know it’ll work - but because it worked for me.

It doesn’t work for me. I reverted to 0.114.4 and the Met.no integration worked flawlessly. I then upgraded to 0.115.2 and I get the same error in the logs. I’m going to try to revert, disable, re-enable and then update to see if that does the trick.

Nope, that didn’t work either. Same error.

You did of course delete (or at least comment out) the setting from your configuration.yaml

#weather:
#  - platform: met

Yes. I posted an issue on Github, it seems this is indeed a bug in the logic that handles the API response. I’ll report back when the devs figure it out.

Ok, so got this solved, in case it’s useful for anyone else. My timezone wasn’t set up correctly :man_facepalming:t3: so I was getting invalid data back from the API, and the Met.no integration wasn’t validating the response before passing it over to HA. Huge thanks and kudos to @thimic, who troubleshot the issue like a champ.