Is there any way to prevent it so that no caterpillar enters in the room?
Prevention of Caterpillars
Certified GKH Gardening Expert
Anything you can do to attract predators that eat caterpillars to the outside of your house will help. For example, you could provide bird seed or plant attractive flowers to bring in beneficial insects. You could also use an organic or synthetic insect repellent around your house:
Or if you wish to use an insecticide see this article: