[RELEASE] Amcrest IPM-721 & IP2M-841 LIVE Video/PTZ/Night Vision/Motion/Video Record/+More IP Camera DTH

amcrest
video
dth_cameras

(David) #1

NOTICE as of 04/24/2017:

Amcrest has broken “Basic Authentication” with firmware V2.420.AC00.17.R 3/22/17.

If you purchase a camera that has this firmware, or update your camera to this version, then my DTH will not function properly.

##I am investigating a work-around and will update this thread if I find a solution.
##________________________________________________________________

##Amcrest IPM-721 & IP2M-841 DeviceType, now with LIVE Video!

##________________________________________________________________
Last Updated 2017-03-11: Current version is 2.3.5

Change History:

  • 2017-03-11: v2.3.5 = Snapshots now work with the new storeTemporaryImage function.
  • 2017-02-08: v2.3.4 = Fixed a bug that prevented video streaming from working when using a public IP.
  • 2017-01-27: v2.3.3 = Increased the range of channels to 0…15 to accommodate 16 camera NVR systems and fixed snapshots.
  • 2017-01-19: v2.3.2 = Fixed a typo in the return value for ‘convertHostnameToIPAddress’. Also, ST revoked S3 access so snapshots are
  •                  no longer functional.  Also, I separated the camera channel from the video channel, so your configurations must
    
  •                  be refiled!
    
  • 2017-01-19: v2.3.1 = Fixed a typo and a missing line in convertHostnameToIPAddress (thx jjslegacy!).
  • 2017-01-18: v2.3.0 = Fixed the HostName resolution, allow user-defined RTSP port and allow for multi-camera HDCVI systems (e.g. 4-camera
  •                  AMDV7204-4B: just pick channels 0 through 3 and set up as individual cameras, thx to JBethancourt), updated debugging
    
  •                  for readability (thx to ady624 for the formatting code), changed the default state of recording to "Auto" instead of "Off"
    
  •                  and added a function (queryMotion) to return ON/OFF based on current state.
    
  • 2016-04-27: v2.2.0 = Assigned the device.switch capability to the “Motion Sensor” toggle.
  • 2016-04-23: v2.1.0 = Allow toggle between MJPEG and RTSP live video streaming.
  • 2016-04-23: v2.0.0 = Added video streaming and a complete UI redesign.
  • 2016-04-21: v1.1.0 = Added the ‘Actuator’ capability (use with caution!) and a version command.
  • 2016-04-12: v1.0.0 = Initial release.
    ##________________________________________________________________

The Amcrest 720P and 1080P cameras are packed with an impressive feature set for their relatively low cost. This Device Type allows for some integration into the ST platform and will hopefully help out other community members.

This is my first Groovy coding attempt, so do not be surprised if I have to make a number of bug fixes. I will be making adjustments/fixes as I continue to develop this further, so feel free to ask for other features and I will try to accomodate them. I am planning to eventually create a SmartApp for my cameras using this DeviceType.

##Features:

  • LIVE Video Streaming (as of version 2.0.0)!
  • Snapshot Image Capture and Carousel Display
  • Full PTZ (Pan-Tilt-Zoom) Functionality (Up/Down/Left/Right/Zoom In/Zoom Out)
  • Adjust PTZ Speed (range slowest <1> to fastest <8>)
  • Toggle Motion Detection On/Off
  • Adjust Motion Detection Sensitivity (range of least sensitive <1> to highest sensitivity <6>)
  • Set Night Vision On/Off/Auto
  • Move to Preset ¹ (available presets 1 -> 6)
  • Toggle Camera Image Flipping On/Off
  • Toggle Camera Image Mirroring On/Off
  • Set Camera Image Rotation Clockwise/Counter-Clockwise/Off
  • Remote Camera Reboot
  • Supports either a Local IP Address or a Public DNS entry
  • Switch Video Recording Off/On/Auto ²
  • Verbose Debugging Switch On/Off
  • Exposed commands that can be access via Rule Machine (RM)

##Please Note:

  • If either the Hostname/IP or Port are changed after executing any request, you may have to edit the devices in the IDE and change the Device Network Id to some string (e.g. “TEST01”) before attempting a new action.
  • If you receive a partial image, or no image at all, and you are using a local IP address, this is most likely occurring because of a ST timeout waiting for a HubAction response.
  • When using a local IP (HubAction), reduce the Snapshot Quality to lessen the likelihood of a timeout occurring ³ (see Amcrest Web View configuration).

¹ Presets:

  • Preset buttons 1 -> 6 must first be defined in the camera (see Amcrest Web View configuration).

² Video Recording:

  • Recording to the Camera MicroSD Card only, which must be configured in the camera (see Amcrest Web View configuration).
  • All camera actions (PTZ, Zoom, etc.) perform during recording will appear in the recorded video.

