Skip to content

Commit b1625df

Browse files
authored
Fix core detection when overkiz is ignored (#750)
* Fix core detection when overkiz is ignored * Check if entry in a list * Add correct imports
1 parent 9e126c9 commit b1625df

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

custom_components/tahoma/__init__.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
import logging
88

99
from aiohttp import ClientError, ServerDisconnectedError
10-
from homeassistant.config_entries import ConfigEntry
10+
from homeassistant.config_entries import (
11+
SOURCE_DHCP,
12+
SOURCE_USER,
13+
SOURCE_ZEROCONF,
14+
ConfigEntry,
15+
)
1116
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
1217
from homeassistant.core import HomeAssistant, ServiceCall
1318
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
@@ -222,11 +227,11 @@ def log_device(message: str, device: Device) -> None:
222227
async def _block_if_core_is_configured(hass: HomeAssistant, entry: ConfigEntry) -> bool:
223228
overkiz_config_entries = hass.config_entries.async_entries("overkiz")
224229

225-
for overkiz_entry in overkiz_config_entries:
226-
if (
227-
entry.data[CONF_USERNAME] == overkiz_entry.data[CONF_USERNAME]
230+
return any(
231+
(
232+
overkiz_entry.source in [SOURCE_USER, SOURCE_ZEROCONF, SOURCE_DHCP]
233+
and entry.data[CONF_USERNAME] == overkiz_entry.data[CONF_USERNAME]
228234
and entry.data[CONF_HUB] == overkiz_entry.data[CONF_HUB]
229-
):
230-
return True
231-
232-
return False
235+
)
236+
for overkiz_entry in overkiz_config_entries
237+
)

0 commit comments

Comments
 (0)