If the cabin temperature controller does not function, does the pilot have to make an emergency landing?
I'll use the B757 as an example, on it you would not divert due to temperature control issues. In fact the Master Minimum Equipment List items 21-61-1 and 21-61-2 give permission to dispatch the aircraft with inoperative zone temperature control. 

The Quick Reference Handbook (PDF) for the 757 gives the following instructions for failure of zone temperature control.





I also think most airlines and crew think passengers would rather get to where they are going than being comfortable. 

As for the emergency landing, aircraft can and do divert all the time without declaring an emergency (Mayday) or urgency (Pan-Pan). So worse case the crew would choose to divert to a suitable airport.