³ Image Quality:

  • For the IP2M-841B a snapshot at the highest Quality setting (6) is approximately 200 KB in size and at the lowest setting (1) it is approximately 50 KB in size, in my experience.
  • It has been speculated that most images over 40 KB begin to have problems with local IP communication with ST.
  • While the timeout may still occur with a lower Quality_ setting, especially with the 1080P version of the camera, this is much less likely to occur when using a public IP. I experienced no issues grabbing an image at the highest setting (6) when using a public IP.
  • In all honesty, using a local IP failed to return an image more times than not, so I use a public IP (DDNS) for all of my cameras.
  • In addition, you may need to restart the Hub (unplug for 10 seconds, plug back in, wait for the green light) between failed image attempts while adjust the Quality setting.

##Exposed Commands

The following device commands are exposed by the DTH:

  • appVersion
  • changeNvLED
  • changeRecord
  • changeRotation
  • moveDown
  • moveLeft
  • moveRight
  • moveUp
  • presetCmd1
  • presetCmd2
  • presetCmd3
  • presetCmd4
  • presetCmd5
  • presetCmd6
  • rebootNow
  • setLevelSpeed
  • setLevelSensitivity
  • toggleFlip
  • toggleMirror
  • toggleMotion
  • zoomIn
  • zoomOut

##Amcrest Web View configuration
The following steps will guide you to the correct settings within the Amcrest Web View applications for the specified topic. These steps assume that you have logged in under the admin user account or an account with equivalent permissions.

  • Set Presets: Live (Header) -> PTZ (Footer) -> PTZ Settings (Right Panel) -> Preset (Dropdown) -> Position view to desired point -> Enter # -> Select + Add
  • Set Snapshot Quality: Setup -> Camera -> Video -> Snapshot -> Quality (Dropdown)
  • Set SD Card for Video Record: Setup -> Storage -> Destination -> Path -> SD Card (check the box)

##Installation:
(These installation/setup notes are purposely very detailed to help ST newcomers… a picture is worth a 1,000 words!)

  1. Sign in to the SmartThings IDE and select My Device Handlers.

  2. Click the Settings button:

  3. Click on Add new repository and fill in the highlighted fields:

  4. Click on Save.

  5. Click on Update from Repo and then select Amcrest-Camera (master):

  6. Check the box next to New (only in GitHub) item:

  7. Check the Publish box then click the Execute Update button.

  8. Click on My Devices then click the + New Device button:

  9. Fill in the device fields similar to these values (Type is the only fields that must match):

  10. Click the Create button.

  11. Go into the SmartThings mobile app and select Marketplace where you should see and select:

  12. Fill in the fields below and select Next when finished with page 1, then select Done:

NOTE: The camera default “Video Channel” is usually set to 0.

You should now see your new device available in your Things list. Enjoy!

A final word of thanks to the ST Community for all of their non-code-related help (@JDRoberts that’s a nod to you) and to all of the coders who help make this platform a fun hobby, with specific nods related to this DTH going to:

  • @pstuart For the efforts he put into his Generic Camera device and various posts. Very educational!
  • @tgauchat and @RBoy : For the “convertHostnameToIPAddress” macro.
  • @slagle, @eparkerjr and @scottinpollock For their efforts on the great Foscam & D-Link device types.
  • RBoy again: For the code making the JPEG image available to other apps.

Amcrest ProHD 1080P WiFi Wireless IP Security Camera?
Amcrest 841 problem
Best Video Camera with Live Feed?
Smarttiles + Blink
Amcrest 841 problem
Amcrest says their cameras are not recommended for SmartThings
Pan & Tilt, Night Vision, 2 Way Audio. Smart Baby Monitor/Camera?
Have VeraPlus, thinking of ST. Would Amcrest WiFi camera work?
Integrate ST w/ Amcrest Cameras
Amcrest ProHD 1080p security camera refurbished $79.99 Ebay (make an offer $75?)
SmartTiles Dashboard v5.7: Release March 2, 2016
Amcrest 720p wifi Camera $57
Amcrest ProHD 1080P WiFi Wireless IP Security Camera?
Amazon Prime Day 2016
Amcrest 1080p IP security camera $64.90 Ebay (plus 10x ebay bucks for some YMMV)
Amcrest 1080p IP2M 841B camera is on sale for $64 on new egg
Indoor camera for Nursery and rest of home?
Amcrest 1080p Wifi/Ethernet IP camera $62 new Ebay free shipping
(Tim Slagle) #2

(Broderick) #3

Thanks for this! Does this support using the camera as a motion sensor?


(David) #4

