Camera Setup

From Domoticz
Jump to: navigation, search

Adding Cameras to Domoticz

In Domoticz you can add cameras that you can use to take snapshots when an event happens.

To add a Camera to Domoticz go to 'Setup -> More Options -> Camera'

The basic setup exists of:
- IP Address of the Camera
- Port
- Username
- Password
- Image (snapshot) URL

Note: If your camera Image URL needs to define a USERNAME and/or PASSWORD, you can use the #USERNAME and #PASSWORD tags like:

IP Camera

Actual list of ImageURLs for IP cameras you can find on our wiki page Hardware#IP-networkcameras.
Please refer to your camera manual/model for the settings.

For almost every IP cam you can also find settings here: iSpy Connect database

For 'clone' IP cams or other unknown Chinese cameras you might need to try out a few different URLs.
F.i. for Foscam clones you need to try some of the official Foscam URLs.
Also try out the full URLs in the webbrowser first. If they work there, they will likely work in Domoticz.
If they do not work in the browser, they will definitely not work in Domoticz.

For example a Foscam camera setup could be:
IP Address

Foscam FI9805EP

Notice the number 2 as snapPicture2 in the imageURL below, it is easy to overlook it, without it snapshot will work in browsers, and that can be misleading, but wont work in domoticz.

IP address: my IP address
Port: 88
Username: blank
Password: blank
ImageURL: cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=#USERNAME&pwd=#PASSWORD

Foscam FI9821W V2

