Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map openweathermap weather condition codes once #98516

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions homeassistant/components/openweathermap/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,8 @@
904,
],
}
CONDITION_MAP = {
cond_code: cond_ha
for cond_ha, cond_codes in CONDITION_CLASSES.items()
for cond_code in cond_codes
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
ATTR_API_WIND_BEARING,
ATTR_API_WIND_GUST,
ATTR_API_WIND_SPEED,
CONDITION_CLASSES,
CONDITION_MAP,
DOMAIN,
FORECAST_MODE_DAILY,
FORECAST_MODE_HOURLY,
Expand Down Expand Up @@ -267,7 +267,7 @@ def _get_condition(self, weather_code, timestamp=None):
return ATTR_CONDITION_SUNNY
return ATTR_CONDITION_CLEAR_NIGHT

return [k for k, v in CONDITION_CLASSES.items() if weather_code in v][0]
return CONDITION_MAP.get(weather_code)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would previously fail hard



class LegacyWeather:
Expand Down