Reduce boilerplate to abort for matching config entries (#50186)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
J. Nick Koston 2021-05-11 15:00:12 -05:00 committed by GitHub
parent d6a202bd74
commit 34c84a6bbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 183 additions and 350 deletions

View file

@ -47,13 +47,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
for entry in self.hass.config_entries.async_entries(DOMAIN):
if (
entry.data[CONF_HOST] == data[CONF_HOST]
and entry.data[CONF_PORT] == data[CONF_PORT]
):
raise AbortFlow("already_configured")
self._async_abort_entries_match(
{CONF_HOST: data[CONF_HOST], CONF_PORT: data[CONF_PORT]}
)
camera = FoscamCamera(
data[CONF_HOST],