I had the same issue on my 05. It would do it at the wierdest times. Mostly when it was cold and I went to leave my house.
I was also told NSBU switch. Had it replaced and problem still there.
I also had a bad smoking problem. Edge Juice and it smoked like a PPE Hot+2 but was down on power. It was not listed in your sig, but is your EGR blocked?
I know this sounds crazy, but I blocked my EGR and both problems went away. I can understand it stopping the smoke, but the trans issue has me floored. I have been two months and my truck has not shown range shift. Before the block, it was doing it about every other day.
Only other thing that has been changed, is the number 7 injector wire by dealer. After that though I still had the smoke, but it didnt do the range shift thing. 2 days after the wire fix is when I blocked the EGR. May not have given it enough time after the dealer for the trans to act up.