home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.64k stars 30.4k forks source link

Amcrest Integration - Repeated Login Errors #103897

Open kylepyke opened 11 months ago

kylepyke commented 11 months ago

The problem

I'm getting several errors in the logs, which all seem to reference login errors. Each error is usually followed up with a resolution, and successful connection to the cameras.

What version of Home Assistant Core has the issue?

core-2023.11.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Amcrest

Link to integration documentation on our website

https://www.home-assistant.io/integrations/amcrest/

Diagnostics information

No response

Example YAML snippet

#AmCrest Integration
amcrest:
  - host: 192.168.1.238
    username: !secret amcrest_user
    password: !secret amcrest_pass
    name: hearth
    resolution: low
    stream_source: rtsp
    binary_sensors:
      #- motion_detected
      #- audio_detected
      - online
    sensors:
      #- sdcard
      - ptz_preset
    switches:
      - privacy_mode

  - host: 192.168.1.239
    username: !secret amcrest_user
    password: !secret amcrest_pass
    name: living
    resolution: low
    stream_source: rtsp
    binary_sensors:
      #- motion_detected
      #- audio_detected
      - online
    sensors:
      #- sdcard
      - ptz_preset
    switches:
      - privacy_mode

  - host: 192.168.1.240
    username: !secret amcrest_user
    password: !secret amcrest_pass
    name: basement
    resolution: low
    stream_source: rtsp
    binary_sensors:
      #- motion_detected
      #- audio_detected
      - online
    sensors:
      #- sdcard
      - ptz_preset
    switches:
      - privacy_mode

Anything in the logs that might be useful for us?

Several Errors:

Logger: homeassistant.components.amcrest.camera
Source: components/amcrest/helpers.py:25
Integration: Amcrest (documentation, issues)
First occurred: 3:55:39 PM (1 occurrences)
Last logged: 3:55:39 PM
Could not get living camera attributes due to error: LoginError

and

Logger: homeassistant.components.amcrest
Source: components/amcrest/__init__.py:239
Integration: Amcrest (documentation, issues)
First occurred: 3:55:39 PM (2 occurrences)
Last logged: 4:28:08 PM
living camera offline: Login error: 

and

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:696
First occurred: 4:28:08 PM (1 occurrences)
Last logged: 4:28:08 PM
Update for switch.living_privacy_mode fails

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 696, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 957, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/amcrest/switch.py", line 89, in async_update
    io_res = (await self._api.async_privacy_config()).splitlines()[0].split("=")[1]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/amcrest/privacy_mode.py", line 42, in async_privacy_config
    return await self._async_get_config("LeLensMask")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/amcrest/http.py", line 501, in _async_get_config
    ret = await self.async_command(
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/amcrest/__init__.py", line 205, in async_command
    ret = await super().async_command(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/amcrest/http.py", line 262, in async_command
    return await self._async_command(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/amcrest/http.py", line 388, in _async_command
    raise LoginError()
amcrest.exceptions.LoginError

and

Logger: homeassistant.components.amcrest
Source: components/amcrest/__init__.py:262
Integration: Amcrest (documentation, issues)
First occurred: 3:55:40 PM (2 occurrences)
Last logged: 4:28:08 PM
living camera back online


### Additional information

_No response_
home-assistant[bot] commented 11 months ago

Hey there @flacjacket, mind taking a look at this issue as it has been labeled with an integration (amcrest) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `amcrest` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign amcrest` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


amcrest documentation amcrest source (message by IssueLinks)

xip0rt commented 11 months ago

This has been happening to me for several months. I've looked into it before, found something similar where people suggested removing special characters from password (didn't fix my issue), enable the "preload camera" option (didn't help), etc...

2023-11-15 09:19:09.787 ERROR (MainThread) [homeassistant.components.amcrest.camera] Could not get Living Room Camera camera attributes due to error: LoginError
2023-11-15 09:25:09.860 ERROR (MainThread) [homeassistant.components.amcrest] Living Room Camera camera offline: Login error:
2023-11-15 09:25:09.863 ERROR (MainThread) [homeassistant.components.amcrest.camera] Could not get Living Room Camera camera attributes due to error: LoginError
2023-11-15 09:25:11.868 ERROR (MainThread) [homeassistant.components.amcrest] Living Room Camera camera back online

My configuration for Amcrest 1920TVL


amcrest:
  - host: 192.168.1.111
    username: !secret amcrestu
    password: !secret amcrestp
    name: Living Room Camera
    binary_sensors:
      - audio_detected
      - motion_detected
      - online
    sensors:
      - sdcard
    switches:
      - privacy_mode
OhioSpyderman commented 10 months ago

I have been getting these errors for a while now

image

I know it's not the camera dropping off the network, because via my router, it's always connected.

If I watch the camera window in HA, I see it lose the picture briefly serveral times an hour.

Can someone please fix this?

Thank You.

Bob.

rwjack commented 9 months ago

My camera is connected via cable and I also get these errors. Mister @flacjacket, would you mind taking a look?

Hell, maybe even make the logs less verbose? Why is "Camera back online" an error?

OhioSpyderman commented 9 months ago

image

Still getting these errors DAILY, can someone figure out why? There are no "special" characters in my password and my setup is textbook.

VERY ANNOYING!

Bob.

PS - I've also tried resetting the camera via it's app, with no change (several times)

OhioSpyderman commented 9 months ago

Maybe I have found a solution...

I read the Amcrest info again, and noticed that they recommended if you were "streaming" that you "maybe" you should not poll for detection. I changed my "motion_detection_polled" to just "motion_detected" and that (or maybe the latest core addressed the issue) seems to have eliminated the plethora of Amcrest errors.

I will update as I monitor.

Bob.

rwjack commented 9 months ago

@OhioSpyderman What are you referring to by "motion_detection_polled"?

Here's my config:

amcrest:
  - host: [redacted]
    #port: 443
    username: [redacted]
    password: [redacted]
    name: [redacted]
    binary_sensors:
      - online
    switches:
      - privacy_mode

Edit: I removed the online sensor, it was redundant since I do monitoring elsewhere, might help fix the issue as well.

OhioSpyderman commented 9 months ago

https://www.home-assistant.io/integrations/amcrest/

image

issue-triage-workflows[bot] commented 6 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

rwjack commented 6 months ago

Still relevantOn 7. 4. 2024., at 15:06, issue-triage-workflows[bot] @.***> wrote: There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

marsp88 commented 3 months ago

Hello all, I am facing the same issue, as described here. I also noticed, that there is a lot of login/logout log entries (multiple per second) on my camera and I am wondering if that is related to this. It seems, that all the logins cause the camera to reach the connection limit of 20 (I can not set it higher) and then HA can not login again. Thanks!

issue-triage-workflows[bot] commented 3 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OhioSpyderman commented 3 weeks ago

I'm still getting these errors daily. The camera goes blank for a second and then returns (in the HA streaming camera view).

My guess (as a retired software engineer) is that the code used to access the camera (interrupts) is sometimes itself interrupted and the camera sends back an error.

Just a guess, but I think the "query" to the camera needs a looksee...

Bob.