Skip ignored hosts when checking existing config entries in config flow (#34280)
This commit is contained in:
1 parent
8825561a99
commit
ca67fd9faa
2 files changed
+91
-2
No files matched your search
@@ -8,7 +8,12 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.media_player import DEVICE_CLASS_SPEAKER, DEVICE_CLASS_TV
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_ZEROCONF, ConfigEntry
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_IGNORE,
|
||||
SOURCE_IMPORT,
|
||||
SOURCE_ZEROCONF,
|
||||
ConfigEntry,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_ACCESS_TOKEN,
|
||||
CONF_DEVICE_CLASS,
|
||||
@@ -198,8 +203,13 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
# Check if new config entry matches any existing config entries
|
||||
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
||||
# If source is ignore bypass host and name check and continue through loop
|
||||
if entry.source == SOURCE_IGNORE:
|
||||
continue
|
||||
|
||||
if _host_is_same(entry.data[CONF_HOST], user_input[CONF_HOST]):
|
||||
errors[CONF_HOST] = "host_exists"
|
||||
|
||||
if entry.data[CONF_NAME] == user_input[CONF_NAME]:
|
||||
errors[CONF_NAME] = "name_exists"
|
||||
|
||||
@@ -270,6 +280,10 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Import a config entry from configuration.yaml."""
|
||||
# Check if new config entry matches any existing config entries
|
||||
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
||||
# If source is ignore bypass host check and continue through loop
|
||||
if entry.source == SOURCE_IGNORE:
|
||||
continue
|
||||
|
||||
if _host_is_same(entry.data[CONF_HOST], import_config[CONF_HOST]):
|
||||
updated_options = {}
|
||||
updated_data = {}
|
||||
@@ -334,6 +348,10 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
# Check if new config entry matches any existing config entries and abort if so
|
||||
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
||||
# If source is ignore bypass host check and continue through loop
|
||||
if entry.source == SOURCE_IGNORE:
|
||||
continue
|
||||
|
||||
if _host_is_same(entry.data[CONF_HOST], discovery_info[CONF_HOST]):
|
||||
return self.async_abort(reason="already_setup")
|
||||
|
||||
|
||||
Reference in new issue
Block a user