Defect chemistry of lone-pair semiconductors