Camera Setup

From Domoticz
Jump to navigation Jump to search
Camera Setup
Camera Setup

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' and press the blue button 'Add Camera'
The basic setup exists of:

  • Name: The name you want to identify your camera with
  • IP Address: IP Address of the Camera
  • Port: Port of the Camera
  • Username: Username if you need to enter that in the snapshot URL. Leave empty if not needed.
  • Password: Password if you need to enter that in the snapshot URL. Leave empty if not needed.
  • ImageURL = URL for making a snapshot image, not a video stream without the IP Address or Port and slashes.

Note: A list of ImageURLs for IP cameras you can find on our wiki page Hardware#IP-networkcameras or in section IP Camera General below


Note: If your camera Image URL needs to define a USERNAME and/or PASSWORD, you can use the #USERNAME and #PASSWORD tags like:
snapshot.cgi?user=#USERNAME&pwd=#PASSWORD

Connect to Switch/Light

You can connect a Domoticz switch/light like a Door Switch or Motion Sensor to a camera. This will add a camera stream icon to the switch widget and also will give the opportunity to attach a camera snapshot to the email notification when the switch is triggered.

To connect a device and setup email notification with snapshot:

  • Select the camera
  • Select from the pull down list Device/Scene the device that triggers the notification (On/Off) and on what action and with the delay.
  • Click on button Add
  • Enable Email notification in menu Setup - Settings - Email and select "Send camera snapshot as attachment".

Now if the device is triggered an email is sent with a snapshot. Email subject is: [Trigger Device Name] status: [On/Off].

PS. It is also possible to send such an email with the dzVents snapshot function eg dz.snapshot(1,'Subject') without adding a trigger device to the camera.

IP Camera General

A longer list of Image URLs 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
Port:80
Username:admin
Password:<blank>
ImageURL:snapshot.cgi

Grabbing snapshots from RTSP-stream with script based on 'ffmpeg'

Cams that spit out a RTSP-stream (Real Time Streaming Protocol) won't work in Domoticz.
With this script you can grab snapshots from a RTSP-stream. It uses 'ffmpeg' to open the RTSP-stream and grab a snapshot from it.
You still can't use it directly in Domoticz, but if you want to grab a snapshot when the doorbell is pressed for example, this script will do so (outside of Domoticz).

IP Camera configurations

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. 192.168.1.111)
Port: 88
Username: #USERNAME
Password: #PASSWORD
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: 1.4.1.5
App Firmware Version: 1.11.1.15
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: http://www.ispyconnect.com/man.aspx?n=foscam


Avidsen Visia 7 outside cam

To setup a avidsen cam visia 7, you need to download application on your smartphone "avidsen visia":
Then, select search on local network, when it's ok, select search on WIFI
After this, you can modify the setup of wifi.
For domoticz:
IP address: the address of the IP camera (e.g. 192.168.1.111)
Port: 80 ( it's not possible to modify)
Username: <username of the IP cam>
Password: <password of the IP cam>
ImageURL: web/tmpfs/snap.jpg


Avidsen Visia 8

You first need to connect the cam to your network following Avidsen instructions.

For Domoticz:
Protocole: HTTP
IP address: the address of the IP camera (e.g. 192.168.1.111)
Port: 80 ( it's not possible to modify)
Username: <username of the IP cam>
Password: <password of the IP cam>
ImageURL: web/tmpfs/snap.jpg


Controlling your cam with its API:
This is possible to control moves, shots and even set different positions of the cam.
E.g. if you want the cam to look at the ceiling when you are home (and alarm OFF) and to be in a defined position when you are away (and alarm ON).
See here : https://stackoverflow.com/questions/45464775/how-to-control-ip-camera-avidsen-visia-via-api

flux:
http://<IP-Address>/tmpfs/snap.jpg?usr=admin&pwd=password :: Snapshot (720p / 1280x720 Pixel)
http://<IP-Address>/tmpfs/auto.jpg?usr=admin&pwd=password :: Snapshot (352p or 176p)
rtsp://<IP-Address>/11 (via VLC for example) :: video+audio

Motor:
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=right :: Moves continuously right
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=left :: Moves continuously left
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=up :: Moves continuously up
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=down :: Moves continuously down
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=stop :: Stops moving camera-head
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=1&-act=right :: Moves one step right
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=1&-act=left :: Moves one step left
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=1&-act=up :: Moves one step up
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=1&-act=down :: Moves one step down
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=home :: Go to Center Position
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=hscan :: Scan horizontal
http://<IP-Address>/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=vscan :: Scan vertical
http://<IP-Address>/cgi-bin/hi3510/preset.cgi?-act=set&-status=1&-number=[0-7] :: set a position
http://<IP-Address>/cgi-bin/hi3510/preset.cgi?-act=set&-status=0&-number=[0-7] :: unset a position
http://<IP-Address>/cgi-bin/hi3510/preset.cgi?-act=goto&-status=1&-number=[0-7] :: goto to a set position

image:
brightness :: [0 - 255] the bigger the value the brighter the image
saturation :: [0 - 255] the bigger the value the more saturation the image has
contrast :: [0 - 255] the bigger the value the more contrast the image has
hue :: [0 - 127] the bigger the value the more hue the image has
flip :: (on , off) flips the image
mirror :: (on , off) flips the image
scene :: (auto , indoor , outdoor) sets the white balance mode

Easy example: http://<IP-Address>/cgi-bin/hi3510/param.cgi?cmd=setimageattr&-mirror=off

Complexe example: http://<IP-Address>/cgi-bin/hi3510/param.cgi?cmd=setimageattr&-brightness=0&-saturation=0&-contrast=0&-hue=0&-flip=off&-mirror=off&-scene=auto

IR-LED:
http://<IP-Address>/cgi-bin/hi3510/param.cgi?cmd=setinfrared&-infraredstat=auto :: Sets IR LED's to auto mode
http://<IP-Address>/cgi-bin/hi3510/param.cgi?cmd=setinfrared&-infraredstat=open :: Sets IR LED's always active :: only IN-6011
http://<IP-Address>/cgi-bin/hi3510/param.cgi?cmd=setinfrared&-infraredstat=close :: Sets IR LED's always inactive

ALARM:
http://admin:password@<IP-Address>/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-enable=1&-name=1 :: enables the md area 1
http://admin:password@<IP-Address>/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-enable=0&-name=1 :: disables the md area 1
http://<IP-Address>/cgi-bin/hi3510/param.cgi?cmd=setioattr&-io_enable=1&-io_flag=1 :: enable / disable external alarm in to trigger recording



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. 192.168.1.111)
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. 192.168.1.10)
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)
ImageURL: http://192.168.1.10:9989/

