Problems turning AC on/off based on door sensor

I followed the code example in the below.
http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Thermostat_conditioned_by_door.2Fwindow

I am having sporadic issues where the AC keeps turning itself off. It usually happens after a door is opened/closed. The door sensor shows that the door is closed but the AC turns to “Off”. If I manually change the thermostat to Auto or Cool, it will turn back to Off in 30-120 seconds. Any ideas what would cause this?