Help with IP camera amcrest

Yes, I checked compatibility on this list:

It’s the IP2M-841W, so it should be good.

I tried copying how you had yours set up with the port number and everything.

 - platform: amcrest
   host: 192.168.1.3
   port: 9080
   name: Lincoln
   stream_source: snapshot
   username: !secret camera_username
   password: !secret camera_password

With this config I get the following error in Home Assistant:

17-04-06 23:06:50 WARNING (Thread-7) [requests.packages.urllib3.connectionpool] Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='192.168.1.3', port=9080): Read timed out. (read timeout=3.0)",)': /cgi-bin/snapshot.cgi?=channel=0

I’ll get a still image with that config, then after a while the camera crashes.

I’ve also tried using low resolution rather than a snapshot stream source. With that config the video feed is horrible in quality and only stays up for about 5 seconds before it freezes.

what happens if you leave the above out…? I am not using it and seems to work ok…

If I don’t specify stream_source or resolution then I don’t get any picture at all since the camera doesn’t use MJPEG encoding.

only other thing i can think of checking is the port your camera is running on is that http port? i used the amcrest ip cam software to check these ports…

i had 9080 show up as tcp port (configured in my android App), and 9083 show up as http port…

The port was the http port. By default it was port 80. I manually changed it to 9080.

Before I changed the port number or anything I was getting the same error that you were. What did you have to do to fix that?

in my instance the camera per its software was running on tcp 9080 and http 9083.

this was “news” to me since i though i was only running it on 9080 the port config i had changed from 80…

i update my configs in HA to use 9083 instead of 9080.

Did you solve the issue?

I am about to buy the same camera but I wanted to ensure it works with HA.

Any feedback on the camera with HA?

Thanks

The camera works with HA, but there are some issues with it right now with the live feed. The developer has been working on it, and I think he’s got a workaround, though I haven’t tested it yet. Here’s the thread where it’s discussed:

@kembo @shivan

Guys, I posted a PR today to generate the stream via RTSP via ffmpeg.

This will be a good workaround while aiohttp does not support HTTPDigest authentication for the newer firmware.

I’ve been using this solution for a couple weeks now and it works great in low resolution. When I try it in high resolution the picture locks up. Is there something I can do to try and improve it?

Thanks again for all your hard work.

@shivan could you share your configuration?

Sure it looks like this:

- platform: amcrest
  host: !secret amcrest_lincoln_host2
  name: "Lincoln-old"
  resolution: low
  username: !secret camera_username2
  password: !secret camera_password2
  port: 80
  stream_source: rtsp

is it working?

what error are you getting?

Dear all:

my amcrest camera was working well under hass.io

these are my configuration:

amcrest:
  host: 192.168.34.109
  username: user
  password: XXYYZZ
  resolution: low
  stream_source: mjpeg
  sensors:
    - motion_detector
    - sdcard
     
camera 1:
  platform: amcrest
  host: 192.168.34.109
  username: user
  password: XXYYZZ 
  name: cameraLiving

Then, I switched to hassbian.

the very same configuration file no longer works. It give not-so informative error:

Invalid config

The following components and platforms could not be set up:

camera.amcrest
amcrest

Please check your config.

Upon further examination, I found something strange in homeassistant.log file:

2018-02-01 22:44:17 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=43 from 2018-02-02 06:37:29.160585)
2018-02-01 22:44:23 ERROR (MainThread) [homeassistant.setup] Error during setup of component amcrest
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 199, in _async_setup_component
    component.setup, hass, processed_config)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/amcrest.py", line 99, in setup
    device.get(CONF_PASSWORD)).camera
  File "/srv/homeassistant/lib/python3.5/site-packages/amcrest/__init__.py", line 32, in __init__
    timeout_protocol=timeout_protocol
  File "/srv/homeassistant/lib/python3.5/site-packages/amcrest/http.py", line 67, in __init__
    self._token = self._generate_token()
  File "/srv/homeassistant/lib/python3.5/site-packages/amcrest/http.py", line 82, in _generate_token
    req.raise_for_status()
  File "/srv/homeassistant/lib/python3.5/site-packages/requests/models.py", line 935, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://192.168.34.109:80/cgi-bin/magicBox.cgi?action=getMachineName
2018-02-01 22:44:23 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of camera.amcrest. Setup failed for dependencies: amcrest
2018-02-01 22:44:23 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform camera.amcrest: Could not setup all dependencies.
2018-02-01 22:44:23 ERROR (Recorder) [homeassistant.components.recorder.util] Error executing query: (sqlite3.DatabaseError) database disk image is malformed [SQL: 'INSERT INTO events (event_type, event_data, origin, time_fired, created) VALUES (?, ?, ?, ?, ?)'] [parameters: ('service_registered', '{"service": "purge", "domain": "recorder"}', 'LOCAL', '2018-02-02 06:44:16.159696', '2018-02-02 06:44:23.571472')] (Background on this error at: http://sqlalche.me/e/4xp6)

it looks like recorder sqlite file is corrupted?

thanks in advance

This error is not unique to hassbian. It seems that the amcrest.py is not handling authentication correctly. I get a 401 error and I’m sure that the configuration is okay.

1 Like

There is one error I think I can do something about: that sqlite3.databaseError

if anyone knows where that database is, please let me know. i want to try to delete that data base file and see if it fixes it.

Thanks in advance

you mean something like this?

requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://192.168.23.124:80/cgi-bin/magicBox.cgi?action=getMachineName

The strange thing is that… amcrest worked fine on my hass.io. it’s only when I switched to hassbian i start to encounter this issue.

Unless, it just happened that amcrest updated its script while I was migrating to hassian…

I found the sqlite3 database file: home-assistant_v2.db
And I simply deleted it.

it no longer has that sqlite database disk image malformed error, but it still got that 401 authentication error, which is related to amcrest component no longer works with latest amcrest firmware update.

the author of python-amcrest is aware of this issue, I guess we just have to wait.

Same issue with mine. Amcrest was working fine in hassio but when i switched to hassbian i am getting 401 unauthorized for url error.

Anyone resolved this issue? It seems to have been happening to many people.