Improve handling of MQTT overridden settings (#72698)
* Improve handling of MQTT overridden settings * Don't warn unless config entry overrides yaml
This commit is contained in:
parent
42bcd0263c
commit
342ccb5bf1
2 changed files with 7 additions and 11 deletions
|
@ -685,14 +685,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
# User has configuration.yaml config, warn about config entry overrides
|
# User has configuration.yaml config, warn about config entry overrides
|
||||||
elif any(key in conf for key in entry.data):
|
elif any(key in conf for key in entry.data):
|
||||||
shared_keys = conf.keys() & entry.data.keys()
|
shared_keys = conf.keys() & entry.data.keys()
|
||||||
override = {k: entry.data[k] for k in shared_keys}
|
override = {k: entry.data[k] for k in shared_keys if conf[k] != entry.data[k]}
|
||||||
if CONF_PASSWORD in override:
|
if CONF_PASSWORD in override:
|
||||||
override[CONF_PASSWORD] = "********"
|
override[CONF_PASSWORD] = "********"
|
||||||
_LOGGER.warning(
|
if override:
|
||||||
"Deprecated configuration settings found in configuration.yaml. "
|
_LOGGER.warning(
|
||||||
"These settings from your configuration entry will override: %s",
|
"Deprecated configuration settings found in configuration.yaml. "
|
||||||
override,
|
"These settings from your configuration entry will override: %s",
|
||||||
)
|
override,
|
||||||
|
)
|
||||||
|
|
||||||
# Merge advanced configuration values from configuration.yaml
|
# Merge advanced configuration values from configuration.yaml
|
||||||
conf = _merge_extended_config(entry, conf)
|
conf = _merge_extended_config(entry, conf)
|
||||||
|
|
|
@ -1715,11 +1715,6 @@ async def test_update_incomplete_entry(
|
||||||
"The 'broker' option is deprecated, please remove it from your configuration"
|
"The 'broker' option is deprecated, please remove it from your configuration"
|
||||||
in caplog.text
|
in caplog.text
|
||||||
)
|
)
|
||||||
assert (
|
|
||||||
"Deprecated configuration settings found in configuration.yaml. These settings "
|
|
||||||
"from your configuration entry will override: {'broker': 'yaml_broker'}"
|
|
||||||
in caplog.text
|
|
||||||
)
|
|
||||||
|
|
||||||
# Discover a device to verify the entry was setup correctly
|
# Discover a device to verify the entry was setup correctly
|
||||||
async_fire_mqtt_message(hass, "homeassistant/sensor/bla/config", data)
|
async_fire_mqtt_message(hass, "homeassistant/sensor/bla/config", data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue