Take a look at the copy in the court. If it is not verified, you may bring a motion to strike. If the proper notices were neither attached nor referred to, you can bring a motion to quash or a motion to strike (probably both). If the complaint said that the lease and notice were attached as an exhibit but were not, you should bring a demurrer on the grounds of uncertainty.
You are right that, if renting the unit was unlawful, you owe no damages. But it also means that you should not have been there in the first place, so the court will enter a judgment for possession only in the landlord's favor.
Most likely, you would be initially filing a Motion to Quash. (It's not really possible to ascertain the best strategy without having analyzed the actual Complaint for Unlawful Detainer).
If and when you file an Answer (after the Motion to Quash is heard), you would raise the lack of certificate of occupancy as a defense.
Frank W. Chen has been licensed to practice law in California since 1988. The information presented here is general in nature and is not intended, nor should be construed, as legal advice for a particular case. This Avvo.com posting does not create any attorney-client relationship with the author. For specific advice about your particular situation, please consult with your own attorney.
The best way to do is seeking a help from self help center at court house or from Pro Bono organizations like Pro Bono Project Silicon valley or legal aid. Because the motion procedure is complicated and only attorneys can help you with that.
DISCLAIMER—This answer is for informational purposes only. It doesn't constitute legal advice. This answer doesn't create attorney client relationship.