Use .get to ensure we dont get KeyError (#21993)

pull/21994/head
Robbie Trencheny 2019-03-12 18:00:18 -07:00 committed by GitHub
parent ce1fe06193
commit 9428ed7690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -23,8 +23,9 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType):
if hass.data.get(DOMAIN) is None:
hass.data[DOMAIN] = {DATA_DELETED_IDS: [], DATA_REGISTRATIONS: {}}
hass.data[DOMAIN][DATA_DELETED_IDS] = app_config[DATA_DELETED_IDS]
hass.data[DOMAIN][DATA_REGISTRATIONS] = app_config[DATA_REGISTRATIONS]
hass.data[DOMAIN][DATA_DELETED_IDS] = app_config.get(DATA_DELETED_IDS, [])
hass.data[DOMAIN][DATA_REGISTRATIONS] = app_config.get(DATA_REGISTRATIONS,
{})
hass.data[DOMAIN][DATA_STORE] = store
for registration in app_config[DATA_REGISTRATIONS].values():