Idea for FOSCAM camera binding

Just change the substream to mjpeg and works in any browser without a plugin. Can view my h.264 cams in chrome from the address bar.

Kim

Great tip. Thanks!

Your welcome.

Donā€™t know if this is the place to ask but I am having a heck of a time trying to read the motion detect status on the cameras. I am using this item statement:

Number nCam1Alarm ā€œMotion Detect [%d]ā€ { http="<[http://192.168.0.135:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=xxxx&pwd=xxxx:3000:REGEX(.?(.?).*)]" }

I donā€™t get seem to be getting anything. I dont know how regex works and just copied it from the post above. Anyone have any ideas? when i type the command in chrome i get the xml result below:

Canā€™t type in the < > characters as they donā€™t show up in the post.

CGI_result
,
motionDetectAlarm1/motionDetectAlarm
ā€¦
/CGI_result

Any ideas how to parse that into an openhap number item?? Iā€™ve spent days on this and am no closer. I apologize in advance if this has been covered before. Thanksā€¦

Kim

see Security Camera Recommendations

Markus,

Thanks!! Your my hero!!! Works great!!!

Kim

Yes, I forgot you could do that, you lose your sub stream video though (hijacked by the mjpeg stream).

I have 4 foscams displayed in 4 quadrents using the webview sitemap item.

You make a simple web page with four image items. I have individual web pages for each camera , and made each image a link to/from the main 4up page.

This now means that you can display all 4 cameras at once (in quadrants), then touching (or clicking) on an image zooms it up to full screen. Touching it again goes back to quadrants again.

You have to have an http server (Apache2 Iā€™m using) you can serve the web pages from. The pages are very simple, just a few lines each.

This works independently of how many people are using openhab, and in a browser -itā€™s just a web page.

ā€˜ā€™ā€™

Porch WD Live Feed '''

The main page has 4 entries with the links the other way round.

Yes, I forgot you could do that, you lose your sub stream video though (hijacked by the mjpeg stream).

I have 4 foscams displayed in 4 quadrents using the webview sitemap item.

You make a simple web page with four image items. I have individual web pages for each camera , and made each image a link to/from the main 4up page.

This now means that you can display all 4 cameras at once (in quadrants), then touching (or clicking) on an image zooms it up to full screen. Touching it again goes back to quadrants again.

You have to have an http server (Apache2 Iā€™m using) you can serve the web pages from. The pages are very simple, just a few lines each.

This works independently of how many people are using openhab, and in a browser -itā€™s just a web page.

Iā€™d post an example here, but it doesnā€™t like included html.

If you put three backquotes on a line, your HTML, and another three backquotes on a line, it ought to allow HTML. For example

<html><body>hi there</body></html>

from
```
<html><body>hi there</body></html>
```

kfischer628 thanks for confirming the FI9853EP is the model you have and how you have them working. Iā€™ll buy some shortly, just looking at a POE switch with snmp support so I can turn the power on and off via openhab. What POE switches people use would be great to know as well as they can get pricey for a decent managed switch with more than 4 POE ports and 16+ ports in total.

I may be able to contribute to a foscam binding but am needing more spare time than I have right now to do this. Plaster just got installed and now I have to patch all the cables to get things working, maybe in two months time.

I wrote about this to ā€œteichstaā€ last yearsā€¦ these cameras are based on OpenIP Cam.

http://www.openipcam.com

Isnā€™t OpenIpCAM a set of replacement firmware for different hardware models, that requires the user to flash it onto their supported IP camera?

Is it possible to use items bound to the HTTP binding, and rules, to achieve full integration between OpenIpCAM and openHAB?

Yesā€¦ OpenIpCAM is a firmware. Wansview, Foscam and many chinese cameras are based in this firmware (usually only interface file is different).

Yesā€¦ we are able to use HTTP binding to send commands, and maybe to get status.

BUT, maybe with a little modification in HTTP binding, we could have an ā€œEASY TO USEā€ method for this kind of camera. With direct commands (aliases). Just an idea.

I did already think to use this likeā€¦ IF my movement sensor detects somethingā€¦ SEND to camera a command to move to preset X (sensor location). Orā€¦ everyday at specific time or if my cel phone is at home SEND to camera a command to move to preset Y (do not show specific place image).

Matthew:

These cameras are working well for me in the UI. But I now realize one issue and its about the motion detection.

It seems that on my cameras none of them detect a motion and change the alarm status from 1 to 2. They always return 1 no matter what i do. I know the motion detection is working because it will send a snapshot to my ftp server and will record video if its turned on thru the interface. But that motiondetectalarm always stays at 1. I checked it in openhab and thru chrome by running the getstatus command there. Also, the status in the web interface always stays at 1. So i think iā€™m going to go with separate motion sensors as i donā€™t like the constant polling of the cam anyways.

Something is happening because it happens on all my cams. I could see it being a glitch if it happened on just one. I think my house is on an old indian burial ground (sigh).

Kim

Note motiondetectalarm gets quickly reset to 1 (how fast depends on your settings and polling interval), so you may just not have spotted it.
Works fine for me if you take the Item from my post. Check events.log for a record of all changes to the item.

Markus;

I wasnt waiting long enough. Iā€™m pretty impatient. LOL. Everything is working as planned. It would trigger the alarm but it would get set back very quickly. I added a timer to turn on a switch and its doing what i wanted. Thanks again.

Kim

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 doing.lol. 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(onoffcam.map):%d]ā€ { http="<[http://ip address:port/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig&usr=xxxx&pwd=xxxx:4000:REGEX(.?(.?).*)]" }

editā€¦
The above item REGEX statement should read
REGEX(.?linkage(.?)/linkage.*)
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.

Kim

Matt,

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:

#!/bin/bash

#port 6 is hallway cam

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

# login with username and password
/usr/bin/curl -q "http://192.168.100.99/cgi-bin/dispatcher.cgi?login=1&username=admin&password=xxxxxx"

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 "http://192.168.100.99/cgi-bin/dispatcher.cgi?cmd=774&pdPriority=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.

Regards,
Nick.

Kimberly,

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!
Nick.