There used to be several different project approaches to solving this problem, but to be honest, beginning at the end of 2022 most people just started using millimeterwave radar occupancy sensors. These are fairly inexpensive now, there are several companies offering them for around $85, and one will cover an entire room with up to 30 different zones. they work regardless of the local temperature, lux level, or humidity level, which makes them useful in a number of rooms like bathrooms and laundry rooms where traditional PIR sensors didn’t work and cameras were not desirable for privacy reasons.
Traditional PIR (passive infrared) sensors could only detect large movements like a person walking, so they led to the problem of lights being turned off prematurely, because they could not detect fine movements like someone eating at a table or typing. And they could not detect very fine movements, like someone breathing.
MMWave sensors can detect both, so they can even know when someone is sleeping in a bed versus the bed being empty.
If you have your own reasons for wanting to design a multi device, custom software option, it could be a fun project, and I will leave that to others to discuss the various pieces of it.
But if you just want to solve the use case of keeping the lights on when people are still in a room, I would look into the MMwave sensors. There’s one from aqara (the FP2) that’s getting a lot of buzz right now, and two from Tuya, and I’m pretty sure there’s an edge driver for at least one of those.
(Alternatively, both companies have promised Matter support eventually, so in a few months you might be able to buy one, connect it to its own inexpensive hub, then bring the device into smartthings that way. That’s not here yet, though.)
As for a virtual device with a timer, yes, there are some. Check the quick Browse lists in the community – created wiki, and look for the list for virtual devices.