Problems with my Amcrest Camera (IP2M-844E)

Hello all,

I am trying to use an Amcrest IP2M-844E camera with HA and having a few problems. My Configuration file looks like this:

camera:
  - platform: amcrest
    host: 192.168.1.234
    # port: 554
    port: 80
    name: "Front Door"
    username: !secret camera_username
    password: !secret camera_password
    stream_source: rtsp
    resolution: low

What I am seeing is that sometimes it works and sometimes it does not (mostly not) - totally inconsistent! The camera is working 100% from my web browser at http://192.168.1.234/

When it does not work, here is what I see in the log:

2017-07-13 08:57:06 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform amcrest
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/urllib3/connectionpool.py", line 388, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/urllib3/connectionpool.py", line 308, in _raise_timeout
    raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.1.234', port=80): Read timed out. (read timeout=3.0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.234', port=80): Max retries exceeded with url: /cgi-bin/magicBox.cgi?action=getSerialNo (Caused by ReadTimeoutError("HTTPConnectionPool(host='192.168.1.234', port=80): Read timed out. (read timeout=3.0)",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 161, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/camera/amcrest.py", line 73, in setup_platform
    config.get(CONF_USERNAME), config.get(CONF_PASSWORD)).camera
  File "/home/homeassistant/.homeassistant/deps/amcrest/__init__.py", line 32, in __init__
    timeout_protocol=timeout_protocol
  File "/home/homeassistant/.homeassistant/deps/amcrest/http.py", line 68, in __init__
    self._set_name()
  File "/home/homeassistant/.homeassistant/deps/amcrest/http.py", line 102, in _set_name
    self._serial = self.serial_number
  File "/home/homeassistant/.homeassistant/deps/amcrest/system.py", line 93, in serial_number
    'magicBox.cgi?action=getSerialNo'
  File "/home/homeassistant/.homeassistant/deps/amcrest/http.py", line 147, in command
    timeout=self._timeout_protocol,
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 515, in get
    return self.request('GET', url, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 502, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 612, in send
    r = adapter.send(request, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/adapters.py", line 504, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.234', port=80): Max retries exceeded with url: /cgi-bin/magicBox.cgi?action=getSerialNo (Caused by ReadTimeoutError("HTTPConnectionPool(host='192.168.1.234', port=80): Read timed out. (read timeout=3.0)",))

Any ideas on what I can try next? Is there a way to increase the timeout?

Thank you in advance for any help!

Tom

I have this camera and had multiple issues getting it to work with the amcrest component so I switched to ffmpeg and used the rtsp url to access it.

1 Like

Thank you - I’ll give that a try and see if that works any better.

Below is my configuration replace the login/password and IP address to fit your information.

camera:
 - platform: ffmpeg
   input: rtsp://<login>:<password>@<ip address>:554/cam/realmonitor?channel=1&subtype=0
   name: Front Door

How did you determine the port to use? Is 554 standard or do I need to find it somewhwere in camera config? Any special setup necessary on the camera side?

Thanks

It’s the default port on the Amcrest cameras for RTSP. You can find it in the network configuration of the camera UI.

Not working for me - here’s my errors:

2017-07-13 22:24:09 ERROR (MainThread) [haffmpeg.core] FFmpeg fails 
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/haffmpeg/core.py", line 114, in open
    stderr=stderr
  File "/usr/lib/python3.4/asyncio/subprocess.py", line 226, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "/usr/lib/python3.4/asyncio/base_events.py", line 866, in subprocess_exec
    bufsize, **kwargs)
  File "/usr/lib/python3.4/asyncio/unix_events.py", line 174, in _make_subprocess_transport
    yield from transp._post_init()
  File "/usr/lib/python3.4/asyncio/base_subprocess.py", line 106, in _post_init
    proc.stdin)
  File "/usr/lib/python3.4/asyncio/base_events.py", line 797, in connect_write_pipe
    yield from waiter
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
concurrent.futures._base.CancelledError
2017-07-13 22:24:09 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web_protocol.py", line 421, in start
    resp = yield from self._request_handler(request)
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web.py", line 303, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/ban.py", line 58, in ban_middleware_handler
    return (yield from handler(request))
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 424, in handle
    result = yield from result
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/camera/__init__.py", line 249, in get
    response = yield from self.handle(request, camera)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/camera/__init__.py", line 269, in handle
    image = yield from camera.async_camera_image()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/camera/ffmpeg.py", line 60, in async_camera_image
    extra_cmd=self._extra_arguments)
  File "/home/homeassistant/.homeassistant/deps/haffmpeg/tools.py", line 78, in get_image
    image, _ = yield from self._proc.communicate()
