Defect passivation has been recognized as an efficient strategy to boost the performance of perovskite solar cells (PSCs) for commercial applications. However, most reported strategies overly emphasize passivation of undesirable defects, while ignoring the inherent instability of perovskite materials caused by environmental risks. In this study, we explore a groundbreaking strategy to integrate various functions of defect passivation, photoresponsivity and photocontrolled hydrophobicity in one device via the surface engineering of 7-amino-4-trifluoromethylcoumarin (C151). The detailed experiments demonstrate that C151 based PSCs have regulated power conversion efficiency and stability responding to UV illumination due to the photodimerization of coumarin. On the one hand, the photodimer of C151 (C151-L) can form stronger chelation with various defect sites in comparison with C151, resulting in optimized energy level arrangement, superior charge extraction/transport and significantly inhibited nonradivation recombination. One the other hand, morphological changes of the perovskite film triggered by UV illumination also bring convertible surface hydrophobicity transition. As a result, the unpackaged C151-L modified device exhibits excellent stability maintaining 91% of its initial PCE after aging for 1000 h under a relative humidity of 30%–40% at 20 °C. Moreover, C151-L plays a positive role in improving the operation stability against high humidity, continuous UV radiation, and heating stress. This work may offer more choices for materials with tunable properties in high-efficiency optoelectronic devices.