sleevezipper / hass-workstation-service

Provide useful sensors and services from your workstation to Home Assistant.
Apache License 2.0
613 stars 54 forks source link

A sensor to report webcam usage #1

Closed sleevezipper closed 3 years ago

sleevezipper commented 3 years ago

Several Reddit users want a sensor to show if their webcam or mic is being used.

Link to comments

sleevezipper commented 3 years ago

I have found a possible solution using OpenCV. It tries to grab an image from the webcam. If that succeeds, the webcam is not in use. If it fails, webcam is in use. A drawback is that every time it tries to grab an image, the webcam activity light turns on for a second.

sleevezipper commented 3 years ago

The solution I mentioned earlier is not something I'm happy with and I came up with another workaround: A sensor that returns true if a window with a configured name is found, and false if not. This could be used to check for windows with names like Microsoft Teams, Jitsi or Google Meet. It's not perfect but I think it is a more versatile alternative to the ActiveWindow sensor.

I might also still release the solution I'm not happy with as it may be useful to some people.

sleevezipper commented 3 years ago

I was informed about a collection of registry keys that could be used to determine if the webcam or microphone are in use. See here. Weirdly enough these keys don't appear on my system. I'll have another look at this soon.

sleevezipper commented 3 years ago

Both webcam and microphone sensors have been implemented and will be in the next release.