From f8f64e5b7577060086f6a7c3edb0988c48afbada Mon Sep 17 00:00:00 2001 From: SAY-5 Date: Mon, 11 May 2026 13:45:36 -0700 Subject: [PATCH] fix: avoid KeyError in config flow duplicate check entry.data[KEY_DOMAIN] raised KeyError because the 'domain' key is never written into data by async_create_entry below. _async_current_entries() already filters by handler domain, so the inner check was both broken and redundant. Fixes #446 --- custom_components/panasonic_cc/config_flow.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/custom_components/panasonic_cc/config_flow.py b/custom_components/panasonic_cc/config_flow.py index 8402645..47cf5cb 100644 --- a/custom_components/panasonic_cc/config_flow.py +++ b/custom_components/panasonic_cc/config_flow.py @@ -13,7 +13,6 @@ from aio_panasonic_comfort_cloud import ApiClient from . import DOMAIN as PANASONIC_DOMAIN from .const import ( - KEY_DOMAIN, CONF_FORCE_OUTSIDE_SENSOR, CONF_ENABLE_DAILY_ENERGY_SENSOR, DEFAULT_ENABLE_DAILY_ENERGY_SENSOR, @@ -44,10 +43,9 @@ def async_get_options_flow(config_entry): async def _create_entry(self, username, password): """Register new entry.""" - # Check if ip already is registered - for entry in self._async_current_entries(): - if entry.data[KEY_DOMAIN] == PANASONIC_DOMAIN: - return self.async_abort(reason="already_configured") + # _async_current_entries() already filters to this integration's domain. + if self._async_current_entries(): + return self.async_abort(reason="already_configured") return self.async_create_entry(title="", data={ CONF_USERNAME: username,