You are welcome. :slight_smile:

Unfortunately, no. In order to receive the motion notification the Amcrest API would need to “push” that information to ST. Their API has no such functionality that I could find.

There exists the ability to connect an external sensor that is triggered by the cameras’ alarm and I toyed with the idea of connecting a simple open/close contact sensor to use that as a trigger to notify ST when motion had been detected, but it seemed like a rather extreme solution.


(Broderick) #5

It would be awesome if we could. I know RBoy’s foscam app just does a pull every 5 seconds, could you possibly do that here?

Also, another question: Can this app disable/enable the camera and also trigger ptz setpoints? For example, when my “home” routine runs, I’d like the camera to point up and to stop motion detection or turn off.

Thanks!


(David) #6

RBoy’s cam is using a SmartApp and also has the benefit of Blink & Foscam allowing for PUSH notifications. As I said, the Amcrest API has no such ability and this is a DTH, not a SmartApp. Maybe I can figure out a way to do more with it if I can find time to create the SmartApp I mentioned.

As I mentioned above, this is a device type, not a SmartApp, so I can not subscribe to other devices and receive notifications.

You do have the ability with this DTH to set up to 6 set points in the camera and reference those through the “preset” button 1 thru 6 that I provide. There is also the motion icon that turns it on/off.


(Broderick) #7

Good point, so is there a way to trigger presets based on mode or routine? Or only change manually?


(David) #8

I am working on something now for you to be able to do this with Rule Machine. Hopefully you have that already installed?


(Broderick) #9

I do, haha. That would be great! It would also be nice if you could expose the motion trigger as a virtual switch so it could be automated within a routine. PTZ would also be awesome as momentary switches possibly. Regardless, I do have rule machine, so that would be awesome.


(David) #10

The “motion trigger” and PTZ functions will be exposed but again, you will just be enabling the motion sensor on the camera… you will not be notified of any motion detected.

I will post the DTH update shortly, followed by an example of the custom command usage… stay tuned! :smiley:


(David) #11

UPDATED: v1.1.0 = Exposed DTH commands (use with caution!)

For all of my fellow Rule Machine (RM) fans!

My Amcrest DTH now exposes the following device commands:

  • appVersion
  • changeNvLED
  • changeRecord
  • changeRotation
  • moveDown
  • moveLeft
  • moveRight
  • moveUp
  • presetCmd1
  • presetCmd2
  • presetCmd3
  • presetCmd4
  • presetCmd5
  • presetCmd6
  • rebootNow
  • setLevelSpeed
  • setLevelSensitivity
  • toggleFlip
  • toggleMirror
  • toggleMotion
  • zoomIn
  • zoomOut

I will update post #1 with this new functionality.

To Update Your DTH

  • Sign in to your ST’s IDE.
  • Click on My Device Handlers.
  • Click the Update from Repo button.
  • Select the Amcrest-Camera (master) option.
  • Check the box next to belgarion:Amcrest Camera.
  • Click the Execute Update button.
  • When you return to the My Device Handlers you should see Edited in the Status column for belgarion : Amcrest Camera.
  • Click on belgarion : Amcrest Camera.
  • Click on the Publish button.
  • Select For Me.
  • You are done!

These commands can be used in RM to execute commands directly from within your rules!

RM Custom Commands

(This excerpt, paraphrased from the Rules Machine Wiki, explain how you set up Custom Commands: thanks go to @bravenel and @Mike_Maxwell)

There are two steps required to use custom commands in your rules

  • Create/test and save your command
  • Select the device and command to execute in your rule

Create/test and save your command

  • Open Rule Machine
  • Select Expert Features, then Configure Custom Commands
  • Select a device to extract the available commands from (any device with capability actuator will be shown)
  • Select New Custom command, then select Available device commands (all standard and custom commands will be displayed)
  • Select the command you wish to create from the above list, the results of the command execution will be immediately shown.
  • Add any required parameters to the command.
  • After the command is executing against the device as expected, select save command now, then done, then done again to return to the Custom Commands page.
  • The saved command will now be available in the “saved command to test” list, and also in your new and existing rules.

Select the device and command to execute in your rule

  • Create a new rule or edit an existing one.
  • In the Actions section (at the very bottom), select the custom device(s) and the command (saved above) to execute against them.
  • If multiple devices are selected, each one should support the selected command, any errors will be trapped and show in the logs.

Managing commands

  • One or more commands can be removed by selecting them in Delete Custom Commands, then Delete commands now, then done.

