Mjpg-streamer Setup?

I am trying to get mjpg-streamer working on my HASS Raspberry Pi (AIO) setup. The string I have been using to launch is:

/usr/local/bin/mjpg_streamer -i "/usr/local/lib/mjpg-streamer/input_uvc.so" -o "/usr/local/lib/mjpg-streamer/output_http.so -w /var/www/html" -b

…and the light on the camera is turning on, so I think the -i part is working. I think the problem I am having is the -w; I am not sure at all where to point it to for the web server. The path above didn’t work even though it does exist.

Has anyone worked with this and could give me some insight what the parameters would be for a HASS install? (Or if there is a better way…setting up motion was also a big pile of fail, so it feels like getting it to act like an IP camera (which I can get working in HASS) is my best bet.)

I missed a step where you copy the ‘www’ folder that came with the source code someplace more useful. So now it works!

New problem, though: So I’ve written a command_line switch to turn the stream on and off:

- platform: command_line
  switches:
    webcam:
      command_on: "/usr/local/bin/mjpg_streamer -i '/usr/local/lib/mjpg-streamer/input_uvc.so -r 1280x720' -o '/usr/local/lib/mjpg-streamer/output_http.so -w /usr/local/www -p 8889' -b"
      command_off: "killall mjpg_streamer"

But I want a command_state as well. The following will return a PID if it finds the process running and nothing if it isn’t:

pgrep -f mjpg-streamer

How do I turn that into either a command_state or a value_template so the switch will set itself on if the process is started through other means?

2 Likes