Help with IP camera amcrest

@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

these are my configuration:

  username: user
  password: XXYYZZ
  resolution: low
  stream_source: mjpeg
    - motion_detector
    - sdcard
camera 1:
  platform: amcrest
  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:


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/", line 199, in _async_setup_component
    component.setup, hass, processed_config)
  File "/usr/lib/python3.5/asyncio/", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/", line 304, in _wakeup
  File "/usr/lib/python3.5/asyncio/", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/", line 99, in setup
  File "/srv/homeassistant/lib/python3.5/site-packages/amcrest/", line 32, in __init__
  File "/srv/homeassistant/lib/python3.5/site-packages/amcrest/", line 67, in __init__
    self._token = self._generate_token()
  File "/srv/homeassistant/lib/python3.5/site-packages/amcrest/", line 82, in _generate_token
  File "/srv/homeassistant/lib/python3.5/site-packages/requests/", line 935, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url:
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:

it looks like recorder sqlite file is corrupted?

thanks in advance

This error is not unique to hassbian. It seems that the 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:

The strange thing is that… amcrest worked fine on my 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.