SmartThings Community

[RELEASE] Foscam Camera Device Handler Universal DTH with Discovery, Live Video Streaming, Motion Sensor/Alarm Integration - SD (FI89xx), HD (FI98xx, FI99xx), Cx, Rx, Ex, Fosbaby

smartapp_cameras
dth_security
smartapp_security
dth_cameras
rboyapps
(www.rboyapps.com - Make your home your butler!) #1074

Use the HTTP port if you’re using the LAN IP address. ST doesn’t not support HTTPS for LAN devices yet.

(Greg_Schaub) #1076

Can you tell me exactly how the “motion alarm check interval” is used in the related Foscam Motion Alarm Monitor? The default was 1440 seconds and I thought that every 24 minutes was too long to have the camera check to see if there is motion, so I changed it to 60 seconds. I noticed that my logs are now so full with messages telling me that the checkmotionstatus command was sent to the camera that the activities log on this camera became unusable because of the number of unimportant informational messages.

I also thought that having the motion sensor fire once per minute was way to long an interval. Therefore, I’m thinking that I must not clearly understand the purpose of the interval. My expectation is that the camera will always be monitoring activity and send me a notice if it finds anything. In fact, the Foscam app already does this. The value to me of integrating with Smart Things is being able to have it take action if it finds a problem.

(www.rboyapps.com - Make your home your butler!) #1077

The default is 5 seconds and should not be changed unless there is a reason.
Some cameras models don’t support push notifications and for those camera
the motion alarm needs to be queried. The device handler will identify the
camera and determine is push or pull is required.

The way ST is designed when a SmartApp sends a command to the camera it
logs it in the recently tab which is what you’re seeing. There is no way to
control this other than sending a request to ST to change the way the
platform and mobile app behaves.

(Greg_Schaub) #1078

Thanks so much. I have no idea where the 1440 came from. Somehow I suspect a request for better control over the request tab from the API will fall on deaf ears…

Pairing Onvif cameras
#1079

Hi there. I just subscribed to RBoy’s site to get the device handler for my Foscam R2. I have everything set up, but have one issue.

When I am live streaming from my camera and I initiate a command to either pan or tilt the camera, the video stream goes blank and I have to re-start the stream. After I restart the stream , the panning or tilting took effect, but it seems that every time I try to pan or tilt while viewing the live video stream the stream itself stops.

I’m performing all this within my internal LAN (192.168.1.x), using HTTP, with my ST iPhone App.

Any help on how to troubleshoot shoot this issues to allow me to pan/tilt the camera while viewing the live stream would be much appreciated.

Thanks!

(Blake Northrup) #1080

Hi RBoy, I just setup my Sricam/Foscam with your directions and all is working great! I just wanted to know how set it up take a picture upon motion detection, and where the picture is stored. Sorry if this has been posted previously, as I am a noob. Thanks in advance.

What are the most "recommended" cameras that work with SmartThings currently (2017)?
(www.rboyapps.com - Make your home your butler!) #1081

The Foscam Motion Alarm Monitor has an option to take a picture when motion is detected. This picture is stored in the ST cloud and can be accessed by the ST mobile app.

There’s is also a setting on the camera itself (which can configured via the device settings) where it can be configured to take a picture and email it to the yourself / save it on the SD card / FTP server. Two separate settings.

1 Like
(www.rboyapps.com - Make your home your butler!) #1082

###Foscam Camera Universal Device Handler - version 03.04.05

  • Added check to ignore http:// or https:// entered by users accidentally in the IP address field

###Foscam Motion Alarm Monitor SmartApp - version 02.07.01

  • < no change >

Some users accidentally put a http:// or https:// in the IP Address/URL field. It requires only an IP address (e.g. 192.168.1.50) or a URL (my.camera.com)

(Blake Northrup) #1083

Ok, thank you. Keep up the good work man.

1 Like
(Robross0606) #1084

Is there any existing ability (or plan) to provide a way to use the speaker on a 2-way camera for playback? I’d like to be able to play a specific sound thru the speaker on motion detection.

