Using USB webcams with Home Assistant

In this blog post I am using a Fedora 24 (will most likely work on other distributions too) installation with Home Assistant 0.22.1 on a Foxconn nT-330i with an old Logitech QuickCam Orbit AF
Check first if the your operating system lists your cameras.
The camera we are going to use is available at /dev/video1
. The C270 is the one on /dev/video0
.
We need an additional software part to handle the cameras. motion
For our setup we need to modify the file /etc/motion/motion.conf
. For now the most important parameters are videodevice
, snapshot_interval
, and target_dir
. The other settings can be left to their defaults. We are going to use the device /dev/video1
, use a 30 seconds interval, and set the path to /tmp
.
It’s suggested that you adjust at least width
and height
to get a bigger image from your camera. If you are done, fire up motion
.
Your target_dir
will start filling up with images from your camera. motion
will create a symlink called lastsnap.jpg
which always point to the latest snapshot. We will setup the Local File camera platform to use this file.
The "Cranberry cam" in action
The machine with the attached USB camera will become a webcam server as well because motion
’s built-in HTTP server is enabled by default. This means that you could connect your USB webcams to a different machine in your network, run motion
there, adjust your firewall rules, and use Home Assistant to display the videos. Just check http://[IP of your webcam host]:8081/
to see the stream. This required more powerful hardware than using snapshots, of course.
In a scenario like this needs a Generic MJPEG IP Camera in your configuration.yaml
file.
motionmotion
to unleash its potential.