Idea for FOSCAM camera binding

Glad to hear. Btw, you can also check for ...<soundAlarm>... in another item.
Just discovered my camera model has a jack for it and I just connected a microphone. It does not trigger any alarm, but that seems to be unrelated to OH.

Although there’s no binding for Foscam cameras, we’ve been sharing some great information in this and other threads about integrating the cameras. I’ve created an openHAB wiki page with an overview of the related information. Remember, anybody can edit the wiki pages if you see inaccuracies or would like to add information.

1 Like

I think I’ve got this figured out. My problem is that I don’t know what i am I spent the day turning an old windows 7 pc into an ubuntu server. Took me about 6 hours to configure samba and ftp. I kept messing up the user accounts and file permissions. Plus I found a setting i needed after many hours of searching. UGH!!! Massive headache after all that to get the cameras ftp’ing to the new server.

So I’m now trying turn on and off the foscam motion detect save video/pics/send email so it only takes action when I “arm” the camera through openhab. This lets me have my own little house wide video security system controlled through openhab. This could be done through a schedule or a swtich. I have an rfid tag near the door that I tap my phone on to “arm/disarm” my system when i leave or get home. After my whole house audio project I plan to use squeezespeak to audibly tell me the system status. I keep the motion detect on at all times but just turn the actions off. This is so i can have sitemap items that show if motion is currently being detected even if save to video is off. I also display the last motion detect date/time on my sitemap. I also poll the camera through a number item so i can verify that the camera received and accepted the command to arm/disarm using getMotionDetectConfig.

So this is my item for all of you with a foscam cam. Maybe it will save someone some headaches.

This switch turns the motion detect action on the camera on/off… with full schedule and full camera area.

The linkage parameter sets what action to take when motion is detected. I set it to 12 to send video and snap shots to the ftp server and 0 to take no action. I dont check email that much anymore so i don’t use that option. I have email setup in openhab and have openhab text me when i am away from home (i setup asus merlin script on my router to detect presence and have it update openhab when i connect/disconnect through wifi).

Each schedule interval is per day so there are 7 (schedule0-schedule6). There is one bit for every 30 minutes of the day.There are 48 per day so the value is 281474976710655 to cover the entire day.

The cams have a 10 by 10 grid for motion detection. it uses area0-area9 for each row I have all grids turned on so the value is 1023.

Switch setCam1Alarm “Set Motion Detect Action On/Off” {http=">[ON:POST:http://ip address:port/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&linkage=12&snapInterval=2&sensitivity=1&triggerInterval=10&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&area0=1023&area1=1023&area2=1023&area3=1023&area4=1023&area5=1023&area6=1023&area7=1023&area8=1023&area9=1023&usr=xxxxx&pwd=xxxxx] >[OFF:POST:http://ip address:port/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&linkage=0&snapInterval=2&sensitivity=1&triggerInterval=10&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&area0=1023&area1=1023&area2=1023&area3=1023&area4=1023&area5=1023&area6=1023&area7=1023&area8=1023&area9=1023&usr=xxxx&pwd=xxxx]"}

Here is the item i used to check if the camera received the updates. Sometimes with http it doesnt always work perfectly (timeouts, etc). So I display this item to make sure the cam is set properly. I use a map file to display if armed or disarmed.

Number nCheckCam1Alarm “Verification [MAP(]” { http="<[http://ip address:port/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig&usr=xxxx&pwd=xxxx:4000:REGEX(.?(.?).*)]" }

The above item REGEX statement should read
with the word linkage enclosed by “<>” in both cases.

Large angry rant ahead:
The REGEX statement above does not come out as expected on these forums. This explains why many of the examples i’ve gotten off these forums do not work. The html messes up the actual statement. Does anyone have any ideas how to fix this? I’ve literally spent hours and hours trying to use REGEX examples from here only to find they dont work. Its extremely frustrating. It’s originally why i posted here as I couldnt get examples to work that other have said were working fine on their system. Most times I dont even think the original poster knows it has done this. This is one of the reasons why newbies like myself get so angry with openhab. We are told to read the examples, do a search etc. Fixing this or knowing this would have saved me days of work!!! I think if we want new people to give openhab a shot then we should find a way to change this. I am not a programmer and have been learning as i go. its been long and slow but i’m getting there. its a great program but i completely understand why many people give up on it. Do we want openhab to be only used by programmers? my 2 cents as a newb.
Rant over.
…end edit

The easiest way to get the values you want is to run the getMotionDetectConfig from the address line on your browser. Make sure you’ve set up the schedule the way you want and the areas to detect motion at. You have to do this from a browser or program that can access the native config for the camera (yes, the dreaded foscam plugins). I use IE and just login into the cam using its ip address:port

So after its all set up the way you want run:

http://ip adress:port/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig&usr=xxx&pwd=xxx

Take the values from this and plug them into the item binding above and enjoy!!!

Now that my cams are working my next todo is to add squeeze server to my new ubunto server and start on the whole house audio project!!! Fun times! Anyone with some pointers (ex: STOP NOW , RUN AWAY!) would be helpfull.



I got a ZyXEL Fanless 8 Port GbE 70w PoE+ L2 Web Managed Switch(GS1900-8HP) from Amazon, and I use it to switch the power to my FosCams.

This is the item(s):

/* Camera Power Exec items */
Switch power_Hallway_Camera "Hallway Camera power" <shutdown> { exec=">[ON:/home/nick/Scripts/camera_power 6 1] >[OFF:/home/nick/Scripts/camera_power 6 0]"}
Switch power_BackGarden_Camera "Back Garden Camera power" <shutdown> { exec=">[ON:/home/nick/Scripts/camera_power 5 1] >[OFF:/home/nick/Scripts/camera_power 5 0]"}
Switch power_SideGarden_Camera "Side Garden Camera power" <shutdown> { exec=">[ON:/home/nick/Scripts/camera_power 4 1] >[OFF:/home/nick/Scripts/camera_power 4 0]"}

this is the script that they run:


#port 6 is hallway cam

echo "switching power for port $1 to $2"

# login with username and password
/usr/bin/curl -q ""

sleep 1
#switch PoE on or off port is portlist, on is state 1, off state 0. priority is medium (2)

/usr/bin/curl -q -G -d portlist=$1 -d state=$2 ""

echo "port $1 switched"

This works surprisingly well.

I have a fourth camera, but that is not on PoE (WiFi), I use a switched outlet to power cycle that.



Let me know how you get on with this, one thing I’ve been looking into (not too seriously) is getting voice response out of my openhab set up - but two problems:

  1. the voice synthesis out of openhab is terrible, and arcane (even google tts is bad).
  2. getting audio out of my ubuntu server (in the basement) to speakers around the house is difficult.

I have tried bluetooth with limited success. Getting audio bluetooth to connect to bluetooth speakers sort of works, but it’s hit and miss, by no means automatic. Once I have this working, see 1) above.

Best of luck!

@Nicholas_Waterton #1 - see my post regarding setting up MaryTTS as a separate service and integrating into OpenHAB rules. This gives really good results compared to the MaryTTS binding.

#2 - look into using pulse audio for remote playback. I used this with good results for sending the MaryTTS output from my server to remote Ubuntu Desktop(s). This is much more reliable than bluetooth, and doesn’t involve pulling cables :slightly_smiling: An example of this is included in my script (under REMOTE PLAYBACK).

Best regards,

Thanks for the code and the info. Always good to know what others are using that works. I just got a Dlink DGS-1210-10P which can do 30 watts per port with a total max of 78watts POE. Should handle 7 cameras with an 8th possible if I spend more to use a SFP port to connect to the other switch.

My whole house audio is going to consist of an LMS with some squeezeplayers through out the house. I had ordered an XAP 800 from ebay for $25. i wanted to use that to have some simple ceiling speakers throughout the house as well. Unfortunately it was DOA. I may get another and play around with it but i think an arduino or rpi running squeezeplayer will work.

I have been following with great interest the discussion about creating an Amazon Echo binding/action. I have a small house but am a bit concerned about only having one in the house. I dont know if i want to yell to other room to have Alexa do something while i’m not in the main room.

I just dont thin’k voice control is there yet. Soon…but not yet. I think while I am waiting for that to work itself out a bit better I might make a couple magic mirrors that I can talk to.

I want that house from the future where it knows what room I am in and will activate the magic mirror/screen in that room. It can read me the news, show my schedule or move the content from my kodi player from room to room to follow me. Too much to ask? lol. The two biggest stumbling blocks i see are accurate presence detection in the room and the voice control. I think the voice control will be available soon but not so sure about the presence detection.
What are others using to detect in room activity? I use wifi status with a script on my router to alert the house that i am home. For the most part it works really really well as long as your wifi is on. My kids dont keep theirs on all the time so I will have to have chips implanted in them .ROFL.

I’ve tried some bluetooth solutions but it wasnt consistent enough.

Ok, off topic…sorry…would love to continue this in another thread though.


I use the http binding and send orders to activate the motion detectionin my Foscam C1

as follows

Switch itemname {http = "> [ON: POST: /cgi-bin/CGIProxy.fcgi cmd = setMotionDetectConfig & isEnable = 1 & linkage = 16 & snapInterval = 2 & sensitivity = 1 & triggerInterval = 5 & schedule0 = 1024 & schedule1 = 1024 & schedule2 = 1024 & schedule3 = 1024 & schedule4 = 1024 & schedule5 = 102 4 & schedule6 = 1024 & area0 = 1024 & area1 = 1024 & area2 = 1024 & area3 = 1024 & ar AI4 = 1024 & area5 = 1024 & Area6 = 1024 & Area 7 = 1024 & Area 7 = 1024 & AREA8 = 1024 & area9 = 1024 & usr = admin & pwd = "]> [OFF: POST: /cgi-bin/CGIProxy.fcgi cmd = setMotionDetectConfig & isEnable? = 0¬usr = admin & pwd =] "}

pls kim,what programming language are u using and pls can u help me with some source code .i want to integrate my map to my camera in programming sunh that i can view my camera from the map

after you setup one of the streams to be mjpeg then all you need to do in a sitemap is to add the url item to your sitemap

Frame label=“Camera View” {
Video url=“” encoding=“mjpeg”

No programming language…its all done in openhab.


@Kimberly: doesn´t work for my FI9900P.
I always get “result 0 result”, so the substream doesn´t switch.

Any idea?


What do you see when you open that hyperlink directly in your browser?
You should be able to see your image, without any popup/password/… question.

I myself have a zoneminder server running that centralize/analyze all camera’s. But nevertheless, I wanted to have also the videos directly in openhab (simplier for my family to use 1 app).
I had an issue with live streams on some platforms/browsers, so I just refresh an image every second. Not real video, but almost the same. :wink:

I’m using following in my sitemap:

 Group label="Voordeur" icon="video" {
   Image url="" refresh=1000

Basicly, it does the same as for Kimberly: pulling down the image (in my case from my server instead of camera). Additional with refresh every second.

Guys, i understand from here that it doesn’t matter what camera you have, and as long as you can set a stream to mjpeg, you’ll be able to view live from your camera in OH! Am I wrong? So this means even Foscam C1 can stream live in OH?

Unfortunately not correct, their new cameras are using a new chip which is not supporting the mjpeg at all.
They have some old specific models which can support mjpeg or both.
You can email the support and they will provide you with the list but for sure C1 is not one of them…

I have a C1 and FI9900p both support RTSP. As OpenHab does not support this (only MJPEG). Currently, I am using snapshots to generate at least some sort of moving image. It would be great if OpenHab support the RTSP protocol. Unfortunately I have no clue how to implement this. Any suggestion/initiative would be great. Kind regards!

Has anyone tried controling ip cam Pan and Tilt? If so, how to do that? Thanks!

1 Like

Hi there
i’m new to this world and i just want to ask… is there step by step page
that can help me to add 3 pieces of foscam at openhab please ?
Thanks in advance

have not tried it myself but maybe through HTTP binding and the proper cgi command.

Did a binding ever get started?

Great link of info collected in case it was missed.