Tips

  • Un-select your test device or the “saved command to test” before leaving the custom commands page, otherwise the command will execute the next time you open the page.
  • Un-Select “available device commands” after saving the new command, otherwise the command will execute the next time you open the page.
  • Un-Select “parameter type” for each of your parameters, in reverse order (ie 3,2,1) after saving the new command, this is just a convenience thing.
  • The success or failure of any parameters can’t be determined by expert, use the logging in the IDE if you’re having issues getting a command to function.
  • If your wizBang device isn’t in the list, add capability actuator to it.

Cautions

  • Expert will expose commands on device types that aren’t published by ST, when you find these commands and play with them, you are doing so at your own.
  • Neither Rule Machine, ST or myself are going to have any sympathy when you successfully execute wipeDisk() on your new Samsung appliance and have bricked it.
  • So, be advised it’s probably better to play with device types and commands that you have the code for, there I said it.

A separate post will give an example of how to use this functionality.


(David) #12

##Example of Amcrest DTH being used in Rule Machine “Custom Commands”

The following example shows how you can use Rule Machine (RM) to make your Amcrest cameras automatically point to whatever position you have set to “Preset 1” when your “Goodbye!” routine executes:

Create your “Preset 1” Custom Command
Follow the steps outlined in the RM Wiki to create the Custom Command for your device (my example uses Amcrest CAM-1 Video).

  • Be sure to hit “Done” all of the way out of each screen until you have exited RM.

When done your Custom Command should look something like this:

Define the Rule
Enter RM and select “Create New Rule”.
Select Define a Trigger and give it a name (I used “Amcrest CAM-1 To Preset 1 On Goodbye!”).
Select Select Trigger Events and then:

  • Under Select capability choose “Routine”.
  • Under When this routine runs select “Goodbye!”.
  • Click Done.
    Select Select Actions and then:
  • Scroll down to and select Run custom commands.
  • Under Run this command select “presetCmd1()”.
  • Under On these devices select “Amcrest CAM-1 Video” (you can select multiple Amcrest DTH’s here, if you have them).
  • Click Done.
  • Click Done.

Your screen should now look like this:

Click Done, then click Done.

You should now be able to go into Routines and execute your Goodbye! routine and see your Amcrest camera swing into its Preset 1 position.

Enjoy! :smiley:


(David) #13

##[Update] Version 2.0.0: Added video streaming and a complete UI redesign

This update not only adds LIVE video streaming, but it also represents a complete UI redesign.

The update can be grabbed through the IDE integration.

To Update Your DTH

  • Sign in to your ST’s IDE.
  • Click on My Device Handlers.
  • Click the Update from Repo button.
  • Select the Amcrest-Camera (master) option.
  • Check the box next to belgarion:Amcrest Camera.
  • Click the Execute Update button.
  • When you return to the My Device Handlers you should see Edited in the Status column for belgarion : Amcrest Camera.
  • Click on belgarion : Amcrest Camera.
  • Click on the Publish button.
  • Select For Me.
  • You are done!

Here is a screenshot of the new UI:

Coming soon:

A parent/child SmartApp!
Enjoy!


#14

Wow… loving it… Thanks


(David) #15

##[UPDATE] Version 2.1.0: Added the ability to switch between MJPEG and RTSP

This update allows you to change from the current default of an MJPEG format to RTSP, allowing the Live Video stream to have audio in the stream!

This change assumes that you are using port 554 for RTSP streaming, whether you are using a local IP or public.

Also, once a stream has begun in one format, be sure that you stop the video before toggling to a different format. I noticed that I had to restart ST’s when changing streaming formats.

Enjoy! :slight_smile:


#16

David,

Not sure if this is a bug or not but each time I view the live feed in the ST app, it changes the camera’s video setting. The Main Stream setting would change to the Encode Mode to MJPEG from H.264H. Is there any way to have the device type look at the Sub Stream instead? I use the Main Stream with Amcrest Surveillance Pro software which in HD format.

UPDATE: I think it’s a bug in the camera. I get the same result by viewing the feed in a browser. It would change the Main Stream setting to MJPEG. I tried using the sub stream but it looks terrible. For now I’ve reconfigured the Main Stream to be MJPEG as well but at the highest quality settings. Resolution not so great with Surveillance Pro but oh well.

Update: Maybe not a bug with the firmware but it’s because it’s responding to the URL. We are requesting the MJPEG stream so maybe it’s switching over automatically to handle the stream. Can we stream H.264 stream to ST?
Thanks


(David) #17

Just to be clear, the added button I circled toggles between MJPEG and RTSP. If the camera itself is switching the main stream to MJPEG, then that is definitely a bug in the camera/script. Strange.


(Broderick) #18

Does this device type work with other amcrest cameras like their outdoor bullet style ones?


(David) #19

I do not have one to test so I could not say with certainty. Do you have a model number?


(Broderick) #20

The IPM-743E or IP2M-844E or IP3M-956E