(www.rboyapps.com - Make your home your butler!) #1085

There’s no way to “send” audio to the camera through ST, the 2 way is limited to live viewing and ST doesn’t support sending audio return yet.

(Raymond King) #1086

@RBoy I’ve been able to connect everything up for my C1 I just received. However, when I view the image in Foscam it’s pretty clear. When I view in ST, sometimes it looks good but most of the time it’s very green. Is there a specific setting I need to change somewhere?
Foscam App Screenshot
FoscamScreenshot
ST Screenshot
ST_screenshot

(Raymond King) #1087

@RBoy now all of a sudden my camera wont even show up. it always shows Camera Unavailable. Are there any logs i can look into to see what the problem is?
Edit: I’ve looked into the live logging and i can see thats it’s reaching out to the right address (blocked out IP and password):
5d09f77d-d2c8-4cf8-96c7-4c67ba3b7598 1:50:58 PM: trace Called getInHomeURL, returning http://*****:80/videostream.cgi?user=camera1&pwd=&resolution=32
Edit: I completely removed the device from ST and added it back. I can now see the green screen again. It’s using rtsp link correctly now
rtsp://camera1:
@****:554/videoMain <-- correct address
But it is still showing up as green. When it initially connected, the color was correct but since it has stayed green no matter what i do

(www.rboyapps.com - Make your home your butler!) #1088

The green screen is an issue with the ST mobile app video tile (I’m guessing you’re on Android). What has worked for folks in the past is to

  1. Reboot the phone
  2. Reboot the camera
  3. Play with the MJPEG settings

One of these three things usually resolves the issue, but again it’s phone/ST dependent

(Yury Rabinovich) #1089

Hi,

I’m using the Foscam Handler and everything works as expected. Just using it to enable/disable motion detection based on home/away. Issue i’ve run into is when I set detection area settings in the camera portal they are being reset to defaults the next day even on cameras that are in ST but have not had any actions taken on them by ST during that time period. Same thing happens on two different type of foscam cameras.

Any idea of how to get the detection area settings to stay?

(www.rboyapps.com - Make your home your butler!) #1090

You will need to define them in the device handler settings page (requirement of the Foscam API). If you have the detection parameters you can enter them directly.

If you need help to understand how to create the detection parameters, see this post for details:

1 Like
(Raymond King) #1091

@RBoy so I have my camera working inhome and outhome but it sucks that I have to change the IP of the device based on where I am.
Like, if I have my phone and I’m not on my home wifi because im away i have to edit the device and put my home’s publish ip address. If i’m behind my router, obviously I have to put my in-home IP address. Is there a way to make it where both will work without changes to properties?

(www.rboyapps.com - Make your home your butler!) #1092

Not required. Not sure why you’re switching IP addresses. This is how internal and external IP addresses work:

  1. Using the the LAN IP address works inside and outside the house as all communication is routed through the hub
  2. Using an external IP address will work inside and outside the house IF your router supports loopback connections (i.e. it detects that the IP address is it’s own public IP and loops it back). If your router doesn’t support loopback connections then you won’t be able to communicate while inside the house (but will work outside the house).

You’re best off using 1 (except for video which requires a direct connection between your camera and your phone) for best compatibility with routers.

If you’re using video then get a router which supports loopback connections and use 2.

(Nick Baker) #1093

Hi RBoy

I noticed a while back someone asked about R2 support but couldn’t see any updates since then. Well I have an R2 and wanted to set that up with your DTH so have made some modifications and it all seems to work ok. Just thought I would share them with you so you can build them into the official release if you wanted to.

The problem stems from the fact Foscam made a new API for cameras that support multiple detection zones. Everything else is the same apart from the command name and the detection area formatting.

I added the following option after your “hdcamera” in the preferences to enable for an R2 device - note you need to enable both hdcamera and r2camera because I haven’t changed every reference to the API, just the motion detection bits that have changed. There is probably a better way of doing this (combine them both into an enum field?) but that would mean changing all the rest of your “if (hdcamera)” logic.

input("r2camera", "bool", title:"Enable this if the camera is a R2 model?", description: "R2 Model", required: false, displayDuringSetup: true)

