Not Buddha but Ven. Sariputta gives a talk here
[Ven. Sariputta:] "Then, householder, you should train yourself in
this way: 'I won't cling to the eye; my consciousness will not be
dependent on the eye.' That's how you should train yourself. 'I won't
cling to the ear... nose... tongue... body; my consciousness will not
be dependent on the body.' ... 'I won't cling to the intellect; my
consciousness will not be dependent on the intellect.' That's how you
should train yourself.
"Then, householder, you should train yourself in this way: 'I won't
cling to forms... sounds... smells... tastes... tactile sensations; my
consciousness will not be dependent on tactile sensations.' ... 'I
won't cling to ideas; my consciousness will not be dependent on
ideas.' That's how you should train yourself.
"Then, householder, you should train yourself in this way: 'I won't
cling to eye-consciousness... ear-consciousness...
nose-consciousness... tongue-consciousness... body-consciousness; my
consciousness will not be dependent on body-consciousness.' ... 'I
won't cling to intellect-consciousness; my consciousness will not be
dependent on intellect-consciousness.' That's how you should train
yourself.
"Then, householder, you should train yourself in this way: 'I won't
cling to contact at the eye... contact at the ear... contact at the
nose... contact at the tongue... contact at the body; my consciousness
will not be dependent on contact at the body.' ... 'I won't cling to
contact at the intellect; my consciousness will not be dependent on
contact at the intellect.' That's how you should train yourself.
"Then, householder, you should train yourself in this way: 'I won't
cling to feeling born of contact at the eye... feeling born of contact
at the ear... feeling born of contact at the nose... feeling born of
contact at the tongue... feeling born of contact at the body; my
consciousness will not be dependent on feeling born of contact at the
body.' ... 'I won't cling to feeling born of contact at the intellect;
my consciousness will not be dependent on feeling born of contact at
the intellect.' That's how you should train yourself.
"Then, householder, you should train yourself in this way: 'I won't
cling to the earth property... liquid property... fire property...
wind property... space property; my consciousness will not be
dependent on the space property.' ... 'I won't cling to the
consciousness property; my consciousness will not be dependent on the
consciousness property.' That's how you should train yourself.
"Then, householder, you should train yourself in this way: 'I won't
cling to form... feeling... perception... thought-fabrications; my
consciousness will not be dependent on thought-fabrications.' ... 'I
won't cling to consciousness; my consciousness will not be dependent
on consciousness.' That's how you should train yourself.
"Then, householder, you should train yourself in this way: 'I won't
cling to the dimension of the infinitude of space... the dimension of
the infinitude of consciousness... the dimension of nothingness; my
consciousness will not be dependent on the dimension of nothingness.'
... 'I won't cling to the sphere of neither perception nor
non-perception; my consciousness will not be dependent on the sphere
of neither perception nor non-perception.' That's how you should train
yourself.
"Then, householder, you should train yourself in this way: 'I won't
cling to this world; my consciousness will not be dependent on this
world... I won't cling to the world beyond; my consciousness will not
be dependent on the world beyond.' That's how you should train
yourself.
"Then, householder, you should train yourself in this way: 'I won't
cling to what is seen, heard, sensed, cognized, attained, sought
after, pondered by the intellect; my consciousness will not be
dependent on that.' That's how you should train yourself."
When this was said, Anathapindika the householder wept and shed tears.
Ven. Ananda said to him, "Are you sinking, householder? Are you
foundering?"
"No, venerable sir. I'm not sinking, nor am I foundering. It's just
that for a long time I have attended to the Teacher, and to the monks
who inspire my heart, but never before have I heard a talk on the
Dhamma like this."
"This sort of talk on the Dhamma, householder, is not given to lay
people clad in white. This sort of talk on the Dhamma is given to
those gone forth."
"In that case, Ven. Sariputta, please let this sort of talk on the
Dhamma be given to lay people clad in white. There are clansmen with
little dust in their eyes who are wasting away through not hearing
[this] Dhamma. There will be those who will understand it."
Then Ven. Sariputta and Ven. Ananda, having given this instruction to
Anathapindika the householder, got up from their seats and left. Then,
not long after they left, Anathapindika died and reappeared in the Tusita heaven. Mn143