A framework for intelligently controlling heating/cooling devices