Foscam Universal Internal Device Type (HD\Non-HD with Alarm\LED\PTZ Control)

The settings you set in the Foscam app will persist when ST uses the camera. I went to the foscam app, opened the live feed, hit the HD icon at the bottom which brings up a slider bar with “Smooth” on one side and “HD” on the other. Even though it’s a slider bar it seems like there are really only two options. If you slide it to the first 50% of the bar it will be low quality, the second 50% will be full HD.

Even with it set to low quality it still seems to fail if you try to take a camera burst without giving it enough delay to return the image. Delaying the burst 5-6 seconds between shots seems to guarantee you get every pic back.

Thanks vors. After changing the stream resolution to Smooth from the web app then now I can take the picture from the camera more consistently.

How to I point ST at my FOSCAM with the Device type you listed above?

I am attempting to use this. I have latest code from github, and the device is added. I have the preferences set correctly. When I hit take picture, i see in the IDE log

/cgi-bin/CGIProxy.fcgi?usr=user&pwd=passf&cmd=snapPicture2
Executing hubaction on myip:88

But nothing happens. If I take what’s in the IDE log http://myip:88//cgi-bin/CGIProxy.fcgi?usr=user&pwd=passf&cmd=snapPicture2 and the put that in a browser, I get an image returned.

I looked on my firewall that’s between the hub (v2) and the camera, and I see that the hub completes a 3 way TCP hand shake (SYN/SYN+ACK/ACK) with the foscam but then the hub issues the FIN flag immediately to shut down the connection. What on earth could be going on?

This was working great for a while but it also no longer works for me. I moved over the summer and just recently setup my foscams again. Not sure when it stopped working??

This is all very disappointing. I noticed the parse function was not getting called. Through scouring the forums I learned that some time in the last couple of months, access to a camera via hub action can now only go to a local ip address on the same subnet as the hub. Boo. So I worked around that by setting up a reverse port forward on my firewall, with an internal port on the firewall forwarded to my chosen remote camera. That seemed to do it. Now the HTTP requests were actually being made and I got some picture data back after pressing “take a photo”. However, the photo was corrupted. Only the top part was correct. I read somewhere that the photo resolution might be too high so I adjusted it down to low on the camera and tried to take another photo. NOTHING. Now the HTTP requests didn’t seem to be working. From what I can tell, only some of the outbound calls go CGIProxy.fcgi actually get made. On the ones that do get made, when the parse function is called, the description parameter does not contain bucket: and key: so the function that stores the image isn’t getting called. I tried deleting the device and the device type and starting over. Got it all reinstalled and reconfigured and then NO http requests were going through at all. The refresh button wasn’t even working. Scouring the forums, I found a note from someone saying that something gets “stuck” with the DNI and that if you have a different DNI it’ll start working again. So I changed my port forwarding setup on the firewall- moved the internal port from 88 to 89 so the DNI was unique again, and boom, http requests started working again. Press take photo, get a corrupt photo again, and that’s it, take photo doesn’t do anything again. Bah. Why is this so hard?

Well, got it working in the end. It turns out the trick was to turn the camera resolution down AND to turn down the jpeg quality. From some rough experimentation and guess work I have sort of concluded that the S3 image store component needs the images to be below a certain size. Maybe somewhere in the 32-64KB range? My foscam is a 9831P and none of the PTZ or other buttons work properly as best I can tell. Still that’s investigation for another day.

I am not seeing the ‘icons’ change on pull/refresh, should they be? I have the app set up and I am able to turn on/off motion detection through the app. but when I change it through the Foscam app. and do a refresh on your app. it does not update the icon to reflect whether motion detection has changed. In the realtime logging I do see that it successfully polled and identified the current state of the ‘motion direction’ and it calls the appropriate ‘sendevent’ function based on the Cam’s status, but the smartthings app icons do not change to show the motion state has changed.

Workflow:

  1. turn motion detection on through the ST app.
  2. validate the calls were made, icon in ST app. changes to BLUE, and Cam’s motion detection is on (Cam web interface)
  3. In the Cam web interface turn OFF motion detection
  4. CLose the ST app. reopen and perform a ‘refresh’, validate logging shows that the Cam’s current state with the motion detection is ‘off’, and the correct ‘sendevent’ is called
  5. ST App. still shows “BLUE” on icon for motion after it has identified it was ‘off’

Another thing to note is that the ‘take picture’ does not work for me (no picture load but log is correct and link works). that is another issue I’ll tackle down the road.

I have uninstalled and reinstalled the device type, etc. multiple times with change in issue

