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

dth_security
smartapp_security
dth_sensors
dth_cameras
rboyapps

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

NOTE: Some folks who are installing/configuring this from the Android SmartThings App facing this issue can use this work around for the number input bug. While entering the port number for some users the ST app will complain that the user hasn’t entered all the fields. This is because of the bug in the latest ST phone app which expects atleast 3 digits while entering a number, so if you want to enter 88, then you need to enter 088. If you’re facing this issue, please report it to ST support and this message will be removed once ST has fixed the bug.

###We’ve created a customized version for the Foscam Device Type which allows for integration of the IP Camera’s into SmartThings. There are a few versions floating around here on the forum. This device type started by putting together the base working parts of those with tons of bugfixes, enhancements, new features, add on’s and bell’s/whistles’s and now added support for Live Streaming! We’ve even been touch with Foscam to add new features to their upcoming lineup for cameras. Features include:

  1. Live Video Streaming Directly from your ST Phone App
  2. Ability to put HD Camera’s into SmartTiles compatible mode (MJPEG mode) and get URL to watch live stream through a browser using SmartTiles
  3. Use the camera Motion Detection feature and report it as a Motion Sensor event to get notified or trigger an alarm. NOTE: to use this feature you MUST install the Foscam Motion Alarm Monitor smart app (now with support for HD and SD Cameras). This can be found on the RBoy server in the Smart Apps directory. The app has features such as triggering an Alarm, switching on lights, turning on the cruise function when a motion alarm is detected etc. SD Camera’s support Push Alarm notifications also which are enabled by default.
  4. Enabling camera built in actions when motion is detected (eMail notifications, sounds, starting video recording, taking pictures when motion is detected). You can set this up for activation on a mode change.
  5. Configure the sensitivity and trigger interval for the monitoring functions through the Preferences page
  6. The camera is setup as a Alarm, Relay, Imaging device and Switch. So this can be used with most standard apps and phrases. When using as Switch, turning it will enable the Motion Detection, turning it off will Disable the Motion Detection. Similarly when using an Alarm, turning it on will Enable the Motion Detection and turning the Alarm off will disable the Motion Detection. When the Strobe is enabled, it also takes a picture along with enabling the Motion Detection.
  7. Reset the camera to specific presets on modes and alarm events
  8. Tiles have new icons and show the names of the configured shortcuts in preferences instead of generic names
  9. Remote reboot functionality
  10. Added the ability to use public URL/hostnames for the camera instead of IP addresses
  11. Support for reverse proxy setups when using public URL/hostnames
  12. Get the current LED status (even in Auto mode)
  13. Integration with SHM for arming/disarming motion detection when SHM modes are changed
  14. Controlling the camera (mirror, flipping, pan, tilt, cruise, LED’s, taking images etc) from the device interface on the smartphone
  15. Control LED’s through CoRE (or other SmartApps) using the following custom commands ledOn, ledOff, ledAuto
  16. Activate/stop cruise through CoRE (or other SmartApps) using the following custom commands cruisemap1, cruisemap2, stopCruise
  17. Activate presets through CoRE (or other SmartApps) using the following custom commands preset1, preset2, preset3
  18. Turn on/off Motion Detection through CoRE (or other SmartApps) using the following custom commands alarmOn, alarmOff

LIVE STREAMING NOTE: You need a DIRECT connection between your Phone and the Camera for live streaming to work. If you’re using a private IP address for your camera then live streaming will work ONLY from within your private LAN. If you want to access your camera live streaming while you’re outside your network, ensure that you’re using your public IP address/URL/port and have enabled port forwarding on your router.


MOTION DETECTION FEATURES: Motion detection can be configured to take pictures, eMail, video, local alarm etc and also use the motion alarm notifications to set off actions in SmartThings (can used as a motion sensor). Motion detection eMail feature requires the camera to be initially configured through the camera’s web interface as the motion detection eMail will be sent by the camera and not the SmartApp. Similarly the duration of the video etc need to be initially configured through the camera web interface, the video capture is done by the camera on detection motion and cannot be triggered by the SmartApp.


