Section 1941.2 is the counterweight to §§ 1941 and 1942, and it is drafted as a condition rather than as a list of tenant duties for their own sake. Subdivision (a) says no duty to repair arises under § 1941 or § 1942 if the tenant is in substantial violation of any of the listed obligations — but only provided that violation contributes substantially to the existence of the dilapidation, or interferes substantially with the landlord's ability to do the repairs. Both halves have to be true. A tenant who keeps a messy flat has not thereby released the landlord from fixing an unrelated roof leak.
The obligations themselves are five: to keep the occupied part of the premises clean and sanitary as its condition permits; to dispose of rubbish, garbage and waste in a clean and sanitary manner; to use and operate the electrical, gas and plumbing fixtures properly and keep them clean and sanitary as their condition permits; not to destroy, deface, damage, impair or remove any part of the structure, dwelling unit, facilities, equipment or appurtenances, and not to permit anyone on the premises with permission to do so; and to use the premises as a home, using each part only for the sleeping, cooking, dining or living purpose it was designed for.
Subdivision (b) removes the first two obligations where the landlord has expressly agreed in writing to perform them — the cleaning-service case. The section is the provision landlords cite most often when a habitability complaint is made, and the words that decide those arguments are "substantial violation" and "contributes substantially": both are questions of degree and causation about a particular defect, and both are worth putting to a lawyer with the facts rather than settling from the text.