I have a FI8905W and I had to modify the code to include the usrname and password to take a picture. change in bold
//TAKE PICTURE
def take() {
log.debug(“Taking Photo”)
sendEvent(name: “hubactionMode”, value: “s3”);
if(hdcamera == true) {
hubGet(“cmd=snapPicture2”)
}
else {
hubGet("/snapshot.cgi?user=${username}&pwd=${password}")
}
}
//END TAKE PICTURE

Does anyone mind creating a simple step-by-step? I have done a few things and noting works:

I have Smartthings V2 Hub and Foscam FI9821W V2 HD.

I created a new device type using the latest github code and then set the preferences including the IP address and port of the camera.

I then created a device.

In the decive configuration all I can see is a place for the user name, password, name, and image. I can’t set or edit the IP address from the mobile app.

When I look at the created device all i see is a “capture image” button which when i click it nothing happens.

Any advice?

1 Like

Yeah, my Foscam C1 sits @ Taking the picture. Not sure if it is stuck moving the image to S3?

I have completely setup my Foscam’s using this device type and verified the Ports and IP’s multiple times. In the app the Cam image isn’t coming through at all and nothing seems to be working. Can someone help my diagnose what I am doing wrong? I see all the buttons when I click on the Cam from my Things section but the area where the image should be in just blank grey space. I have clicked the context menu while in the device to edit the settings and verified the usr and pass along with the correct IP and Port.

This Device Type is perfect for my HD Foscam camera!! I did have to spend a little time getting a few quirks worked out before it worked flawless and wanted to share those with anyone else having the same issues. Hopefully some other community members find this useful, especially the image capture part which seems to be a big issue for many folks.

  • Image capture fix. I’m not sure why, but when the device network ID has lowercase characters in the hex value, it doesn’t want to work. Converting it to all uppercase makes the image capture work flawlessly for me. Not sure why, but read it somewhere else in a post here, but can’t seem to find that post. Edits on lines 415 and 416:
def iphex = convertIPtoHex(ip).toUpperCase()
def porthex = convertPortToHex(port).toUpperCase()
  • Camera Controls not all working. Looks like it ins in the logic determining if the device is HD or not. Some place try to evaluate a string, and other a boolean (the difference being quotes are “true”). Had to remove the quotes around true on lines 250, 336, 350. All of those should look like this:

if(hdcamera == true) {

Edit: Removed quotes from example - the quotes were what was causing the problems

1 Like

Thanks! While I was able to control my HD Foscam, it wasn’t working to take pictures. After using your edits, pictures are working! I made the edits to the controls as well, and they are still working as well.

EDIT: Well, scratch what I said above. Its back to not working. This is the same behavior that I experienced before I made your changes. It worked for a couple of snapshots and then quit working. Very frustrating.

I am still having issues getting my cameras to function and show the video stream at all. I have made the modifications for the Image Capture issue that @foxxyben has stated but still not stream of the camera in the app:

As you see above the area where the feed should be is grey

Here are my settings:

Someone please help me figure out what my issue is. Thank you

From what I understand of this device type (and of SmartThings capability), this is not meant to stream the video. It only takes stills when the Take button is pressed. In order to stream video you have to use one of the SmartThings approved cameras.

That would be pointless IMO to have a cam that can only take snapshots. I hope that truly isn’t the case. I am about to just pay for @RBoy DeviceType and SmartApps as I am just beyond confused as to why I can’t view my cam with this or the native Foscam DeviceType. I am just hesitant to shell out money for an app or device type and run into the same issue I have here with this one.

@keatonhoskins this is a limitation currently with the SmartThings. I have been holding off development on this mostly until the video functionality is available. Unless they have pushed an update while I’ve been gone, I’m still waiting. I believe dropcam has the video capability so I’m just waiting for them to extend the functionality or for someone to help figure out how to give access to IP cams. I wouldn’t call this useless though. One reason people use this is to take snapshots when an alarm is triggered. You will need to combine this device type with some of the smartapps.

@eparkerjr I definitely appreciate your developing this, I’m giving up on it with my FI9821W V2 for two reasons:

  1. It rarely works. For whatever reason, snapshots work a couple of times before they completely stop working at all. I’ve tried deleting the device, deleting the device type, power cycling my phone and camera with no luck.

  2. It wipes out the motion detection settings every time it arms the alarm. Because of this, all the “actions” (send email, take snapshot) get unchecked, so it accomplishes nothing. This was brought up several times by other users, and no solution was ever offered.

Are you not experiencing these issues? If not, I’d love to understand what is wrong with my setup.

2 Likes

@eparkerjr, thanks for putting this together. I do have a question, though. Where are the images stored after taking them and is it possible to delete them from within the iOS app?

1 Like