In my opinion, ultrasonic repellents are the most safe for nature. In addition, some of them scare away not only mice and rats, but also insects. They do not require refilling chemicals, only electricity. There are devices for cars. For example, Vensmile Under the Hood Electronic Rat Repeller for Cars. Read this article https://smartratcontrol.com/best-ultrasonic-rat-repellents/ . It describes the most successful device models.
RE: The Principle of Rat