To setup a Foscam FI9821W V2 enter the following:
IP address: the address of the IP camera (e.g.
Port: 88
Username: xxxx
Password: xxx
ImageURL: cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=#USERNAME&pwd=#PASSWORD

Remark 1
Port 88 is the default port.

Remark 2
In the Foscam camera setup leave Snapshot Settings / Image Quality to Medium or Low. In the High setting the snapshot is broken. The bottom half of the photo is blank....
This bug is identified in the version below (and the versions before this one):
System Firmware Version:
App Firmware Version:
Web version: 2.0.11

Remark 3
It seems the Foscam software does not allow passwords longer than 12 characters.

Remark 4
These instructions are for version 2 (V2). For other Foscam models try this page:

Y-Cam Cube HD (720/1080)

To setup a y-Cam Cube HD enter the following:
IP address: the address of the IP camera (e.g.
Port: the port of the IP Camera (e.g. 88)
Username: <username of the IP cam>
Password: <password of the IP cam>
ImageURL: snapshot.jpg

Dahua IPC-HDW4100SP-0360B

To setup the Dahua enter the following:
IP address: the address of the IP camera (e.g.
Port: the port of the IP Camera (e.g. 9989)not 80
Username: <username of the IP cam>(admin)
Password: <password of the IP cam>(admin)

Axis 221/211

To setup a Axis 221/211 enter the following:
IP address: the address of the IP camera (e.g.
Port: the port of the IP Camera (e.g. 80)
Username: <username of the IP cam>
Password: <password of the IP cam>
ImageURL: axis-cgi/jpg/image.cgi


CGI API documentation PDF

To setup a Sunell IP camera enter the following:
IP address: the address of the IP camera (e.g.
Port: the port of the IP Camera (e.g. 80)
Username: <username of the IP cam>
Password: <password of the IP cam>
ImageURL: cgi-bin/image.cgi?userName=#USERNAME&password=#PASSWORD&cameraID=1&quality=1

Raspberry PI Camera

To setup a raspberry pi camera, make sure that the device is enabled in the raspberry pi setup:

sudo raspi-config, enable camera
Test if the camera can take correct snapshots with the command:

raspistill -o test.jpg

For more information please visit:

To add the camera in domoticz use the following parameters:
IP Address: Your domoticz server IP address

USB Camera

To setup a USB camera, make sure that the device is working, and you can take a snapshot with the command:

uvccapture -S80 -B128 -C128 -G80 -x800 -y600 -otest.jpg -q100
Installation on raspbian
sudo apt-get install uvccapture

To add the camera in domoticz use the following parameters:
IP Address: Your domoticz server IP address

Plug-in Version:

Using your camera as motion sensor

This chapter describes how to set up motion detection using your camera and raspbian/debian/ubuntu box. Works on Raspberry Pi but read notes on performance in the "Some notes" paragraph. Howto by Safi78.


Motion is a package that's been around for a long time, it's very good, very well documented (find it here)
You can configure your 'video'-devices (ip, usb, tvcards, etc) in different config-files and include them in the main-config file. You can put your central settings in one file and overrule or specify different values in extra config-files for individual cameras. This leads to a nice centralized set up server / ip-cam configuration.
As a little bonus, I added a 'dummy' motion sensor in Domoticz for each ip-cam and switch that with the use of the api-commands to "On" if there's motion detected and "Off" when the motion is stopped. You basically get (VERY) reliable motion-sensors for further logic in the basic webinterface, blockly or LUA.
Basically you point motion to your ip-cam's snapshot URL (different for each brand, model, so not going in to that 'standard'), motion looks into the snapshots, compares them, determines if there's motion based on your thresholds and can glue the relevant snapshots together as a recording to a directory you specify.

Install the motion package

ssh into your debian/ubuntu/raspbian box and run:

sudo apt-get install motion

This will install the package and all its dependencies.
After this the daemon will be disabled by default in /etc/default/motion so you'll have to change that.

sudo nano /etc/default/motion

change the configuration to this and save the file:

# set to 'yes' to enable the motion daemon

Now the daemon can be started & will be started at boot time:

sudo /etc/init.d/motion start

and now it does... nothing. Continue with "Configure the config files".

Configure the config files

The files that are actually important for configuration are:

  • The main configuration file motion.conf. If you only use one ip-cam all configuration goes in here:


  • The extra configuration files, if you use more than one ip-cam, you put all the central configuration in 'motion.conf' and include these at the end for each cam you want to setup, these files are more or less the same and will override the settings you specify explicitly for each cam in each file.

By default these files are created:

and can be included at the end of the central motion.conf. You can specify your own names (which is very handy if you have more than a few files, you will always know which ip-cam you are configuring if you give the files a useful name like: cam_frontdoor.conf or something like that). But make sure to include these files in motion.conf with the correct names or it will not work of course.
The config files are very well documented, so they look huge, but don't be scared, it's mostly useful comments about the settings you are changing.
Just start with motion.conf and change everything you need, except the individual ip-cam settings. For instance if you want to use the same motion detection settings or folders where motion will output the files, put them in here.
For each individual setting, put it in a separate config file and just include them all the at the end of the file.
For example, you want to use the same video_codec for each output file, but you want to specify different resolutions for the individual webcams you put it like this:


ffmpeg_video_codec mpeg4


width 640
height 480


width 1280
height 720

Make sure that after every change of a config-file you issue:

sudo /etc/init.d/motion restart

to load the new settings.
Of course you will need a lot of other stuff in your config file, ipaddres of your ip-cams, username & password to access your snapshot URL's, directories where to put the recordings, but that's all pretty self-explanatory.
Also see the URL at the beginning a lot of settings you'll find out just reading the config files, but the Wiki is very useful as well.
You can fiddle around with the sensitivity, light bursts, tell motion how many pixels need to change before actual motion is detected (e.g. find out how much pixels your cat is, put that in the file and it will not trigger motion on your cat ;)), exclude certain areas, specify how long a minimal motion-event should be, how many frames before and after should be included, how long after motion the motion-event should end, etc etc.

Setup a new dummy motion-sensor in Domoticz

This would be the (really cool) part:
If you add the 'Dummy' hardware to 'Setup -> Hardware' in Domoticz you are able to add dummy switches and sensors.
Add a dummy motion-sensor and find the 'ID' in 'Setup -> Devices' in Domoticz, you'll need that to switch the virtual motion-sensor through the API-commands.
Now find one of your ip-cams you want to communicate with the dummy motion-sensor and add the following two lines and change the bold parts to suit your needs:


on_event_start /usr/bin/curl -s "http://api_username:api_password@domoticz_server:domoticz_port/json.htm?

on_event_end /usr/bin/curl -s "http://api_username:api_password@domoticz_server:domoticz_port/json.htm?

The on_event_start will switch your motion-sensor on at motion detection.
The on_event_end will switch it off again.
And it all works together very well, because Domoticz & motion will 'access' the IP-camera at the URL's you specify for the needed screenshots, but they will not interfere:
1. You can still use your cam in Domoticz (e.g. take a snapshot of your Doorbell-event and send it with mail).
2. The cam streams can be saved to a NAS if you want that, with the settings you specify.
3. The motion-sensors will switch on and off for use within Domoticz as well. You can use it in the normal web-interface, blockly or LUA, endless possibilities.

Some notes

  • CPU: I use a dedicated, pretty good server for multiple webcams. I think a raspberry can handle one ip-cam, but it's very CPU-hungry, so I wouldn't recommend a pi for this kind of load. (100Mbps, CPU slow, etc).
  • I know of a motion 'light' package that exists for the Raspberry Pi Cam you hook into the motherboard that's tuned for the rasp, it's available from this thread. I did test that, worked very well, if I recall correctly it had a 20% CPU load.
  • Storage: next to that, use a NAS or a big drive to store your files, because the recordings can add up and eat away your drive space pretty fast!
  • Bandwith: ofcourse it's going to use a constant stream per cam, which can really up the traffic on your network.
  • Pets: it's very reliable and tunable and will detect motion if there is. That also means dogs, canaries and goldfish.
  • If you're having problems with taking snapshots when using motion, and you can live without motion detection, you may wish to use uvccapture (details can be found in the USB Camera section above)

Using your camera as sound sensor

This section describes how to use your network camera to detect sounds above a certain threshold. Many webcams have a built in microphone which can be accessed via a specific URL.

Installing the software

Assuming you have node and npm installed, all you need to do is run:

   sudo npm install -g domoticz-sound-detection

Configuring Domoticz

Add a dummy switch and take a note of the IDX value. As a bonus I changed the icon to a speaker so I can get a visual representation of when the noise threshold has been reached.

Running the software

If you run 'domoticz-sound-detection' you will see a list of command line arguments, the most important is -u and -i which can be used to configure the URL of the audio feed and the ID of the switch in Domoticz.

   -h, --help              output usage information
   -V, --version           output the version number
   -u --url <url>          Set the URL to the IP Camera
   -i --idx <n>            ID of switch in Domoticz
   -b --bit-depth <n>      Bit depth of audio stream [16]
   -c --channels <n>       Number of Channels [1]
   -t --trigger-level <n>  Number of dB above ambient before triggered [30]

For example for my webcam which provides a 16 bit PCM mono stream:

   domoticz-sound-detection -u http://mycam/audio.cgi -i 33

This will set the dummy switch to on for 1 second everytime a sound is heard 30dB above the ambient noise level. The software will adapt to the background noise, the trigger level for an event can be adjusted by using the -t option in the command line.

Domoticz API Access

The sound detection software assumes Domoticz is running on the localhost and can access the API without using a username and password.

Feel free to send a PR to

Suggested Recipes

This could be used to trigger lights in a bedroom if your baby wakes up crying, or alternatively trigger the camera to start taking snapshots.