@SBDOBRESCU, that’s quite complicated for a regular ST user. My zoned Heating/Cooling Solutions (and even the newly released KeenVentManager) can do that in a much easier & configurable way.
It’s part of the room setup. For each room where you want to take into account the room occupancy, you just need to define the room’s motion sensor, the occupancy flag (to be set to true), and the occupied threshold in minutes (optional).
The occupied threshold is set at 15 minutes by default, but you can change it to any value you want, and this is configurable on a room-by-room basis.
That’s it, you do not need to define a virtual swich and use Smart Lighting (which is not perceived as reliable according to some user feedback I’ve seen in the forum).