One may not enter a room where doing so automatically turns on the lights or air conditioning. While one might claim that he did not intend to turn on the lights or air conditioning by entering the room, the fact is that everyone knows how the system works in such places.
This problem is common in hotel rooms and bathrooms. One who stays in such a hotel must make sure that the system is switched off before Shabbat. If he did not take care of this in advance and is outside his room when Shabbat begins, he may ask a non-Jew to open the door for him. He should further ask the non-Jew to stay for a bit so that the non-Jew will benefit from the lights or air conditioning, since he is then viewed as having turned them on for his own sake, and the Jew may then benefit from them (below, 25:2).
What if the hotel guest is inside such a room when Shabbat begins, and he knows that if he leaves he will cause the lights or air conditioning to shut off? If he can easily stay inside until after Shabbat, or if a non-Jew is due to come shortly to disable the system, it is preferable to wait inside. However, if doing so causes him anguish, he may leave the room or bathroom because the purpose of this system is to save the hotel money by conserving electricity. The hotel guest does not care about that, so it is a case of psik reisha de-lo niĥa lei regarding a rabbinic prohibition (since all agree that the prohibition of turning off the lights or air conditioning is rabbinic). When necessary, in such a case, one may be lenient (above, ch. 9 n. 2).
However, as we saw earlier, once the guest has left his room he will not be able to return to it, because doing so will turn on the lights and air conditioning. The only way for him to re-enter would be with the help of a non-Jew. Therefore, the proper course of action in this case is to ask a non-Jew to disable the system. Then the guest will be able to enter and exit the room as needed.