Amcrest Switch Deprecated

The amcrest.enable_motion_recording and amcrest.disable_motion_recording services actually change that exact setting in the camera (the one you have circled in the picture.) After calling the service, click the Refresh button (shown at the bottom of your picture) and you’ll see that check box change.

The camera.enable_motion_detection and camera.disable_motion_detection services change the top checkbox – i.e., the one labeled “Enable” in your picture.

The amcrest.enable_recording and amcrest.disable_recording services have nothing to do with motion detection. They simply enable and disable “manual” recording. If you click on “Storage” (in the left pane of your picture), then click on “Record Control” under it, you’ll see this:

amcrest.enable_recording sets Record Mode to Manual, and amcrest.disable_recording sets it to Auto.

This is really helpful, thank you! You should consider adding this to the component page.
Unfortunately, it doesn’t work for me. amcrest.enable_motion_recording and camera.enable_motion_detection only change state, they don’t seem to change any camera settings. amcrest.enable_recording does work as you described though. Most likely it’s this specific model/firmware that doesn’t work. Is there anything I can do to debug why it’s not working?
Some details:

amcrest:
  - host: 192.168.1.8
    username: !secret amcrest_user
    password: !secret amcrest_password
    name: living_room
    binary_sensors:
      - motion_detected
      - online
    sensors:
      - sdcard
Software VersionV2.620.00AC000.3.R, Build Date: 2019-08-03
WEB Version3.2.1.619604
ONVIF Version16.12(V2.4.1.513183)

It’s weird. When I call amcrest.enable_motion_recording and amcrest.disable_motion_recording from hassio, I can see this in logs:

Detailed Information
Time:2019-10-01 08:07:41
User Name:XXXXXXXXXX
Type:Save Configuration
Content:
Address: 192.168.1.3
Name: Motion Detect

but again. It doesn’t actually change anything. Maybe the setting was renamed in latest firmware or something like that?

I think this might be helpful. This is the request payload from amcrest web interface that does work and change Record checkbox:

{
  "method": "system.multicall",
  "params": [
    {
      "method": "configManager.setConfig",
      "params": {
        "name": "MotionDetect",
        "table": [
          {
            "Enable": true,
            "EventHandler": {
              "AlarmOut": 1,
              "AlarmOutChannels": [0],
              "AlarmOutEnable": true,
              "AlarmOutLatch": 10,
              "BeepEnable": false,
              "Dejitter": 5,
              "Delay": 0,
              "ExAlarmOut": 1,
              "ExAlarmOutChannels": [0],
              "ExAlarmOutEnable": false,
              "FlashEnable": false,
              "FlashLatch": 10,
              "LightingLink": {
                "Enable": false,
                "FilckerIntevalTime": 5,
                "FilckerLightType": "WhiteLight",
                "FilckerTimes": 5
              },
              "LogEnable": true,
              "MailEnable": false,
              "Matrix": 1,
              "MatrixChannels": [0],
              "MatrixEnable": false,
              "MessageEnable": false,
              "PtzLink": [["None", 0]],
              "PtzLinkEnable": false,
              "Record": 1,
              "RecordChannels": [0],
              "RecordEnable": true,
              "RecordLatch": 10,
              "Snapshot": 1,
              "SnapshotChannels": [0],
              "SnapshotEnable": false,
              "SnapshotTimes": 3,
              "TimeSection": [
                [
                  "1 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59"
                ],
                [
                  "1 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59"
                ],
                [
                  "1 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59"
                ],
                [
                  "1 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59"
                ],
                [
                  "1 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59"
                ],
                [
                  "1 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59"
                ],
                [
                  "1 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59",
                  "0 00:00:00-23:59:59"
                ]
              ],
              "TipEnable": false,
              "Tour": 1,
              "TourChannels": [0],
              "TourEnable": false,
              "VoiceEnable": false
            },
            "Level": 3,
            "MotionDetectWindow": [
              {
                "Id": 0,
                "Name": "Region1",
                "Region": [
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303,
                  4194303
                ],
                "Sensitive": 60,
                "Threshold": 5,
                "Window": [0, 0, 8191, 8191]
              },
              {
                "Id": 1,
                "Name": "Region2",
                "Region": [
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0
                ],
                "Sensitive": 60,
                "Threshold": 5,
                "Window": [0, 0, 0, 0]
              },
              {
                "Id": 2,
                "Name": "Region3",
                "Region": [
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0
                ],
                "Sensitive": 60,
                "Threshold": 5,
                "Window": [0, 0, 0, 0]
              },
              {
                "Id": 3,
                "Name": "Region4",
                "Region": [
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0
                ],
                "Sensitive": 60,
                "Threshold": 5,
                "Window": [0, 0, 0, 0]
              }
            ],
            "OsdTwinkleEnable": false,
            "PirMotionLevel": 4,
            "PtzManualEnable": true,
            "Region": [
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303,
              4194303
            ],
            "DetectVersion": "V3.0"
          }
        ],
        "options": []
      },
      "id": 506,
      "session": "c446af098f030b3c04e32b314c1e286e"
    },
    {
      "method": "configManager.setConfig",
      "params": { "name": "LeSmartTrack", "table": null, "options": [] },
      "id": 507,
      "session": "c446af098f030b3c04e32b314c1e286e"
    }
  ],
  "id": 508,
  "session": "c446af098f030b3c04e32b314c1e286e"
}