Also added a Smart App called “Trigger based Camera Pictures which allows you to use triggers (motion sensors, contact/door sensors, momentary switches like door bells) to activate the Camera to take pictures and turn on switches and enable Camera monitoring optionally. The pictures will show up in your SmartThings camera device page.


##Instructions for installing Device Type:

  1. Login to your IDE at https://graph.api.smartthings.com (create a login if you don’t have one AND opt in for the developer account)
  1. Click on “My Device Handlers”
  2. Click on “+Create New Device Handler” on the top right
  3. Click “From Code”
  4. Copy paste the code into the editor and click “Create”
  5. Click “Publish” and then “For me” on the top right
  6. Click on “My Devices”
  7. Click on “+New Device” on the top right
  8. Enter a “Name”
  9. For “Device Network Id *” enter 2000
  10. Under “Type *” select the new device type you just created (it will show up at the bottom of the list called as RBoy Foscam IP Camera) (IMPORTANT: Do NOT select Foscam from the middle of the list)
  11. Select your “Hub” (very important step!)
  12. Select your “Location”
  13. Click “Create”
  14. Open you SmartThings App on your phone (iPhone or Android), under “Things” (in the Location page, bottom bar second tab with the 4 squares) look for your new device
  15. Open the device page, on the top right click on the 3 vertical dots and select “Edit Device”
  16. Enter the details (IP Address, port, username (case sensitive), password etc) and finish the configuration and click Done.
  17. Scroll down and click on “Refresh” to load the new settings. You’re Done!

