[OBSOLETE] Foscam Camera Device Handler Universal DTH with Motion Detection - SD (FI89xx), HD Ambarella FI98xx, FI99xx, Cx, Gx, Rx, Ex, Zx, Fosbaby

In addition to the motion alarm enable/disable issue, the R2’s have a number of additional features that get overwritten whenever the camera is enabled/disabled in the ST app.

1- Sound detection

The R2 has 5 different sound sensitivity levels (same as motion), Lowest, Lower, Low, Medium, High. If I change these in the official Foscam app, they are defaulted to “Low” whenever I enable the camera in ST. Could we have options to control the Sensitivity in the DH the same as motion?

2- Push Notifications

The R2 also has the ability to send push notifications in the official app (or by accessing the camera web interface). The Push notification “checkbox” is always removed whenever I enable the camera via ST. Could this be ignored in the DH or have the option to enable/disable in the settings?

Appreciate the amazing work you’ve done for those of us using Foscam cameras and hope these suggestions will be considered (especially sound since the HVAC unit turning on/off sets off a sound alarm. This R2 is crazy sensitive to noise).

Thanks again

1 Like

My camera keeps disconnecting when going to a preset or trying to PTZ the camera within ST. If no movement, camera works fine, but any movement in camera will disconnect the video. Any solutions?

Will keep in the pipeline for R2 specific customizations. In general Foscam audio are VERY sensitive. By default the DH sets the audio sensitivity to lowest because of this issue.

Thanks it appears on my R2, it defaults to “Low” (the default) which probably explains the sensitivity although the 9831W shows “Lowest” like you mentioned. Based on update notes from other iOS apps, developers mention "Fixed motion on/off for Foscam Ambarella devices (R2 and C2) so it appears the C2 is also affected but I cannot confirm as I do not have this model.

Thanks again

1 Like

Edit Xtrophy found this first too

I have finally figure out my Alarm arm/disarm issue with my C2 and FI9900P. I’m betting it works with all the camera’s having issues too.

At some point Foscam changed the commands from




i edited the device handler for the misbehaving cameras and everything works again

edit 1: of course now the motion detection doesn’t work at all. Smart thing shows the switch as enabled but it does nothing. I have a feeling that they also changed the detection area command as well.

edit2: It has something to do with the dection areas being cleared when the detector is toggled.


Sets a detection block but it doesn’t enable it.



enables the motion detection zone


Here is the code to automatically set the full frame as a detection zone



So some folks have been asking how to configure the motion detection area and enter that string in the camera settings page. So here’s are the instructions:

I got this reply from Foscam support:

Hi Xtropy, Amba S2L cameras like R2 has different CGI command than with FI9831W. Please use the correct command (setMotionDetectConfig1)

I’m working on connecting a Foscam F19821 camera using your Foscam device handler.

I’m able to connect to the cam both over my local network and remotely via port forwarding in a browser. I’ve setup port 88 for http and 8888 for https. I’ve forwarded all 3 ports, 88, 8888, and 888 (Onvif) to the camera.

In the Camera configuration in, I’m starting off with the internal ip address and port 88 but I’m getting camera not found.

Am I missing something?

[edit] Interesting development…I can snap pictures from both internal an external and they display in my client properly. It can also detect motion. th eonly thing I can do is see the live feed.


  • Marc

Have you found the area in RBoy’s code to change to fix this issue? I didn’t realise that the setMotionDetectConfig1 fixed the switch but didn’t actually enable motion detection. Would really like to get this corrected and wondering if you could advise the lines of code we need to change to fix this issue?

Figured it out. If you add the following information to line 544, things start working again:

cmd=setMotionDetectConfig 1&isEnable=1&valid1=1&width1=10000&height1=10000

Also in the same line change the setAudioAlarmConfig &sensitivity value from 0 to 4 to put the sound alarm to the lowest value

Now I have Motion working and my sound alarms are not going off every hour.

For reference the GetMotionDetectConfig1 values for the R2 are:


Whereas for the 9831W there are a lot less:


Probably take a while to get all this setup/working in the DTH so wanted to post a workaround for now

1 Like

Thanks, will build it into the next release. Am also working with Foscam to get the latest changes to the SDK.

Hi, is the live ST feed working for your 9900p? I can’t get my live feed to work but I’m able to take snapshots and receive motion detection alerts.

Yeah, live video works for me

Can you tell me how you’ve set the device settings? I’ve followed the instructions to the letter and my feed isn’t showing. Did you have to change anything in the DH code?

I didn’t change the code for live stream at all. I do have the “Enable this if the camera is a HD Model” and “Enable HD Cam MJPEG stream” toggled on


I just got the Foscam SmartApp installed with the Device Handler. Everything shows up but when I select my camera, the entire ST iOS app crashes.

My camera is a Foscam FI9821P IP camera.

Any thoughts?

This is what shows up in the Live logs when I attempt to add the camera.