The new alarmOn and alarmOff functions are as follows:

def alarmOn() {
	log.debug "Enabling Alarm"
	if(r2camera) {
        delayBetween([hubGet("cmd=setMotionDetectConfig1&isEnable=1&snapInterval=1&sensitivity=${getMotionLevel(motionLevel)}&linkage=${getMotionAlarmEvents()}&triggerInterval=${getReArmInterval("15s")}&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&${getDetectionArea(detectionArea)}&1421696056773"), hubGet("cmd=setAudioAlarmConfig&isEnable=${soundAlarm ? "1" : "0"}&sensitivity=0&linkage=${getMotionAlarmEvents()}&triggerInterval=${getReArmInterval("15s")}&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655"), poll()], delayInterval())
    }
    else if(hdcamera) {
        delayBetween([hubGet("cmd=setMotionDetectConfig&isEnable=1&snapInterval=1&sensitivity=${getMotionLevel(motionLevel)}&linkage=${getMotionAlarmEvents()}&triggerInterval=${getReArmInterval("15s")}&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&${getDetectionArea(detectionArea)}&1421696056773"), hubGet("cmd=setAudioAlarmConfig&isEnable=${soundAlarm ? "1" : "0"}&sensitivity=0&linkage=${getMotionAlarmEvents()}&triggerInterval=${getReArmInterval("15s")}&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655"), poll()], delayInterval())
    }
    else {
    	delayBetween([hubGet("/set_alarm.cgi?motion_armed=1&motion_sensitivity=${getMotionLevel(motionLevel)}&motion_compensation=${lightCompensation ? "1" : "0"}&sounddetect_enabled=${soundAlarm ? "1" : "0"}&sounddetect_sensitivity=9&mail=${motionEMail ? "1" : "0"}&upload_interval=${motionSnap ? "1" : "0"}&"), poll()], delayInterval())
    }
}

def alarmOff() {
	log.debug "Disabling Alarm"

    if(r2camera) {
		delayBetween([hubGet("cmd=setMotionDetectConfig1&isEnable=0"), hubGet("cmd=setAudioAlarmConfig&isEnable=0"), poll()], delayInterval())
    }
    else if(hdcamera) {
		delayBetween([hubGet("cmd=setMotionDetectConfig&isEnable=0"), hubGet("cmd=setAudioAlarmConfig&isEnable=0"), poll()], delayInterval())
    }
    else {
    	delayBetween([hubGet("/set_alarm.cgi?motion_armed=0&sounddetect_enabled=0&"), poll()], delayInterval())
    }
    
}

And finally the only other change was to the getDetectionArea function, which now reads as follows. Note for this to work I also removed the default value for the detectionArea preference - as the full frame default for other cameras already seems to be defined in this function anyway

private String getDetectionArea(area) {
	log.trace "User entered detection:$area"
    
    if (area?.trim()) {
    	// Remove any trailing or leading & if entered accidentally
        area = area.replaceAll("^&+", "") // Leading &
    	area = area.replaceAll("&+\$", "") // Trailing &
        return area
    } else if (r2camera) {
    	return "x1=0&y1=0&width1=10000&height1=10000" // Default is full frame detection
    } else {
    	return "area0=1023&area1=1023&area2=1023&area3=1023&area4=1023&area5=1023&area6=1023&area7=1023&area8=1023&area9=1023" // Default is full frame detection
    }
}

Hopefully if you don’t want to include this in the release version this post might be handy to someone else out there who has an R2 as well :slight_smile:

Nick

1 Like
(www.rboyapps.com - Make your home your butler!) #1094

Great to see, but we added R2 support quite some time ago (Jan 2016). There an option in the settings (if you’re on the latest version) that asks you to select the camera Model. R2 models are also known as the Ambarella series. There are many more changes to the API for the Ambarella series, check out the below.

Here’s the release notes for the R2 support:

Here are the configuration instructions for the R2 (and other Ambarella cameras):

You may be on an older version. update to the latest version and let us know if you have any issues.