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

I am glad to hear that you resolved the conflict @skhandu. Read up a few posts and you will see many messages that clarify the previously resolved video streaming configuration issues. The key suggestion is to make sure you have the correct ports defined.

Enjoy!

First off, thanks a ton for making this DTH. I’m really new to this, I want to learn more, but apologies if I ask a dumb question(s). I’ve read all the posts here, but I’m having confusing results. Here’s what I have set up.

Amcrest IP2M-842B settings:
-camera assigned 10.0.1.50 (static)
-http port set to 4001. Did this since I plan to get more camera and assume they each need a different port #
-rtsp port still set to 554
-mainstream and sub stream set to MJPEG

This SmartThings App settings:
-IP address is 10.0.1.50
-Port 4001
-Channel 0 or 1, it doesn’t seem to matter
-Camera stream type is RTSP (only type that works for me)

Observations/Questions:

  1. I can’t get MJPEG to work for me no matter what port or channel settings I use. Does it make a difference or matter?
  2. Any time I try to start streaming on the ST App, my camera’s main stream settings are changed to MJPEG, 720P, 10 FPS. I’d like to keep my main stream on H.264H, 1080P and use my sub stream as the MJPEG source. Is it possible to use the sub-stream or at least keep the resolution to 1080P for the MJPEG?
  3. I can’t take a snapshot when my ST App is connected to my home wireless network. If I’m off my network, I can take a snapshot. Is this normal?
  4. Has anyone had any success at the “multi-cast” function under “network” setting for the camera? I’m assuming this would allow other streaming options.

Hi @Scott_Snyder,

You do not need to change the camera port for multiple cameras unless you are using port forwarding through your router, since the public IP/name server would be the same for all cameras outside of your local network. Since you have a unique IP for each camera within your local network, using port 80 for each of them is fine.

The MJPEG port is the same port used for HTTP requests. The port configured in the DTH must match the camera configuration. Again, local network IP’s are fine with the default port of 80 for HTTP requests.

I believe I have the channel hard-coded in my DTH to use channel 0 for MJPEG and channel 1 for RTSP, since this is how the cameras are configured by default. The SD (720P) and HD (1080P) resolutions are set by the camera configuration and toggled in the DTH by the ST video control, I do not directly override these setting in my DTH, so I do not believe that I am changing your camera configuration settings for video streaming.

Again, I believe this goes to the question of using a local network port for HTTP requests, which taking a snapshot is an HTTP request. Try changing the port in your camera configuration and the DTH configuration to the default of 80 and see if that works for you.

The “streaming options” are limited by what the ST control is capable of rendering. I have not played with the multi-cast functionality myself, so I can not speak to whether or not this will open up other avenues.

Good luck!

David, thanks for your reply. I’ve changed everything back to the original port 80 and channel 0 and now have MJPEG streaming. I’m still not able to switch between HD and SD using the app. When I toggle between HD and SD, I can’t see that it changes anything on the camera setup. If I go in and change to 1080P using the web browser access, it immediately reverts back to 720P when I start to stream from the ST app. Other controls work: motion detection (on/off), profile management (Day/Night/Auto). Are you able to get 1080P MJPEG streaming to the ST app?

I am not. RTSP is working, but MJPEG is not. I will have to look into this when I have some time… I am not sure if this is my setup or the ST video streaming object.

Just to be clear, you are saying that MJPEG streaming does work? You are not using RTSP, correct?

I can get MJPEG and RTSP to stream to the ST app. Settings in the ST app that I have for each:

ST app set to MJPEG, port 80, and video channel 0
-however, I’ve noticed that it will change my camera’s main stream MJPEG resolution to 720P and will not allow me to keep it set to 1080P.

ST app set to RTSP, port 80, and video channel 0.
-I have not changed the camera’s port settings from the factory defaults
-this will allow me to stream at any of the H.264 encode modes and at any resolution.

To be honest, I’m happy with how it’s working now so I am not looking to have anything changed. My whole goal was to get main stream set to HD streaming for recording events, and sub-stream set to MJPEG so that I can have the smarttiles work for my home automation. All that seems to be working now. As a side note, smart tiles uses the following code to link to the sub-stream. Not sure if this will be useful to you for future versions.

http://LOGIN:PASSWORD@IP/axis-cgi/mjpg/video.cgi?subtype=1

Hi Scott,

I am glad that you were able to get back to the basic config and get the DTH working. Don’t forget that you can use CoRE to trigger off of the cameras motion sensor, should you choose to play around with that. :smiley:

The axis-cgi URI is another example of ways to display video with these cameras (there are several) and I have used it in the past, but thank you for pointing it out.

Enjoy!

Anyone seeing these errors in the log?

