Send an Event when Camera Feed is Viewed

I’ve got a great setup using a Raspberry Pi Zero 2 and an Adafruit spy camera. Octoprint is frigging awesome!

I’d like to turn on the lights in my shop, only when someone is actually viewing the camera feed. Is there anything that be used to detect that? (My lights are MQTT controlled.)

I can code in Python, so just pointing me in the right direction would help.

Thanks all,

A.

hmm..if you want to detect the "viewing" than you need an extra camera with face-tracking :wink: or maybe more suitable: listen for the event ClientOpened.

The event is triggered when someone open the octoprint-browser page.

There is an MQTT Plugin that could handle this out-of-the-box:

If you make sure that also the camera-tab is opened, then you need to handle this with a custom plugin which use javascript to detect the tab-visibility:
Doc: Viewmodels — OctoPrint master documentation

        self.onAfterTabChange = function(current, previous){
            alert("Next:"+next +" Current:"+previous);
            if ("#control" == current){
....
do some javascript handling and call an Web-API or push an MQTT-Message

With the custom solution you could also grab the current username and send this information also to your mqtt-server.

Hope that helps
Olli

1 Like