To get the PIR sensor working with MM on the currently latest Raspberry PI OS Bullseye you can use
/usr/bin/vcgencmd display_power 0/1 instead of using the tvservice command (I run it in a script started by crontab at reboot).
/usr/bin/xrandr -display :0.0 --autobefore the vcgencmd command
- added user Pi to the gpio group:
sudo usermod -a -G gpio pi, and I
sudo vi /etc/environment
My mirror uses a DVI to HMI output, but using
XAUTHORITY as above solved the issues I had.
Btw, I use
/usr/bin/chvt 6 /usr/bin/chvt 7
/usr/bin/vcgencmd display_power 1 command, but that was used prior to using Bullseye as well.