For instance, add a pressure sensor under the bathmat (or seat) in front of the toilet so that the turn-off timer doesn't run while it senses pressure. Alternatively, maybe infrared heat sensor or CO2 sensor to detect presence of living mammals in the room. But both of these approaches can be messed up by your cat/dog spending all day/night laying on the bathroom mat keeping the lights on.
The cool thing about building your own smart home is you can design system to do anything on any kind of assumption. The bad part is you're turning your home into an test of your engineering design prowess, and most part-time novices aren't going to be super happy with how they score... especially if their score ends up being an input to their home valuation.