Guard withings accessing hass.data without it being set (#73454)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
pull/73504/head
Paulus Schoutsen 2022-06-14 10:55:58 -07:00
parent d6bfb86da2
commit d8f2afb772
1 changed files with 4 additions and 3 deletions

View File

@ -72,11 +72,12 @@ CONFIG_SCHEMA = vol.Schema(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Withings component."""
conf = config.get(DOMAIN, {})
if not (conf := config.get(DOMAIN, {})):
if not (conf := config.get(DOMAIN)):
# Apply the defaults.
conf = CONFIG_SCHEMA({DOMAIN: {}})[DOMAIN]
hass.data[DOMAIN] = {const.CONFIG: conf}
return True
# Make the config available to the oauth2 config flow.
hass.data[DOMAIN] = {const.CONFIG: conf}
# Setup the oauth2 config flow.