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 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.