AttributeError: 'NoneType' object has no attribute 'communicate'

Try enabling the multicast option in the camera, forgot to mention that.

Looks like it is already enabled …

Thanks!

Hmm check also in the TCP/IP or Connection tab there, it’s been awhile since I’ve had to use the UI on the camera.

Hmmm… I wonder if this is significant?

No that’s not an issue.

Ill crack open the settings on my camera for you when I get off work and post a reply.

Awesome - thanks - really appreciate you helping me out.

Make sure your video settings are setup like so:

Connection:

…and it’s working! Thanks for your help on this - I was changing so many things I’m not even exactly sure what finally fixed it. Now to just wait and see if it remains stable.

Anyone have any examples of how to setup motion detection and have it alert in HA? Also is there any way to change the update rate of the view in HA from the default of once every 10 seconds?

Thanks again @firstof9 for the examples and the help!

Tom

That’s built into the amcrest component.

sensor:
  - platform: amcrest
    host: IP_ADDRESS
    username: USERNAME
    password: PASSWORD
    monitored_conditions:
      - motion_detector

In the camera settings setup your motion zones like so:


Highlight the areas you want to detect motion in.
In HA you will have a new sensor named sensor.<camera name>_motion

So even though you are using the ffmpeg component for the camera (instead of Amcrest), you still use the Amrest platform for motion detection? I get the following error:

2017-07-15 22:28:53 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform amcrest
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 386, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 382, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 388, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 308, in _raise_timeout
    raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.1.234', port=80): Read timed out. (read timeout=3.0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/adapters.py", line 438, in send
    timeout=timeout
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 678, in urlopen
    **response_kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.234', port=80): Max retries exceeded with url: /cgi-bin/magicBox.cgi?action=getMachineName (Caused by ReadTimeoutError("HTTPConnectionPool(host='192.168.1.234', port=80): Read timed out. (read timeout=3.0)",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/amcrest.py", line 57, in setup_platform
    config.get(CONF_USERNAME), config.get(CONF_PASSWORD)).camera
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/amcrest/__init__.py", line 32, in __init__
    timeout_protocol=timeout_protocol
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/amcrest/http.py", line 68, in __init__
    self._set_name()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/amcrest/http.py", line 101, in _set_name
    self._name = pretty(self.machine_name)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/amcrest/system.py", line 100, in machine_name
    'magicBox.cgi?action=getMachineName'
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/amcrest/http.py", line 147, in command
    timeout=self._timeout_protocol,
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 531, in get
    return self.request('GET', url, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 518, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 639, in send
    r = adapter.send(request, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/adapters.py", line 502, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.234', port=80): Max retries exceeded with url: /cgi-bin/magicBox.cgi?action=getMachineName (Caused by ReadTimeoutError("HTTPConnectionPool(host='192.168.1.234', port=80): Read timed out. (read timeout=3.0)",))

Thanks again for your help and patience!

Tom

…and then I tried updating the firmware on the camera and I can now see a new sensor for motion detection.

So, last question for the night - even though I have multiple zones setup for motion on my Amcrest, looks like there is just 1 motion sensor event that is returned to HA?

Thanks!

Correct 1 sensor, it will trip for any zone there’s motion.