FOSCAM and NON-FOSCAM MODELS SUPPORT: This works with Standard Definition Foscam (SD) camera’s (8910/8916/etc), High Definition Foscam (HD) camera’s (9816//9821/9826/9831/etc), new specialty HD foscam’s (C1/C2/etc), HD dome cameras (9851/9853/8919/9828/etc) and other Foscam HD and SD cameras.
This also works with compatible camera (based on same hardware/firmware). However please verify the compatibility of the camera and see this thread for more details.

FAQ’s

  1. I constantly see “Foscam Motion Alarm Monitor” in the recent activities tab, how do I get rid of it?
    That’s done by the ST platform when the SmartApp asks the Device Handler to check for any motion alarms. Since it’s done by the platform there is no way to get rid of it.

  2. Will this device handler also report motion alarms from the camera?
    Yes, but to use this feature you MUST install the Foscam Motion Alarm Monitor smart app.

  3. How do I get Live Video Streaming to work with my camera?
    You need a DIRECT connection between your Phone and the Camera for live streaming to work. If you’re using a private IP address for your camera then live streaming will work ONLY from within your private LAN. If you want to access your camera live streaming while you’re outside your network, ensure that you’re using your public IP address/URL/port and have enabled port forwarding on your router. If your stream is slow or dropping frames, then you connection between the camera and phone is the issue. Try rebooting your camera and router and see if it helps.

  4. Live view can’t seem to connect or I get an error
    Try a few times, this a BETA viewer and ST hasn’t made an official release, so you may need to try connecting a few times before it works. If it still doesn’t work then your camera isn’t able to connect to the phone. [Check phone capabilities and signal strength] ([RELEASE] [Universal] Foscam Camera Device Handler with Discovery, Live Video Streaming, Motion Sensor/Alarm Integration - SD (FI89xx), HD (FI98xx, FI99xx), Cx, Rx, Ex, Fosbaby). Also note that the streaming depends upon the phone’s capabilities, e.g. does it support the codec, format and bitrates that the camera is sending to the phone since it’s a direct connection. Also the ST video tile is VERY sensitive to stream errors and delays. So if the first few packets are delayed or corrupted the stream may not work. Try rebooting your camera and router which helps. Also use a fast LAN instead of port forwarding over the internet to troubleshoot. If one works and not the other it’s likely the delay that’s causing the issues. These are not issues with the device handler but more with the network/setup/phone.

  5. How do I get video streaming to with SmartTiles?
    If you have a SD camera (640x480 or less resolution) then use this URL in SmartTiles http://IPADDRESS:PORT/videostream.cgi?user=USERNAME&pwd=PASSWORD.
    If you have a HD Camera (720p or high resolution) AND your camera supports MJPEG (check the specs), then enable the MJPEG mode in the Device Preference from your ST Phone App and then use this URL in SmartTiles http://IPADDRESS:PORT/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=USERNAME&pwd=PASSWORD

COMMON TROUBLESHOOTING STEPS (Read this before posting):

  1. The device handler works fine, if you’re facing an issue it’s likely a mis-configuration (case sensitive username, case sensitive password, port, ip address or camera type (enable HD for High Definition cameras 1280+ pixels). Also check your network configuration, the camera should be able to access the internet AND the hub (same subnet). Check your IDE live logging and see if the camera responds to the refresh button. If all is configured correctly you’ll see the responses from the cameras. You can also copy paste the debug URL’s from Live Logging into your browser to ensure that your parameters are defined correctly.
  2. If the camera is inconsistently working it indicates a communication issue. Usually rebooting the camera AND hub will solve your issue.
  3. If your camera functions like up/down/reboot etc are working but you cannot take picture and motion detection not working then it’s likely you have a corrupted device installation. In this case you need to change the IP Address or Port on your camera and then go to the device preferences and enter the new IP Address/Port there. This is the ONLY solution (ST platform remembers IP/Port instances and hence reinstalling has no effect on the corruption, only changing the IPAddress/Port works here). [See this for details] ([RELEASE] [Universal] Foscam Camera Device Handler with Discovery, Live Video Streaming, Motion Sensor/Alarm Integration - SD (FI89xx), HD (FI98xx, FI99xx), Cx, Rx, Ex, Fosbaby)
  4. If your picture works sometimes, suddenly stopped working or is tearing apart, this is due to a slow platform/hub/camera. Try rebooting your camera and hub usually it works. If not, then the LAN communication is too slow and is timing out. Try using your Public IP address in the settings and make sure your router has port forwarding for your camera setup. That enables direct communication between the camera and the cloud bypassing the hub which is usually faster.
  5. To use public IP address/hostname make sure you’re enabled Port Forwarding for your camera in your router. Also try not to use port 80 (change it to e.g. 88) and try rebooting your camera. It’s the hub that communicates with the camera to ensure that they are on the same network.

More features to be added, if you have any suggestions or ideas please feel free to ask and we’ll try to add it.

###This device type handler and the SmartApps are available on the RBoy ST SmartApps Server, http://smartthings.rboyapps.com. Refer to our facebook page below to get access to the server.
If you like the Apps consider supporting our development efforts. Visit our Facebook page for updates on new apps and to get Access to all our Premium ST Apps Server. http://www.facebook.com/RBoySTApps

The latest version of these apps with udpates are available on the RBoy server.


Best camera options for SmartThings integration
Foscam Images - save, send, etc?
Mode setting for Supplementary Foscam App, Foscam Motion Alarm Monitor
Experience with integrating the Foscam FI9900P anyone?
Best Smart Camera
Any Recording system for Surveillance Camera work with ST?
FOSCAM C2 Lightning deal $70
New and looking for a hand
Enable Motion Detection/Recording when Away & Disabled when Home?
Not sure to understand which devices need a ST Hub or not
[RELEASE] FOSCAM Camera LED Controller
[SUSPENDED] Blink Camera Device Handler with Motion Sensor, Live Video Streaming, Integration with SmartThings/SHM, Temperature, Signals and Push Notifications
Foscam as motion detector
Anyone have a working foscam FI9826W?
Foscam as motion detector
Ip outdoor camera
[RELEASE] Trigger based Camera Pictures and Actions
Camera Selection Help for Newbie
(Acastal) #2

Your site is asking for a username and password to log in.


(Morgan) #3

@RBoy Do you have a screen shot of what the updated device type looks like so I can decide whether it is worth putting 10 bucks into?


(Eric) #4

His Facebook site explains you pay to play…so the site won’t let you in without that $10.


(Acastal) #5

I figured that out from other posts. I guess it should be explained better in the OP.


(Eric) #6

I paid up and got access…I actually like someone is creating a place to get some purpose built apps…there some good surprises in there. My Foscam comes tomorrow so will try this app out then.


(Acastal) #7

do post your experience. I for one would find it useful. thanks.


(Eric) #8

So far The FOSCAM camera stuff doesn’t work. Trying to make the device type in the IDE, and it times out every time. No idea if its the IDE or the code. Pretty sure its the IDE being its wonderful self.


(Eric) #9

After a half hour of putzing, I have an device type in there and its in my Things…but doesn’t seem to do much. I see no video, clicking on “take” just changes the icon color and nothing happens. Things like what “on and off” do have no context…I expect a video stream in the big gray area at top and nothing. Tried to move the camera via controls and presets and nothing.

Alternately, I put my Foscam info in the Action Dashboard, and boom, its there.

No idea if we even get support from these guys as they provide no info on it.

Trying his locks stuff next. Have a Kwikset that I can already change codes with via a different app using custom device type from the community. Some info on this thing but not enough to answer my basic questions either. I think maybe you need his device type, but it doesn’t really say.


(Jody) #10

You will not see a video steam in this or any other device type. At least in the ST mobile app. The platform does not currently support streaming video. This is something that should be addressed when hub V2 is released.


(Eric) #11

thanks for that reminder. None of the other functions work either for the camera, and neither do the locks. Regardless, while he may believe he has enough info published, I am approaching like a normal user and hit roadblocks.

I have other comments I will drive into the other thread after I get to Napa tomorrow.


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

True, these found familiar perhaps I’ll put a note with the limitations and sample use cases.

ST platform doesn’t support support video streaming (as @jodyalbritton said it’s something in the pipeline). Right now it’s just control and static stuff (like images). If I understand the Action dashboard, that’s actually a browser service, so you’re not using the ST app rather a browser capabilities which allows you to use the stream function of the webcam.

The way this code was designed was to allow “control” and “event” integration with SmartThings, so for e.g. when you “arm” your security (enable motion sensors), the motion tracking feature - which looks for motion and sets of events (emails, sound, video recording, pictures etc) when there is motion detected.
Couple of things to note, the initial configuration (eMail server, FTP storage/SD storage) is done via the Foscam web page.
SmartThings device code can be used to control the enabling/disabling of the various events, the sensitivity. So here’s an example.
When mode is set to night, turn on the Foscam device (i.e. monitoring is enabled, now it looks for motions). In the device preferences you can set the options, sensitivity of motion (high, low etc), whether it should send an eMail, sound a local alarm, take pictures, record video etc when the motion is detected.
Similarly another use case, you can configure this as an alarm. e.g. when motion is detected, turn on the Foscam Alarm - this will enable the motion sensor and if strobe is selected it’ll also take a picture. This picture BTW will show up on your ST app device.
The Take picture button takes a picture and then it shows up on your ST app. If you aren’t seeing the picture than likely ST isn’t able to connect to the camera. The picture is more for reviewing the events of an alarm motion event.
The pan controls, while present I didn’t find particularly useful since there’s no streaming video, however the reboot button and cruise button are helpful. The Cruise can be enabled via a smart app, so when the alarm is set off using a custom app you can enable the cruise which in then while the camera is recording it’ll take a sweeping video of the room while cruising.

Once ST supports video streaming will see how to integrate the camera streaming services into the app as well.

Hope that helps.


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

If no functions are working then it’s not configured properly, check your preferences. Are you using an internal ip address or external ip address (if external, have you configured port forwarding). Similarly have you configured the correct ports, username and password?

I’ve setup it up with an external IP address, port forwarding and it’s working beautifully even from the internet, check your settings (preferences) once more. If it’s an private IP address you can only access it from your LAN and if it’s an external make sure you have loopback disabled on your router or it won’t work.


(Eric) #14

While I appreciate your response, I will highlight that I mentioned I used the same credentials in the Action Dashboard without incident, and will now mention I used the same via the official Foscam app. All function and all use an external ip with proper port forwarding.

As has been contended elsewhere that the fee includes support, but you don’t publish any vehicle to provide as far as I can find, I have to resort to public feedback. I would prefer to use a proper support vehicle. Despite my skepticism I gave this a shot mostly out of curiosity to how you planned to make a go of this.

If you want to blaze the trail of paid apps before the ST store exists you have to uphold a higher standard of support than the open source contributors here do.

Just a thought from a far too gray CTO from the battles of being a software cloud provider before there was that term.


(Eric) #15

Thanks. Where does it show up in my app device, these pictures?


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

The pictures show up on the First tile in the app. One thing I’ve noticed if the pictures aren’t showing up and other buttons are working fine then there’s a “timing” issue, the foscam firmware may be running slow. I hit the Reboot button on the app and try again after a minute and that usually works for me.


#18

If I have my Foscams connected to POE and then plugged into my router, will Smart things be able to control them with this additional app functionality, or do they have to be on wifi for this to work?


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

As long as smartthings is able to connect to the webcam it doesn’t really matter whether it’s connected via ethernet or Wifi, infact ethernet would be a more stable/reliable connection than WiFi.

Best way to confirm, If you’re able to connect to the webcam web login/interface from your browser it should work fine with smart things. First start with your internal lan ip address (check via browser web interface), then enter the same in the device preferences (and port), try turning on/off the IR LED’s, if that works fine then try to connect via external ip address/url.

If you’re using an external ip address to communicate make sure you setup port forwarding correctly and I would recommend not to use the default port 80 (since many ISP’s block it, sometimes it’s in use by other UPnP apps which override the router port forwarding etc). Use something like this:
HTTP -> 88
HTTPS -> 8888
ONVIF -> 888

These would have to be configured through your foscam web interface and also in your device code preferences (use the HTTP port there).


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

Thanks for Chris Jefferies for finding this. If your Snap (take picture) feature is not showing up on your ST App tile, see this message from him:

OK got it to work. my mistake, it was me. looks like if you don’t have it accessible via a public IP, the cam controls work, but the picture doesn’t. I made the camera public and the snapshot works. it doesn’t support SSL, so I didn’t want to do that. . . I’m going to try and proxy it through stunnel so the public communication is going thru SSL. I’ll let you know how that works.


(Chris Jefferies) #22

Oddly enough,after making those changes, when I pointed the device config back to the LAN IP of the foscam, maintaining the (arbitrarily chosen) port I changed it to, the snapshots still worked.

Subsequently, I had it work and sometimes not work – especially if I tried taking a few shots quickly in a row.

When it works, the Live event logs for the camera device look something like this:

Executing hubaction on 172.16.20.2:578
/snapshot.cgi?user=alias&pwd=fakepassword
Parsing ‘index:01, mac:DEADBEEFAAAA, ip:1BC1AF3, port:7A69, bucket:smartthings-device-conn-temp, key:123456-7890-1d34-beef-3445dddddddab’

When it doesn’t work, you never get to the Parsing line.

In further testing it shouldn’t matter whether you use an internal or external IP as the hub itself is making the http request to the camera to pull the image (I believe RBoy mentioned this at some point).

For security purposes, be aware that requesting the image from over the internet in clear http (e.g. in using an external IP for smartthings access) could easily expose your username and password for the camera. That said, so can using the foscam at all over the internet without proxying the connection. But it’s fine for playing around or testing – just make sure you use a throwaway u/p and are aware of the risk.

In any case, here are the things to try if it doesn’t work.

  • Try setting it up with the public IP – note that if your firewall doesn’t support loopback connections from the LAN, this probably won’t work.
  • Try changing to a port other than 80.
  • Restart your hub via the web graph interface
  • Restart the app – Make sure it’s dead – you can do a force stop in applications if you have android.
  • Restart the camera – As mentioned above by RBoy, sometimes the camera doesn’t respond correctly – though you can rule this out by attempting to browse to the Camera picture fetch URL directly from your web browser - http://IP address here:port/snapshot.cgi?user=alias&pwd=fakepassword

OK so once the app is working, there are a few other oddities. Sometimes the pictures just disappear out of the app. If you go back to the Event logs for the device you can find some names for the pictures it has taken. I’m not sure if these are accessible from somewhere else – maybe somewhere out on s3 storage. But once they’ve disappeared from the app, I haven’t been able to find them.

Also, it looks like the dns lookup function may be broken, as it wasn’t able to lookup a couple different dns names I pointed it to.

When it doesn’t work, I’m not sure if I should be blaming the android app, or slowness on the smart things side, but something is a bit screwy with that if the same settings cause different results. I’ve ruled out the code itself, my network connection and camera as the culprits when it happens, so have to find something else to blame.

In any case despite all that, I think it’s coming along nicely.