python-amcrest icon indicating copy to clipboard operation
python-amcrest copied to clipboard

Enable/disable motion detection

Open zetix opened this issue 5 years ago • 23 comments

The documentation states there is MotionDetection but does this allow the ability to enable/disable motion detection?

zetix avatar Oct 25 '19 19:10 zetix

Yes. See the motion_detection setter in motion_detection.py.

pnbruckner avatar Jan 21 '20 21:01 pnbruckner

I can't seem to get the motion_detection to work.

Python version: 2.7.16 Raspberry Pi 3b running Raspbian Installed python-amcrest with: sudo pip install amcrest Installed argcomplete with: sudo pip install argcomplete Enabled amcrest-cli autocomplete with:

sudo su
echo 'eval "$(register-python-argcomplete amcrest-cli)"' >  /etc/profile.d/amcrest-cli-autocomplete.sh

Tried running via python:

>>> from amcrest import AmcrestCamera
>>> camera = AmcrestCamera('192.168.1.225', 80, 'USER', 'PASS').camera
>>> camera.motion_detection(False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'unicode' object is not callable
>>> camera.motion_detection(True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'unicode' object is not callable

In Terminal:

pi@rpi3:~ $ amcrest-cli -H 192.168.1.225 -u USER -p PASSWORD --motion-detection False
No handlers could be found for logger "amcrest.http"
Traceback (most recent call last):
  File "/usr/local/bin/amcrest-cli", line 912, in <module>
    main()
  File "/usr/local/bin/amcrest-cli", line 887, in main
    camera.motion_detection = args.motion_detection
  File "/usr/local/lib/python2.7/dist-packages/amcrest/motion_detection.py", line 44, in motion_detection
    'setConfig&MotionDetect[0].Enable={0}'.format(opt.lower())
  File "/usr/local/lib/python2.7/dist-packages/amcrest/http.py", line 163, in command
    return self._command(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/amcrest/http.py", line 203, in _command
    raise CommError(error)
amcrest.exceptions.CommError: 400 Client Error: Bad Request for url: http://192.168.1.225:80/cgi-bin/configManager.cgi?action=setConfig&MotionDetect%5B0%5D.Enable=false

Added the camera to ~/.config/amcrest.conf so the full path is /home/pi/.config/amcrest.conf and running it in Terminal:

pi@rpi3:~ $ amcrest-cli --camera room --motion-detection False
No handlers could be found for logger "amcrest.http"
Traceback (most recent call last):
  File "/usr/local/bin/amcrest-cli", line 912, in <module>
    main()
  File "/usr/local/bin/amcrest-cli", line 887, in main
    camera.motion_detection = args.motion_detection
  File "/usr/local/lib/python2.7/dist-packages/amcrest/motion_detection.py", line 44, in motion_detection
    'setConfig&MotionDetect[0].Enable={0}'.format(opt.lower())
  File "/usr/local/lib/python2.7/dist-packages/amcrest/http.py", line 163, in command
    return self._command(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/amcrest/http.py", line 203, in _command
    raise CommError(error)
amcrest.exceptions.CommError: 400 Client Error: Bad Request for url: http://192.168.1.225:80/cgi-bin/configManager.cgi?action=setConfig&MotionDetect%5B0%5D.Enable=false

zetix avatar Mar 05 '20 05:03 zetix

camera.motion_detection(False) Traceback (most recent call last): File "", line 1, in TypeError: 'unicode' object is not callable

The motion_detection setter takes a string, not a bool. So try this instead:

camera.motion_detection("false")

I don't know why it didn't work when you used the cli w/ Python 2. I'm only concerned with how this works with Home Assistant (which, BTW, uses only Python 3.) Maybe @tchellomello could look into those problems.

pnbruckner avatar Mar 05 '20 15:03 pnbruckner

I tried it with a string but I get the same error as without.

>>> camera.motion_detection("false")
Traceback (most recent call last)
File "<stdin>", line 1, in <module>
TypeError: 'Unicode' object is not callable

HTTP-API Version is 2.29 Firmware build is 2019-07-29

zetix avatar Mar 05 '20 16:03 zetix

Oh, wait, that's not how a setter is used. I should have said try this:

camera.motion_detection = "false"

pnbruckner avatar Mar 05 '20 17:03 pnbruckner

It's showing the same error as when I type the amcrest-cli command from terminal.

>>> camera.motion_detection = "false"
No handlers could be found for logger "amcrest.http"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/amcrest/motion_detection.py", line 44, in motion_detection
    'setConfig&MotionDetect[0].Enable={0}'.format(opt.lower())
  File "/usr/local/lib/python2.7/dist-packages/amcrest/http.py", line 163, in command
    return self._command(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/amcrest/http.py", line 203, in _command
    raise CommError(error)
amcrest.exceptions.CommError: 400 Client Error: Bad Request for url: http://192.168.1.225:80/cgi-bin/configManager.cgi?action=setConfig&MotionDetect%5B0%5D.Enable=false

Also copying and pasting the url directly into my browser gives a bad request error. There's post on the Amcrest forum saying that the previous and current firmware released doesn't support setConfig for the API.

zetix avatar Mar 05 '20 19:03 zetix

Well, not much that can be done about that at this time. I've tried several times, through several different channels, to get Amcrest to admit that the HTTP API has changed and to provide a new spec that documents the new API. But they've consistently denied that the API has changed and have stated that there is no newer revision of the spec available. I've personally not updated the firmware in my cameras and have refrained from buying any new ones from Amcrest until they cease their denial and provide a new spec.

pnbruckner avatar Mar 05 '20 20:03 pnbruckner

It's pretty sad cause the hardware and specs are great, but the software and support is really lackluster.

zetix avatar Mar 05 '20 21:03 zetix

I also opened a support ticket on this issue. They concluded by closing the ticket as: "_Good afternoon,

The R&D team is currently looking into this issue and update the firmware accordingly. Unfortunately at the moment we do not have an ETA on any release dates for further updates. I apologize for the inconvenience._"

Mark612 avatar Mar 06 '20 00:03 Mark612

Has this been resolved? I am looking to do the same (enable/disable motion detection).

nfour14 avatar Nov 25 '20 01:11 nfour14

On an IPM-721B when I try to set motion detection, I actually get a return of "OK"

http://X.X.X.X:8080/cgi-bin/configManager.cgi?action=setConfig&MotionDetect[0].Enable=true

But when I view it either via API or UI, it says its not enabled:

http://X.X.X.X:8080/cgi-bin/configManager.cgi?action=getConfig&name=MotionDetect

I guess its still not working on Amcrest's end, but its certainly not giving me an error. Its just not working.

nfour14 avatar Nov 25 '20 21:11 nfour14

FYI - Looks like this is still broken according to Amcrest. Set commands do not work for motion detection. Unfortunately that will be the end of the road for me and Amcrest cameras.

nfour14 avatar Nov 26 '20 01:11 nfour14

I am having the same problem........... Always received OK but the Motion Detection not enable/disable..... I can enable/disable from Android app only. I leave one thing that listen events and take photography from api and then send the photography to telegram, may be you want improve and add new features for telegram ;) https://github.com/luisbattle/amcrest-read-events-and-send-photo

luisbattle avatar Dec 28 '20 12:12 luisbattle

Same, it works fine from their applications, but not from the API. Its on the Amcrest end. They are still not going to address it. Its a bummer since I was going to script up some on/off times and movement.

I am having the same problem........... Always received OK but the Motion Detection not enable/disable..... I can enable/disable from Android app only. I leave one thing that listen events and take photography from api and then send the photography to telegram, may be you want improve and add new features for telegram ;) https://github.com/luisbattle/amcrest-read-events-and-send-photo

nfour14 avatar Dec 28 '20 17:12 nfour14

My idea was to program the motion detection on and off by sending commands from telegram but we will have to wait for them to solve it, I hope it will be soon...

luisbattle avatar Dec 28 '20 17:12 luisbattle

FYI - I have a new 841B v3 camera and the motion detection on/off seems to work now.

nfour14 avatar Jan 16 '21 17:01 nfour14

Hi @rtmgllc, I hope you are well. Could you share the software camera version ? I have this version: Software VersionV2.420.AC00.18.R, Build Date: 2020-02-17

luisbattle avatar Jan 16 '21 18:01 luisbattle

V2.800.0000000.6.R, Build Date: 2020-03-1

nfour14 avatar Jan 16 '21 18:01 nfour14

I am tryng access to amcrest website to check if new releases exists but the web doesnt work........... image

luisbattle avatar Jan 16 '21 18:01 luisbattle

The website is up, thats Cloudflare blocking you. Not sure why, sorry.

nfour14 avatar Jan 16 '21 18:01 nfour14

:(

luisbattle avatar Jan 16 '21 18:01 luisbattle

Sadly, while motion detection on/off works on the 841, ptz control does not. On the 741 ptz control works, but motion on/off does not. :(

nfour14 avatar Jan 17 '21 00:01 nfour14

Luckily, you can use the ptz preset list to move the camera.

nfour14 avatar Jan 17 '21 00:01 nfour14