Vacancy automation for already-vacant room

I would like to create a vacancy automation for an already-vacant room. Can this be done?

I understand the premise of the SmartThings automation trigger “when things quiet down”: that means when motion sensors do not detect motion or occupancy for a specified period of time.

However, I would like to have an automation (turning off the Lutron Caseta light switches in a bathroom) trigger when the room transitions from an occupied to an unoccupied state, after a certain timeout, and when the room’s lights are turned on while the room is unoccupied (for example, turned on remotely) and remains unoccupied for the specified duration.

How do I set up this automation?

I am on Hub v2 and am using the SmartThings Classic app. The sensors that I could use include the Samsung SmartThings Motion Sensor (2018 GP-U999SJVLBAA), and the ecobee room sensors (EB-RSE3PK2-01). The ecobee room sensors have quite a bit of lag time, so they are not good for detecting occupancy to turn lights on, but they work perfectly fine for vacancy sensing purposes to turn the lights off.

For really complex stuff like this youll probably want either WebCoRE and /or a smartapp like Bangali’s Rooms Manager: Rooms Manager: Smarter Rooms: Personalized home automation with Occupancy