Are you sure you clicked the Refresh button after calling the HA service? The page won’t automatically update if a setting is changed externally. You need to refresh the page to see the change.

Yes, I’m sure. It does not change values in UI. It does not change camera behavior.

Just to be clear, we’re talking about two different "UI"s – HA’s and Amcrest Web View’s. I’m saying if you call the service via HA’s UI, then click on the Refresh button in the Amcrest Web View UI, you should see the checkbox change in the latter, assuming it’s working. If it’s not, then it’s possible Amcrest changed their HTTP API in this camera or its latest firmware.

FWIW, the amcrest integration was written in an “optimistic” mode. I.e., it generally doesn’t query the camera’s settings to see if they actually changed. It queries all the settings at startup, but then when it changes a setting it assumes the setting changed accordingly. This also means the HA entity will not show a change in a setting if it is done remotely (say via the Amcrest Web View.) The HA amcrest integration assumes it is in full control of the camera.

The only way to get it to query all the settings again is to either restart HA, or prevent HA from being able to communicate with it for a while (until the state of the HA entity goes to unavailable) and then let it communicate again.

Yes, when I run amcrest.enable_motion_recording or amcrest.disable_motion_recording HA and Amcrest Web View go out of sync because nothing gets changed in Amcrest (It just doesn’t. Not because of Refresh btn). I’m pretty sure it’s my camera model or firmware. Is there a way I can figure out what API does it expect? I posted payload that gets sent from Web View but it’s probably not the same as the one used in the component.

From a web browser that can reach the camera, enter this URL (in the API doc this command is called “Get version of HTTP API”):

http://ip_addr:port/cgi-bin/IntervideoManager.cgi?action=getVersion&Name=CGI

The browser should automatically prompt you for the username and password. This is the output I get from one of my cameras:

version=2.0.0

FWIW, I just checked Amcrest’s website for the latest HTTP API doc from here:

https://support.amcrest.com/hc/en-us/articles/360001770132-Amcrest-HTTP-API-SDK

It is the same version I’ve been using – Revision 2.12 from 2017-03-15

Oh, cool. I didn’t know there is an official API. I’ll try the API when I get home and see if I can make it work. I’ll post the results when I have them.

1 Like

Ok, so it’s much worse than I thought.
First, API version is 2.29.
Now the bugs:

  1. When I call
    /cgi-bin/configManager.cgi?action=getConfig&name=MotionDetect
    I get MotionDetect[0].Enable=false and MotionDetect[0].EventHandler.RecordEnable=false
  2. When I call /cgi-bin/configManager.cgi?action=setConfig&MotionDetect[0].Enable=true
    I get “OK” in response but again it doesn’t actually change anything and second call to 1. still returns false
  3. The same for /cgi-bin/configManager.cgi?action=setConfig&MotionDetect[0].EventHandler.RecordEnable=true
    I get “OK” in response but nothing is getting changed.

I guess their 2.29 API is just broken.

Can confirm that for API version=2.29 I have the same issue - namely that Amcrest cameras stopped registering (motion) recording activation/deactivation by service call from homeassistant. Triggering recording and motion detection on/off still work from Amcrest app and web interface though.

@MIthras.ftw @kahka

You might want to head over to https://github.com/tchellomello/python-amcrest. That’s where the Python package is maintained that the HA amcrest integration uses. I did a bunch of work there, and in HA, but haven’t touched either for a while. I see others have been doing some work on the package lately. In fact, I believe I saw comments about support for the IP4M-1051.

There is no point until AmCrest API is fixed. Probably the only way to fix it for now is to try to rollback to older firmware.
I might report the bug to AmCrest at least and see if they care.

After my three years with Amcrest I can tell you they most likely won’t care but I wish you the best of luck in trying to get something out of them!

1 Like

While you’re at it, ask them for the updated HTTP API SDK doc that shows how the new version works (or is at least supposed to work.)

Did Amcrest provide any help? I just sent them a support ticket. I also had to roll back my firmware in order to resolve the API issues. As you probably noticed the older firmware was not on Amcrest.com website, but I located it at https://amcrest.in/firmware/ for my IP2M-841 camera. I was hoping that I could utilize the new firmware as it fixed the GMail email issue.

How did you downgrade? I can not do this, it’s not downgrading at all, just rebooting :/… my whole automation at home just broke because of this firmware upgrade :(. I hope someone would do something about these changes in API :confused:

I just downloaded the previous version, reflashed, reset to defaults, and I was back in action.

Edit: Just found out the PTZ setting kept erasing when I had my camera reboot weekly or did a manual reboot. I had to do a hard reset by pressing the button on the camera itself. So far the PTZ setting are staying after a reboot.

2 Likes

I am seeing the same issue after updated the firmware to V2.420.AC00.18.R, Build Date: 2019-08-03.
The http request to active motion detection is no longer working. I updated it because it’s the way to show video from the browser plug in. I can’t find the previous firmware. Do you have it so I can downgrade it? Thank you.