Binary Sensor and Rotary Encoder using same pin

Daughter and I are building a chicken door. We have two IR beams on the door. The are both set up as GPIO binary sensors so that we can use them a obstacle sensors for a feedback cover. We would like to use the two inputs with a rotary encoder so that we can track number of chickens in the coop.

We have added allow_other_uses: true to the both sets of pin definitions.

Code compiles fine and rotary encoder works for one count then stops. Both GPIO binary sensors continue to work fine.

Adding a 3rd IR beam would add a lot of extra parts that we’d like to avoid. We only need to use rotary encoder when the door is open, and only need the GPIO binary sensor as an obstacle sensor when the door is closing.

I can’t think of a solution. Wondering if there would be a way to substitute a binary sensor for pin in rotary encoder?

Any ideas would be appreciated!

I read twice your post, but I still can’t imagine your setup. You could post a drawing of your setup and an image or link of your encoder.