Authenticate Foscam IP camera for HTTP Post Commands

Right, so I think that documentation for functions such as this will be released when dropcam support officially gets released.

Vera has a plug in for Foscam (and most other ip cams) - works like a charm.

Yup…

Well… The DropCam demo was pretty good, so I guess the functionality is coming along in ST. Looks promising.

Keep in mind: We are “volunteer developers” (at the moment, no income stream in this…), so SmartThings benefits from our attempts to develop Device Handlers such as for Foscam IP-Cameras.

I think it is actually pretty typical in the industry for Developer-Partners to get advance knowledge of APIs (even if subject to change…) so that they build the value-added functionality ahead of public release dates; i.e., so that Foscam could be ready (along with DropCam) right out of the gate.

Thanks for passing the message along,
…CP.

What happened to the rest of the Dropcam device type code? I didn’t get a chance to save it and now looks like the important stuff is gone.

Hey guys, I’m sorry I had to take down the Dropcam device handler – it turns out, we do not have permission yet to post the their API details.

That said, SmartApp functionality for Dropcam is coming along, and when it is complete, Build community members will be the first to know.

-Zach

I may or may not have some “residual” bits of you-know, for those that want to play dangerously and contact me via private message.
Contact information is in my profile.

…CP.

I’ve worked a little on the DT for Foscam. A lot of changes, including tiles that work (sort of)!

No image/take function yet, can’t seem to figure out how to deal with the result from the camera to actually see it.

Still no poll, tiles are based on last value from the SmartThings platform only. So, if you turn the alarm off using the camera’s web interface or another IP cam app, the tiles will not update to show current state.

https://gist.github.com/ronnycarr/6218175

Might be able to add a SmartApp that does scheduled polling and triggers an Event to update the tile…

That sort of thing is only hard to figure out the first time, then it starts to make sense pretty quickly…

Hey All,
I want to share a little about a Foscam prototype I put together and I hope to post as soon as a little new functionality goes live (most likely) at the end of this week.

Using the FI8910W, I can send basic httpGet requests to the cgi web interface. This allowed me to move the camera along both axis (decoder_control.cgi?command=${num}) and to request frames as jpgs (calling snapshot.cgi). Configuring presets is also a great element.

The most complex part of the setup really comes from the networking configuration. For now, you’ll need to setup port forwarding in order to send commands from the Smartthings cloud to the device.

The down side is that the Foscam model I have does not (to the best of my research) allow for SSL Certs. Several of their newer/less-common models do, I am told, however they appear to use self-signed certs - which we currently deem a security risk and do not allow. So, at least on the models I’m aware of, the lack of SSL means one has to send camera login info unencrypted. That’s certainly been part of my hesitation about sharing the code.

That said, I intend to post the device type prototype as soon as the new functions go live. Perhaps other folks in the community can weigh in on the security issue.

While it’s not exactly a mainstream approach - I’d also love to hear if anyone has experimented with adding custom firmware to an ip camera
along the lines of the work done over at openipcam.com.

Thanks,
Danny

@megapixel (Danny): Thanks for your research and experiments and reporting the results.

Folks like myself who already access our cameras remotely, are either using Foscam’s dynamic DNS service, or an alternate.
I’ve also never found basic port forwarding to be complex; though I don’t know if Foscam would at least support uPnP to configure routers automatically. I don’t like uPnP updating my router’s port forwarding without my knowledge, though.

Use of non-https for the camera connection is certainly a major complaint, but, realistically for home applications (so far…?) cameras have not been a major attack vector. The most basic precautions are: use a non-standard port number (not 80, but perhaps 9967), use username and passwords that are not used for any other purpose (and change periodically), and review the camera’s logs frequently.

Adding Foscam support to SmartThings does not significantly increase the risk (unless your data stores are likely to be compromised?).

Thanks,
…CP.

@megapixel I am excited about the impending release of the foscam device type! The security risk you mention is already there for those of us who own these and open ports to view the cameras. The android app I use to view the cameras now sends the login info unencrypted. I don’t care if someone targets my camera and tries to hack it :slight_smile:

This will open a whole range of cameras that have been on the market for years. I have an older Linksys WVC54GCA that I will be able to use after tweaking your device type, also.

Need a tester?
Scott

@av9rdude, I should have thought to mention that the Image Carouse for the Foscam device type is only now live in the iOS app.
The Android team is catching up to the capabilities of the iOS app, but I know that the Image Carouse has not yet been created.
That said, I do have one idea for working with images outside of the app. I’ll give it a try and share what I find.

Hey all,
I wanted to share the example Foscam device type code I mentioned.
I’ve also written a Tutorial/writeup on it for the next developer newsletter.

A couple updated features went live today that made it possible:

First the “carouselTile” allows us to show stored images (in the iOS App):

carouselTile("cameraDetails", "device.image", width: 3, height: 2) { }

and the “StoreImage” function allows us to save captured images:

storeImage(getPictureName(), imageBytes)

Called together, (with the “Image Capture” capability checked off in the device type) we’re able to scroll through images take by the camera with just a few lines of code.

Take a look - full code below. I will update and link to the tutorial as soon as it’s published.

Thanks,
Danny

Looking forward to developments here. from @megapixel 's demo, things work decently - but hoping to add in the alarmOn() and alarmOff() tile from @ronnycarr . Tried to splice them together last night, but the lack of documentation is pretty frustrating.

Also hoping for some means to either encrypt credentials or allow the hub to access locally (thereby avoiding port forwarding). Polling would be a huge plus to grab state of the world info. I’ve created a very simple smartapp to set alarmOn and alarmOff based off modes, so when my presence tags are away, the Foscam automatically starts looking for motion and uploading to an off-site FTP. Getting very close to properly usable, but a few rough edges. Also on android and awaiting the image viewing functionality there.

Hey @ImBrian,
Just posted some thoughts on possible trouble spots for you on the tutorial thread.

You can find the building blocks for standardTiles in the documentation baked into the IDE:
https://graph.api.smartthings.com/ide/doc/deviceType

That said, it’s not the friendliest place to start. I’ll plan on covering tiles in an upcoming post - hopefully in an approachable way.

We’re also blazing forward on our local-ip connectivity. I think that’s probably the easy way to avoid port forwarding.
Should be coming out pretty soon - still working out the rough edges.

-D

@megapixel - that’s awesome news! I was about to put an order in on a Raspberry Pi and Razberry daughterboard to hack together a proxy device so that I could use my Foscam externally - among other things.

Starting to look now at parsing Foscam configuration settings on poll, as they are fully exposed in a reasonably friendly split’able output here:

http://192.168.0.100:8080/get_params.cgi?user=admin&pwd=abc123

With local IP connectivity, I’m also very interested in trying to write a TV remote tool, as Samsung smart TVs allow requests to be made via TCP - with the caveat being they have some strange header requests (and base64 encoding) that I’m not sure how easily can be ported to Groovy / SmartThings. Here’s a basic implementation in python: https://gist.github.com/danielfaust/998441

Hi @megapixel,

Has there been progress on allowing local-ip connectivity in ST? In addition to Foscam, I want to connect other devices to ST (ie. Envisalink) without exposing them outside a firewall.