Automatic light management

Grumpy_Mike:
Quite literally in a toilet we had at a University I worked at, that would plunge you into total darkness if you spent too long in a “stall” hidden from the PIR sensors. Most inconvenient when it happened at night.

Familiar problem, experienced this before.

The problem is that these rely on movement, not keeping track of actual presence.

There are lots of discussions on this board on how to count people entering/leaving a room, and the general consensus seems to be that it's nigh impossible to do reliably without going visual (and that's out of scope of Arduinos).
Accurately counting passages through the door is hard. How about people coming in very close together, then leaving separately? People turning around in the doorway? You can't put your sensor too low as you start counting double (two legs rather than a single torso) but then you may miss small people (such as children).