Idea for FOSCAM camera binding

Matthew

Hi, First time poster and long time lurker.

I was having issues with the new foscam cameras. I wanted to be able to use the video widget in the openhab ui without plugins etc. I was originally told that the H.264 cameras cannot be show live in the UI. Not true. My solution was to turn one of the streams to mjpeg and then the video widget works great. I don’t know if its a good as the HD stream but it does work flawlessly in the UI without any plugins. Maker sure the firmware is up to date and you use the mjpeg option in your sitemap item.

http://ip address:port/cgi-bin/CGIProxy.fcgi?cmd=setSubStreamFormat&format=1&usr=xxxx&pwd=xxxxx

will set the substream to mjpeg.

I have 5 foscam FI9853EP HD POE cameras that i can view in the openhab ui. Works from the internet too.
Also works in HABDroid as well.

Anyone have a good way to display the streams in the UI?? Or at least have the user pick what camera to see in the UI? Side by side? Right now I have a switch that only shows the steam when “on” using the visibility on a frame. It works great unless 2 people are logged in to openhab.

Kim

1 Like

In the very latest version I believe there is an experimental html5 viewer that works on ff and chrome. Maybe we can explore that

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