With break beam sensors and some sensor logic you should be able to detect "just peaking out".
Two beams, beam 1 on the inside, beam to on the outside of the door frame.
Moving through (I assume body/head height - not leg height)
Break sensor 1, break sensor 2, some time both broken, then return sensor 1, return sensor 2.
Peeking out:
Break sensor 1, break sensor 2, some time both broken, then return sensor 2, return sensor 1.
The order in which the beams come back up tells you the direction the animal moves. Ignore any situation where just one beam breaks, have your sketch start paying attention only when both are actually broken.
This works as there is one and only one animal that can break the beams. You may want to add some user override button or so for when the wife is home and she walks in and out as well.