I’ve installed the Pi camera behind the mirror and it allows motion detection to turn on-off the monitor.
https://forum.magicmirror.builders/topic/988/motion-detection-with-raspicam-non-module-version
As suggested by Bhelper I start it with pm2 and the result is just … perfect!