SmartThings Community

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

@eparkerjr Thanks for writing this! It is helping me out quite a bit on my non-HD cameras. Any luck on getting the HD cameras to keep from wiping the motion settings out? Please let me know. Thanks again!

Newbie here …

Can someone explain or point me the document that shows what I do with this code?

I love my ST and want to add my Foscam webcams to it.

Thanks in advance!!

@mndude Look at the first part of this post from another thread and follow the steps to get the device type and device created in the IDE

@skp19 My device ID didn’t change so I manually changed it to the hex version of the IP while trying to get snapshots to work. They still aren’t working and I’m at a loss as to what to do next. Any suggestions? Here’s the ST log:

99cf5e4e-4e1a-4d90-8170-1f54fe76bd55 8:51:07 AM: debug Parsing 'index:01, mac:E8ABFA10ADDA, ip:0A00000A, port:0058, bucket:smartthings-device-conn-temp, key:e3b7851c-e06c-4233-a318-8f0cd95af7d8’
99cf5e4e-4e1a-4d90-8170-1f54fe76bd55 8:51:07 AM: debug Parsing 'index:01, mac:E8ABFA10ADDA, ip:0A00000A, port:0058’
db1eee6d-f1c6-43ef-8914-e54be02550a9 8:51:03 AM: debug /cgi-bin/CGIProxy.fcgi?usr=removed&pwd=removed&cmd=snapPicture2
db1eee6d-f1c6-43ef-8914-e54be02550a9 8:51:03 AM: debug Executing hubaction on
db1eee6d-f1c6-43ef-8914-e54be02550a9 8:51:03 AM: debug Device Network Id set to 0a00000a:0058
db1eee6d-f1c6-43ef-8914-e54be02550a9 8:51:02 AM: debug Taking Photo


I have the exact same issue, with the same log… I tried the URL in a browser, and I get the image, so the setup is correct… Not sure what could be wrong?

I have a Samsung 5S and a Galaxy 4 tablet laying side by side and open it to the Smartthing and open the camera app and tool a picture and it shows up on the S5 but not the galaxy 4?? Strange, also I can take a picture with the galaxy and it shows up on the S5 but not the Galaxy? Help.

Kudos to @eparkerjr (a)scottinpollock and @pstuart. Great work! I could not write a single line of this code and I’m always amazed at those of you who can. I’m using this code with a Wansview NC541W, which seems to be a clone of the FOSCAM FI8908W, without issues. Snapshots, PTZ, and alarm work well. Allows access to the camera without opening an outside port (not an issue for me, but could be for some). My use-case only needs snaps to be saved on alarm, which I configured in the cam ui (send email). My issue was conveniently enabling the camera alarm remotely. This solves that. Next step is to activate the cam alarm with a mode change . . .

Is this the latest device type and most updated device type for Foscams?? It does seem to have the ability to turn on Sound Detection, on and off.


@acastal Did you ever find a solution to the alarm config being wiped? Or are we just waiting on @eparkerjr get some free time and tweak the code a little?

I did not. I just bought a big SD card and have it record 24x7 and have photo burst tied to a motion sensor that goes in “away” and “night” modes. I liked doing it the old way better but I like the resolution of the HD camera so much more I am willing to go without util someone figures it out. I have not tried using the HD only device type or the older/first Foscam device type (that you have to poke a firewall hole) with the new HD camera so maybe if you are more motivated you could try those. If you get something to work please report back :slight_smile:

I am having the same issue. It looks like you have to do a getMotionDetectConfig cgi command first and then just change the the desired value and set the entire configuration. Easier said than done. If get it to work I will post my code.

Haven’t been able to get on here for a while. Hopefully I can free up some time soon to add the alarm settings to the code. It should only take me a day once I get started.

@philglov I created the smartapp to enable the alarm on mode change here…

@zj4x4 @hma Are you still getting errors? There was some issues for another device type when you use the 10.x.x.x network. I’m wondering if this may still be an issue.

Someone may be able accomplish this a little more efficiently than what I did, but it work none the less.

I changed the alarm on and alarm off functions such they get the current configuration, parse the data and then pack it all back up after changing the isEnable bit. I would not be surprised if this could be accomplished in 1 or 2 lines of code by someone more knowledgeable.

This will be a little be a little different for the Foscam Universal Device Type since I was using the Foscam HD device type, but you get the gist.

def alarmOn() {
  api("get_params", "cmd=getMotionDetectConfig") {
    def CGI_Result = new XmlParser().parse(
	def a_data = CGI_Result.linkage.text()
	def b_data = CGI_Result.snapInterval.text()
    def c_data = CGI_Result.sensitivity.text()
    def d_data = CGI_Result.triggerInterval.text()
    def s0 = CGI_Result.schedule0.text()
    def s1 = CGI_Result.schedule1.text()
    def s2 = CGI_Result.schedule2.text()
    def s3 = CGI_Result.schedule3.text()
    def s4 = CGI_Result.schedule4.text()
    def s5 = CGI_Result.schedule5.text()
    def s6 = CGI_Result.schedule6.text()
    def a0 = CGI_Result.area0.text()
    def a1 = CGI_Result.area1.text()
    def a2 = CGI_Result.area2.text()
    def a3 = CGI_Result.area3.text()
    def a4 = CGI_Result.area4.text()
    def a5 = CGI_Result.area5.text()
    def a6 = CGI_Result.area6.text()
    def a7 = CGI_Result.area7.text()
    def a8 = CGI_Result.area8.text()
    def a9 = CGI_Result.area9.text()
    def AlarmData = "isEnable=1&linkage=${a_data}&snapInterval=${b_data}&sensitivity=${c_data}&triggerInterval=${d_data}&schedule0=${s0}&schedule1=${s1}&schedule2=${s2}&schedule3=${s3}&schedule4=${s4}&schedule5=${s5}&schedule6=${s6}&area0=${a0}&area1=${a1}&area2=${a2}&area3=${a3}&area4=${a4}&area5=${a5}&area6=${a6}&area7=${a7}&area8=${a8}&area9=${a09}"
  api("set_alarm", "${AlarmData}") {  ///Changed from "isEnable=1" to "${AlarmData}"
    log.debug("Alarm changed to: on")
    sendEvent(name: "alarmStatus", value: "on");

Thanks @eparkerjr. I found your mode alarm code and have been using it for the past two weeks. I suspect there is a nuance delta between the Foscam and the WansView where the on-alarm configuration (email, or FTP) does not persist between mode changes, which may have been mentioned in this thread. That said, I am thoroughly enjoying your code and hope to eventually write a line or two. Thanks for your reply!

@eparkerjr I gave up on it because neither this one or a one in another thread was working for me. However, I’m ready to dive back into it because I need a camera integrated with SmartThings (2 actually, but I want to make sure this works before I buy another one). I have a 10.x network which wouldn’t be terribly painful to change to something else but on the other hand it would be nice for this to work regardless of your IP scheme. Anything I can do to help?

I was finally able to change my home subnet to a 192.168 address scheme and the camera started working instantly.

This is great. I added the code to skp19 Foscam HD Device Type but it’s not working.
Can you share the whole device type code?

The edited code can be found here.

Works great. Awesome job