3a3d6a57-deca-4b61-9398-14bdf94ffd97  5:06:47 PM: error java.lang.NullPointerException: Cannot invoke method toUpperCase() on null object @ line 821
3a3d6a57-deca-4b61-9398-14bdf94ffd97  5:06:47 PM: error IP Address is invalid (null), Error: java.lang.NullPointerException: Cannot invoke method tokenize() on null object
3a3d6a57-deca-4b61-9398-14bdf94ffd97  5:06:47 PM: error Exception: java.lang.NullPointerException: Cannot invoke method take() on null object
3a3d6a57-deca-4b61-9398-14bdf94ffd97  5:06:47 PM: error IP Address is invalid (null), Error: java.lang.NullPointerException: Cannot invoke method tokenize() on null object
3a3d6a57-deca-4b61-9398-14bdf94ffd97  5:06:47 PM: debug hubGetImage -> Host name '#####.######.com' resolved to IP 'null'
3a3d6a57-deca-4b61-9398-14bdf94ffd97  5:06:47 PM: warn Unable to convert hostname to IP Address, Error: org.apache.http.conn.ConnectTimeoutException: Connect to api.myiponline.net:80 [api.myiponline.net/69.164.214.134] failed: connect timed out
3a3d6a57-deca-4b61-9398-14bdf94ffd97  5:06:37 PM: debug apiCommand = /cgi-bin/snapshot.cgi
3a3d6a57-deca-4b61-9398-14bdf94ffd97  5:06:37 PM: debug hubGetImage -> BEGIN
3a3d6a57-deca-4b61-9398-14bdf94ffd97  5:06:37 PM: info Taking Photo

I am seeing these as well and I am trying to add a camera. I also tried to start a stream from a camera I know that is working and it wouldnt start the stream.

When I try to visit: api.myiponline.net:80 I get a connection time out too

It appears to be a server name resolution failure. The site is offline. I will try to find an alternative if it does not come back online soon.

FWIW last night I was trying to connect my IPM-722S but the live stream option or any of the buttons were not working and giving me the time out error. This morning I tried again and the live stream was working but the image capture was giving the same error I got last night. Not sure why that happened since I assume every call made goes through this site?

No, the video streaming does not go through the site. The streaming is handled in the cloud by ST and I do not attempt to translate the DNS.

Hi David,
Thanks for creating this DTH. Excellent job!

I seem to be having an issue not reported by anyone else yet. I use CoRE to monitor ST Home/Away status which then triggers presetCmd1/2() as well as toggleMotion(). The issue is that toggling motion also has the side-effect of changing Record Mode (Amcrest WebApp: Storage->Record Control->Record Mode) from ‘Auto’ to ‘Off’, which causes the camera to never record video. Once Record Mode reverts to ‘Off’, it stays off, and motion detection is only capable of sending snapshots in email.

I don’t know if it is related, but in the ST app, tapping the Record Mode button (under pan left) is only switching the camera between Off and On…never Auto, even though Auto is shown on screen. Using the Amcrest API for this cam, I can send an HTTP request and switch the camera to Auto Record, but I haven’t figured out how to add that web call in CoRe yet.

Have you noticed any of this behavior? Any ideas on how to fix it?

Thanks again for the effort you have put in to this!

Regards,
Chad

My hardware:
Camera: IP2M-841
ST Hub: V1

Hi Chad,

I am glad to hear that you are enjoying the DTH!

I just took a look at my setup (2-720P and 2-1080P PTZ cameras) and I confirmed that I am able to cycle through the ON/OFF/AUTO states using the “record” button, as you reported. However, I do not have a CoRE Piston defined to use the “toggleMotion”, so I have not tested that yet. I will try to test this soon.

My guess is that the state variables are not being stored properly and that is causing the record functionality to default to “off”. I will have to trap this out to see what is going on… stay tuned! :slight_smile:

David,

I think I’ve found a solution, at least in my case. I’ve made the following change to the DTH: (lines 728-729)
From
if (!state.Record) { state.Record = “off”}
if (!state.RecSwitch) { state.RecSwitch = 2}
To
if (!state.Record) { state.Record = “auto”}
if (!state.RecSwitch) { state.RecSwitch = 0}

Following this change, I can now cycle through the Auto/Off/On options and toggling motion detection doesn’t revert record mode to off.

This seems to support your theory that state is being lost somehow.

Regards,
Chad

Hi Chad,

Yes, that is the code I was referring to and your solution works for you, but not really a permanent solution in that it does not address the root cause of state not being maintained.

My goal was (and still is) to rewrite this whole setup to a Parent -> Child app, which would address problems like this… maybe it is time I finally make room for this on my plate. :wink:

What you have now should hold you over… it will take a while to get the app written and I am currently fighting my new network configuration (I just had FIOS installed Wednesday, which broke my OpenVPN :frowning: ), so hang in there!

No worries, my setup does exactly what I wanted it to do at this point.

Good luck with your VPN and I look forward to the eventual evolution of this code.

Thanks again David!

Regards,
Chad

Hi Seth,

Yes, you can read a few posts up to see that this has already been noted:

The problem is that the website used to resolve host names is offline. If you are trying to use a public DDNS service, this is an issue.

I have not found an alternative site yet… but I have not been able to spend a lot of time on the search.

I’m very excited to find your excellent work here for integrating Amcrest with SmartThings, thank you for sharing it! I had the same issue with resolving DDNS, using my dynamic public ip instead as a workaround for now to get this going. I’m able to take snapshots and control ptz, but can’t seem to get RTSP over :554 or MJPEG streaming working on :80 working. I plan to explore that more when i’m at home on my local network. Both work fine from the browser amcrest web app.

Anyway- i see you’ve been busy- i meant to thank you here i appreciate all your time invested in this!

Off topic quesiton,

How can I view this camera via url for Smarttiles/Actiontiles.

Thanks,