Axis 221/211

To setup a Axis 221/211 enter the following:
IP address: the address of the IP camera (e.g. 192.168.1.111)
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

Sunell

CGI API documentation PDF

To setup a Sunell IP camera enter the following:
IP address: the address of the IP camera (e.g. 192.168.1.111)
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

ELP Mini Camera IP-1892, IP-1881, IP6100

To setup an ELP IP camera, enter the following :
IP address : IP camera IP Address (e.g. 192.168.1.11)
Port : IP Camera Web Port (e.g. 80)
Username : <IP cam Username>
Password : <IP cam Password>
ImageURL : webcapture.jpg?command=snap&channel=1

Remark 1 : This IP Cam is Full HD (1920x1080), however the snapshot is 704x576. So I use 'convert image.jpg -resize 1280x720! image2.jpg' (the ! is to force resizing)
Remark 2 : To install convert, type sudo aptitude install imagemagick


FunXWE IP Camera (FS02-0)

To setup an FunXWE IP Camera, enter the following :
IP address : IP camera IP Address (e.g. 192.168.1.11)
Port : IP Camera Web Port (e.g. 80)
Username : <IP cam Username>
Password : <IP cam Password>
ImageURL : http://<Camera_IP>/web/cgi-bin/hi3510/snap.cgi?&-getstream&-sn


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

Test if the camera can record video with the command:

raspivid -o test.h264

For more information please visit:
http://www.raspberrypi.org/camera

To add the camera in domoticz use the following parameters:
IP Address: Your domoticz server IP address
Port:8080
Username:<blank>
password:<blank>
ImageURL:raspberry.cgi

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
http://blog.pixelami.com/2012/06/uvccapture-on-raspberry-pi-debian-squeeze/

To add the camera in domoticz use the following parameters:
IP Address: Your domoticz server IP address
Port:8080
Username:<blank>
password:<blank>
ImageURL:uvccapture.cgi


Plug-in Version: 2.0.1.3

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.

When you have separate Switch/Motion Sensor etc then you can use the Connect to Switch/Light method

Motion

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.
run:

sudo nano /etc/default/motion

change the configuration to this and save the file:

# set to 'yes' to enable the motion daemon
start_motion_daemon=yes

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:

/etc/motion/motion.conf

  • 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:
/etc/motion/thread1.conf
/etc/motion/thread2.conf
/etc/motion/thread3.conf
/etc/motion/thread4.conf

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:

motion.conf:

ffmpeg_video_codec mpeg4

thread1.conf:

width 640
height 480

thread2.conf:

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:

thread1.conf:

on_event_start /usr/bin/curl -s "http://api_username:api_password@domoticz_server:domoticz_port/json.htm?
type=command&param=switchlight&idx=your_ID&switchcmd=On"

on_event_end /usr/bin/curl -s "http://api_username:api_password@domoticz_server:domoticz_port/json.htm?
type=command&param=switchlight&idx=your_ID&switchcmd=Off"


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 https://github.com/bazwilliams/domoticz-sound-detection/

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.