USB Camera With Home Assistant

Hi there,

I’m new here so please be nice,

I’ve trying to get a USB Camera to show on my Home Assistant Dashboard, I’m using a C920 and the linux can see the device plugged in via USB on port
“Bus 001 Device 007: ID 046d:082d Logitech, Inc. HD Pro Webcam C920”

I have basic knowledge on Home Assistant so ask for any information you need.

This might help:

I’ve come across this before but really don’t know how to install, (i’m a bit of a noob) The Dockerfile looks to be some-kind of a installer. I suppose all i’m asking is how do you run this?

Are you running Hass.io?

No hassbian or Home Assistant

The link I’ve posted is for Hassio only because it works with Docker containers. Sorry…

So with Hassbian there is no way, Maybe I will just stick to IP cameras

I didn’t say that there is no way of doing it on Hassbian… I just know that method on Hass.io.

From what I can tell just looking at it, you need to install the motion application on your RPI and configure it. This will generate a static file based on the configuration file. Then that file can be watched in HomeAssistant using the local file camera component to show the feed. Like I said I haven’t tried it yet, but that seems to be the path. I may try it tomorrow just to figure it out. Then I can watch my 3d printer from HA. :slight_smile:

1 Like

Yeah this sounds like where my research took me, Let me know how it goes! :slight_smile:

Here is what I did today.

Follow instructions on https://pimylifeup.com/raspberry-pi-webcam-server/
I still have Jessie on my RPI so I followed those instructions. I did have to do step 1 uninstalling those packages to get the install to work. that broke ffmpeg for me so AFTER I did the installs I had to re-install ffmpeg (actually avconv with a soft link to ffmpeg) for my cameras using ffmpeg.

Go through the configuration section making the changes there. I did not do the optional changes in step 2, only the required ones.

I haven’t been able to get motion to start from the systemctl command yet, and I have to run it under sudo which is a rights issue I’m sure.

Check your snapshot interval. I have mine set to 5 seconds because I’m just watching myself right now.

Make sure you go in and set your snapshot target directory correctly. I set mine to /home/homeassistant/motion But that’s just what I did you can put yours wherever.

I set my snapshot_filename to snapshot without any variables for date/time, etc. This way I don’t have to worry about cleaning up the directory as it fills up with files. Motion has a soft link called lastsnap.jpg that you can use to access the last snapshot taken. This is what we will use in the HA configuration file. So if you capture more files, it won’t matter since HA is always looking at the last file.

set the webcontrol_localhost to off so you can get to the control settings from a web page other than on the local host.

Since I’m not running a RPI webcam, I stopped after the configuration steps and didn’t go any farther on that page. I was able to go to the web page at http://hassmachine:8081 and see myself so I know everything is working this far.

In HA configuration.yaml

camera:
- platform: local_file
file_path: /home/homeassistant/motion/lastsnap.jpg
name: USB Camera - you can be more creative here I’m sure

go to the configuration page in HA and check your files.
cross your fingers and restart HA.

Give it a try and let me know how it goes.

So I used this walkthrough and got it working first time

https://skalavala.github.io/camera/

I highly recommend this to anyone who wants to get this working to use this

1 Like

The link is dead…

1 Like

I think this is the relevant link now. Just about to follow this guide.

https://blog.kalavala.net/camera/diy/webcam/usbcam/homeassistant/motion/jpeg/binary_sensor/mqtt/raspberrypi/2018/01/11/diy-camera.html