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:
Erik Montnemery 2022-05-30 14:21:20 +02:00 committed by GitHub
parent 42bcd0263c
commit 342ccb5bf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 11 deletions

View file

@ -685,9 +685,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# User has configuration.yaml config, warn about config entry overrides
elif any(key in conf for key in entry.data):
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:
override[CONF_PASSWORD] = "********"
if override:
_LOGGER.warning(
"Deprecated configuration settings found in configuration.yaml. "
"These settings from your configuration entry will override: %s",

View file

@ -1715,11 +1715,6 @@ async def test_update_incomplete_entry(
"The 'broker' option is deprecated, please remove it from your configuration"
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
async_fire_mqtt_message(hass, "homeassistant/sensor/bla/config", data)