SmartThings Community

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

foscam
dth_cameras
(skp19) #15

Updated with PTZ controls. I know SmartThings is working on an official device type for Foscam cameras, so if you guys feel like pulling anything out my device type to add to it then feel free.

(Sean) #16

Should this also work with a FI8908W? Not having luck with it.

(skp19) #17

@sgonsalves It should work. I have a FI8906W and FI8910W and it works with both of those. Can you confirm you have a hub selected with the right internal IP and port?

(Acastal) #18

With a FI9821W V2 when the alarm activates it removes other alarm configuration like schedule, email, sensitivity etc. Is this just me? Using the same device type works fine for email alarms on my other two non-HD cameras turning on and off the alarm.

(skp19) #19

@acastal Someone pointed this out to me last week also. Looks like it’s an issue with the HD cameras. I haven’t had a time to really look at it but I will probably end up adding the settings into the preferences.

(Mike) #20

I just registered to ask a question. First awesome work getting this to work with Foscam cameras! I have a few Loftek cameras that are similar (PTZ, motion, etc…).

I have a pretty good idea of what needs to be changed in this code. But what do I do with the code when done? How do I integrate it into smart things?

Thanks!

(Psychoticide) #21

@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!

(Mark Dolan) #22

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!!

(Mike) #23

@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 10.0.0.10:88
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

2 Likes
(HM) #24

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?

(llcanada) #25

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.

(Phil) #26

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 . . .

(Morgan) #27

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.

Morgan

(Psychoticide) #28

@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?

(Acastal) #29

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:

(Brandon) #30

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.

http://foscam.us/forum/loose-all-settings-when-change-motion-detection-via-cgi-t6435.html

(skp19) #31

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.

(skp19) #32

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

(skp19) #33

@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.

(Brandon) #34

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(it.data)
	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");
  }
  }
}