|
31 | 31 | DEFAULT_START,
|
32 | 32 | DOMAIN,
|
33 | 33 | )
|
| 34 | +from .data import get_entry_data |
34 | 35 | from .helpers import CODE_SLOT_SCHEMA, CODE_SLOTS_SCHEMA, UI_CODE_SLOT_SCHEMA
|
35 | 36 |
|
36 | 37 | _LOGGER = logging.getLogger(__name__)
|
@@ -64,8 +65,12 @@ def _check_common_slots(
|
64 | 65 | (lock, common_slots, entry.title)
|
65 | 66 | for lock in locks
|
66 | 67 | for entry in hass.config_entries.async_entries(DOMAIN)
|
67 |
| - if lock in entry.data[CONF_LOCKS] |
68 |
| - and (common_slots := sorted(set(entry.data[CONF_SLOTS]) & set(slots_list))) |
| 68 | + if lock in get_entry_data(entry, CONF_LOCKS, {}) |
| 69 | + and ( |
| 70 | + common_slots := sorted( |
| 71 | + set(get_entry_data(entry, CONF_SLOTS, {})) & set(slots_list) |
| 72 | + ) |
| 73 | + ) |
69 | 74 | and not (config_entry and config_entry == entry)
|
70 | 75 | )
|
71 | 76 | except StopIteration:
|
@@ -231,7 +236,7 @@ async def async_step_reauth(self, user_input: dict[str, Any]):
|
231 | 236 | additional_errors, additional_placeholders = _check_common_slots(
|
232 | 237 | self.hass,
|
233 | 238 | user_input[CONF_LOCKS],
|
234 |
| - config_entry.data[CONF_SLOTS].keys(), |
| 239 | + get_entry_data(config_entry, CONF_SLOTS, {}).keys(), |
235 | 240 | config_entry,
|
236 | 241 | )
|
237 | 242 | errors.update(additional_errors)
|
@@ -304,7 +309,7 @@ async def async_step_init(
|
304 | 309 |
|
305 | 310 | def _get_default(key: str) -> Any:
|
306 | 311 | """Get default value."""
|
307 |
| - return user_input.get(key, self.config_entry.data[key]) |
| 312 | + return user_input.get(key, get_entry_data(self.config_entry.data, key, {})) |
308 | 313 |
|
309 | 314 | return self.async_show_form(
|
310 | 315 | step_id="init",
|
|
0 commit comments