diff --git a/homeassistant/components/mqtt/config_flow.py b/homeassistant/components/mqtt/config_flow.py index d83b88540b2..b3c82dce65e 100644 --- a/homeassistant/components/mqtt/config_flow.py +++ b/homeassistant/components/mqtt/config_flow.py @@ -526,8 +526,7 @@ def validate_light_platform_config(user_data: dict[str, Any]) -> dict[str, str]: if user_data.get(CONF_MIN_KELVIN, DEFAULT_MIN_KELVIN) >= user_data.get( CONF_MAX_KELVIN, DEFAULT_MAX_KELVIN ): - errors[CONF_MAX_KELVIN] = "max_below_min_kelvin" - errors[CONF_MIN_KELVIN] = "max_below_min_kelvin" + errors["advanced_settings"] = "max_below_min_kelvin" return errors @@ -1381,7 +1380,10 @@ def validate_user_input( try: validator(value) except (ValueError, vol.Error, vol.Invalid): - errors[field] = data_schema_fields[field].error or "invalid_input" + data_schema_field = data_schema_fields[field] + errors[data_schema_field.section or field] = ( + data_schema_field.error or "invalid_input" + ) if config_validator is not None: if TYPE_CHECKING: diff --git a/tests/components/mqtt/test_config_flow.py b/tests/components/mqtt/test_config_flow.py index 81d4960be23..4cfc416c3c9 100644 --- a/tests/components/mqtt/test_config_flow.py +++ b/tests/components/mqtt/test_config_flow.py @@ -2858,14 +2858,22 @@ async def test_migrate_of_incompatible_config_entry( }, {"state_topic": "invalid_subscribe_topic"}, ), + ( + { + "command_topic": "test-topic", + "light_brightness_settings": { + "brightness_command_topic": "test-topic#invalid" + }, + }, + {"light_brightness_settings": "invalid_publish_topic"}, + ), ( { "command_topic": "test-topic", "advanced_settings": {"max_kelvin": 2000, "min_kelvin": 2000}, }, { - "max_kelvin": "max_below_min_kelvin", - "min_kelvin": "max_below_min_kelvin", + "advanced_settings": "max_below_min_kelvin", }, ), ),