Lammā here marks time and succession with a conditional flavor. ʿAraftu is a past verb, its -tu ending is the first-person subject, and al-dāra is the direct object. Qultu reports the action that follows recognition.
In li-rabʿihā, rabʿ is governed by the preposition lām, and -hā refers back to the mentioned dwelling. The grammatical sequence is unambiguous: first inspection and recognition, then address and greeting.