f11aa46f-d5f5-4eda-b777-af6e77cdc66e  8:30:21 PM: debug motionOrContactHandler(Motion Sensor - Living room motion:inactive)
c9237577-d938-4610-99c8-1b75a9b16520  8:30:17 PM: debug getChildDevices(false), children=1
c9237577-d938-4610-99c8-1b75a9b16520  8:30:17 PM: debug getChildDevices(false), children=1
c9237577-d938-4610-99c8-1b75a9b16520  8:30:14 PM: debug getChildDevices(false), children=1
c9237577-d938-4610-99c8-1b75a9b16520  8:30:14 PM: debug getChildDevices(false), children=1
9834344f-28d9-4ebc-9193-0bb31262ee58  8:30:14 PM: trace Refresh()
c9237577-d938-4610-99c8-1b75a9b16520  8:30:03 PM: debug MediaRenderer device found[devicetype:04,     mac:B827EBC9598F, ip:C0A801EE, port:C156, ssdpPath:/description.xml,     ssdpUSN:uuid:7965344d10a7787e39d26cc4aaa5a271::urn:schemas-upnp-org:device:MediaRenderer:1,     ssdpTerm:urn:schemas-upnp-org:device:MediaRenderer:1, hub:0a35454a-4e30-43cd-9c5d-1632b227a4dc]
c9237577-d938-4610-99c8-1b75a9b16520  8:30:02 PM: debug getChildDevices(false), children=1
9834344f-28d9-4ebc-9193-0bb31262ee58  8:30:02 PM: trace poll()
c9237577-d938-4610-99c8-1b75a9b16520  8:30:01 PM: debug syncDevices()
56a1e157-b112-46f3-8aa0-52f6d8cc7787  8:29:58 PM: trace Preset names -> [null, null, null]
56a1e157-b112-46f3-8aa0-52f6d8cc7787  8:29:58 PM: trace Getting present names from camera [FoscamOne]
56a1e157-b112-46f3-8aa0-52f6d8cc7787  8:29:58 PM: trace Cruise names -> [null, null]
56a1e157-b112-46f3-8aa0-52f6d8cc7787  8:29:58 PM: trace Getting cruise names from camera [FoscamOne]
56a1e157-b112-46f3-8aa0-52f6d8cc7787  8:29:53 PM: trace Preset names -> [Invalid! Select/Refresh Camera]
56a1e157-b112-46f3-8aa0-52f6d8cc7787  8:29:53 PM: trace Getting present names from camera null
56a1e157-b112-46f3-8aa0-52f6d8cc7787  8:29:53 PM: trace Cruise names -> [Invalid! Select/Refresh Camera]
56a1e157-b112-46f3-8aa0-52f6d8cc7787  8:29:53 PM: trace Getting cruise names from camera null
9f4a2879-c4a7-4db4-8943-fc807fc1917d  8:29:53 PM: debug Parse returned {{ linkText }} has arrived
f11aa46f-d5f5-4eda-b777-af6e77cdc66e  8:29:49 PM: info SHM isActiveSensor(motion:active, app: off, location: off) = false, locationId: 64c7c4bb-9e55-4fbb-b033-c99ccad6b2cc, ISA: f11aa46f-d5f5-4eda-b777-af6e77cdc66e
f11aa46f-d5f5-4eda-b777-af6e77cdc66e  8:29:49 PM: debug motionOrContactHandler(Motion Sensor - Living room motion:active)

If there is anything else I need to get, please let me know.


Ok I noticed this is just for the Motion Smart App that this happens for. I do see the camera and Im able to add it as a thing. I have the IP address in along with the username and password. The camera shows off. If I attempt to turn it on, it thinks for a bit and goes back to off.

Are you on the latest ST iOS app? Try to delete the device and start over.
What iOS / iPhone?


I think I have it working now. I went in and set some ‘probably’ needed options after adding the camera as a thing. Now I can set it up for automation.

One thing I noticed however is when viewing the livestream, maximizing the video just makes the stream go black. Also if I try to move the camera the stream ends. There are some instances where I have to back completely out of the camera for the stream to connect again.

Just for information sake:

iPhone 7+
iOS 10.2 Beta 4
Latest ST app

Tried on my wife’s phone as well. Same phone but iOS 10.1. Same behavior

I cant get either of my foscams to stream video through the app. I followed the instructions to create a new device handler with your code, then created a device in the IDE with the device type of the Rboy foscam. it shows up as a device in the app, so i configure it but it shows camera unavailable. I have 2 C1’s, both of which i can reach with my phone and log into the web interface. ive tried deleting both cameras and the device handler, then reinstalled the handler and created new devices. They were using port 88, but i saw your note about 2 digit ports, so i changed one to port 889 with the same result. It looks like it adds the camera but for some reason the app wont stream the video. What else can i look at? Or is there just an issue with C1s not streaming in the app? Thanks!

Hello Guys! I have some problems when click +Add a Thing… Fosc… appears but then the app crash, and when open again the app, I can see a message that says “Crash manager submitted report”… could you help me?