Sorry, can’t help you. I don’t use hassio, docker, … Just a simple Ubuntu OS and HA installed into a venv.
Sounds like a dream to manage… I’ll poke around at it and see what I can find. In the meantime, thanks a ton for pointing me in the right direction!
w00t! shell_command FTW!
Here’s my output (I cleaned it up a bit for readability).
The good stuff is in the STDERR. That explains why I was getting a result, but it was still failing.
2019-10-03 18:06:13 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140550098879824] Received {'type': 'call_service', 'domain': 'shell_command', 'service': 'basic_curl', 'service_data': {}, 'id': 22}
2019-10-03 18:06:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=shell_command, service=basic_curl, service_data=>
2019-10-03 18:06:13 DEBUG (MainThread) [homeassistant.components.shell_command] Stderr of command: `curl -v --basic --user test:testTEST http://x.x.x.x/cgi-bin/magicBox.cgi?action=getVendor`, return code: 0:
b'
* Trying x.x.x.x:80...
* TCP_NODELAY set
* Connected to x.x.x.x (x.x.x.x) port 80 (#0)
* Server auth using Basic with user \'test\'
> GET /cgi-bin/magicBox.cgi?action=getVendor HTTP/1.1
> Host: x.x.x.x
> Authorization: Basic BASE64_HORRIBLE_PASSWORD_IDEA_IETF
> User-Agent: curl/7.65.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Digest realm="Login to REDACTED", qop="auth", nonce="NONCE", opaque="OPAQUE"
< Connection: close
< CONTENT-LENGTH: 0
<
* Closing connection 0
'
2019-10-03 18:06:13 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140550098879824] Sending {'id': 22, 'type': 'result', 'success': True, 'result': None}
2019-10-03 18:06:26 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140550098879824] Received {'type': 'call_service', 'domain': 'shell_command', 'service': 'digest_curl', 'service_data': {}, 'id': 23}
2019-10-03 18:06:26 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=shell_command, service=digest_curl, service_data=>
2019-10-03 18:06:26 DEBUG (MainThread) [homeassistant.components.shell_command] Stdout of command: `curl -v --digest --user test:testTEST http://x.x.x.x/cgi-bin/magicBox.cgi?action=getVendor`, return code: 0:
b'
vendor=Amcrest
'
2019-10-03 18:06:26 DEBUG (MainThread) [homeassistant.components.shell_command] Stderr of command: `curl -v --digest --user test:testTEST http://x.x.x.x/cgi-bin/magicBox.cgi?action=getVendor`, return code: 0:
b'
* Trying x.x.x.x:80...
* TCP_NODELAY set
* Connected to x.x.x.x (x.x.x.x) port 80 (#0)
* Server auth using Digest with user \'test\'
> GET /cgi-bin/magicBox.cgi?action=getVendor HTTP/1.1
> Host: x.x.x.x
> User-Agent: curl/7.65.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Digest realm="Login to REDACTED", qop="auth", nonce="NONCE", opaque="OPAQUE"
< Connection: close
< CONTENT-LENGTH: 0
<
* Closing connection 0
* Issue another request to this URL: \'http://x.x.x.x/cgi-bin/magicBox.cgi?action=getVendor\'
* Hostname x.x.x.x was found in DNS cache
* Trying x.x.x.x:80...
* TCP_NODELAY set
* Connected to x.x.x.x (x.x.x.x) port 80 (#1)
* Server auth using Digest with user \'test\'
> GET /cgi-bin/magicBox.cgi?action=getVendor HTTP/1.1
> Host: x.x.x.x
> Authorization: Digest username="test", realm="Login to REDACTED", nonce="NONCE", uri="/cgi-bin/magicBox.cgi?action=getVendor", cnonce="CNONCE=", nc=00000001, qop=auth, response="REPONSE", opaque="OPAQUE"
> User-Agent: curl/7.65.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-type: text/plain;charset=utf-8
< CONNECTION: close
< CONTENT-LENGTH: 16
<
{ [16 bytes data]
* Closing connection 1
'
2019-10-03 18:06:26 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140550098879824] Sending {'id': 23, 'type': 'result', 'success': True, 'result': None}
I guess I’m a bit confused. This suggests that the amcrest component should have worked, yet it didn’t.
The amcrest component will first attempt using basic authentication (to support older models.) If that fails with an error 401 (Unauthorized) it will then attempt using digest authentication.
This is what the output from the curl commands show. I.e., basic fails with error 401, but digest works.
BUT, when the amcrest component tried basic authentication, it didn’t fail with an error 401, it failed with a ConnectTimeout. I.e., the camera did not return error 401, it in fact returned nothing.
I suspect the shell_command is still not running in the right container/context. I’m probably going to have to stop cheating and just get into the docker itself
Well, FWIW, it uses asyncio.subprocess.create_subprocess_shell
or asyncio.subprocess.create_subprocess_exec
. I can’t say I really know how those work, but I’d assume they run at least in the same docker as HA.
And now you know why I don’t bother with hassio, docker, etc. Yes, I guess I miss out on “add ons”, and probably other advantages, but in a year and a half using HA, I’ve not missed them.
I am in the same boat;
Getting a lot of error messages in HA logs, but I do get stream and snapshot of the amcrest camera in HA (so it is working but spoiling the error logs).
2020-08-06 11:17:00 DEBUG (SyncWorker_6) [homeassistant.components.amcrest] els_wash_210 camera errs: 1
2020-08-06 11:17:00 ERROR (SyncWorker_6) [homeassistant.components.amcrest.camera] Could not get els_wash_210 camera attributes due to error: CommError
2020-08-06 11:17:00 DEBUG (SyncWorker_7) [homeassistant.components.amcrest.camera] Updating els_beik_215 camera
2020-08-06 11:17:00 WARNING (SyncWorker_7) [amcrest.http] <2J0225PZA9A0014:2J0225PZA9A0014> Trying again due to error: HTTPError('403 Client Error: Forbidden for url: http://192.168.2.215:80/cgi-bin/configManager.cgi?action=getConfig&name=RecordMode')
I am also on hassio.
my configuration.yaml
amcrest:
- host: 192.168.2.200
name: els_flur_200
username: !secret cctv_user
password: !secret cctv_password
# authentication: digest
resolution: low
sensors:
# - motion_detector
# - sdcard
# switches:
# - motion_detection
# - motion_recording
Tried curl -v on a terminal console of my HA host (terminal within HA):
-» ~ curl --digest --user admin http://192.168.2.200/cgi-bin/magicBox.cgi\?action\=getVendor -v Enter host password for user 'admin':
* Trying 192.168.2.200:80...
* TCP_NODELAY set
* Connected to 192.168.2.200 (192.168.2.200) port 80 (#0)
* Server auth using Digest with user 'admin'
> GET /cgi-bin/magicBox.cgi?action=getVendor HTTP/1.1
> Host: 192.168.2.200
> User-Agent: curl/7.67.0
> Accept: */* >
* Mark bundle as not supporting multiuse
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Digest realm="Login to 2J0225PZA8H0318", qop="auth"J nonce="279112332", Opaque="480b6bc94748118c5fa5077c9071664900fbfd50"
< Connection: close
< Set-Cookie:secure; HttpOnly
< CONTENT-LENGTH: 0
<
* Closing connection 0
* Issue another request to this URL: ,http://192.168.2.200/cgi-bin/magicBox.cgi?action=getVendor'
* Hostname 192.168.2.200 was found in DNS cache
*
Trying 192.168.2.200:80...
* TCP_NODELAY set
* Connected to 192.168.2.200 (192.168.2.200) port 80 (#1)
* Server auth using Digest with user 'admin'
> GET /cgi-bin/magicBox.cgi?action=getVendor HTTP/1.1
> Host: 192.168.2.200
> Authorization: Digest username="admin", realm="Login to 2J0225PZA8H0318", nonce="279112332", uri="/cgi-bin/magicBox.cgi?action=getVendor"J cnonce="MzBiMmU4OTY4Mzg2YzJkN2VhYTRkYzYlZjA0NmYlZTc=" , nc=00000001, qop=auth, response="e940054334e668f25f9d28c9c07e003f", Opaque="480b6bc94748118c5fa5077c9071664900fbfd50"
> User-Agent: curl/7.67.0
> Accept: */* >
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-type: text/plain;charset=utf-8
< CONNECTION: close
< Set-Cookie:secure; HttpOnly
< CONTENT-LENGTH: 14
<
vendor=Dahua
* Closing connection 1
any idea?
What version of HA are you using?
tnx for coming back to my issue;
the most recent one ( Home Assistant 0.113.3)
As curl with “Digest” is running without issue maybe it is a good idea to have this configuration possibility in HA (authentication does not take “Digest” as value); this way your component does not need to check “basic” beforehand to then switch to “Digest” and generating “errors” while trying to get a connection under “basic”.
Wondering that nobody else seems to have this issue.
Your errors are not due to basic authentication failing. That is error 401, and would not be logged as a warning or error. You’re getting error 403 which is something different. That could be due to your camera not being compatible with HA’s amcrest integration (or vice versa.)
Does this camera ever work with HA’s amcrest integration? Does it cause errors sometimes, or all the time?
ok, tnx for the clarification.
But the “problems” are just log related.
Apart from this the camras are working nicely within HA and your Amcrest integration.
The (log) issues are since long; would be great to get rid of these as they are floating my logs (I do have 10 cameras and so the problems are multiplying).
The camera itself is a Dahua Starlight.
The status of the camera entities is “idle”.
tnx
according to wikipedia:
HTTP 403 is returned when the client is not permitted access to the resource despite providing authentication such as insufficient permissions of the authenticated account.
Error 403: “The server understood the request, but is refusing to authorise it.”, RFC 7231[1]
Strangely curl is working nicely and not causing any errors while accessing the cameras.
Yes, 403 means what you’re asking is not allowed, not that it doesn’t know who you are. I.e., authentication worked (hence no error 401), but authorization did not. For the camera, that basically means you’re asking it to do something it doesn’t know how to do.
That’s because you asked it to do something (“http://192.168.2.200/cgi-bin/magicBox.cgi\?action\=getVendor
”, i.e., return the vendor name) that it knows how to do.
If you look at the error, it’s occurring because it’s asking something else:
Forbidden for url: http://192.168.2.215:80/cgi-bin/configManager.cgi?action=getConfig&name=RecordMode
So try this:
curl --digest --user admin http://192.168.2.215:80/cgi-bin/configManager.cgi?action=getConfig&name=RecordMode
And, BTW, I just noticed you’re using two different IP addresses: 192.168.2.200 & 192.168.2.215???
I’ve also found that these cameras sometimes just refuse to do what they are asked, but when retried the command that just failed, works. I have considered changing some of the messages classified as WARNING to INFO or DEBUG, especially when retrying, (because, unfortunately, there’s no way to filter WARNING messages from the UI log) but I just haven’t gotten around to doing that yet.
good idea trying with the error message causing curl command:
-» ~curl--digest--useradminhttp://192.168.2.215:80/cgi-bin/configManager.cgi\?action\=getConfig\8name\=RecordMode Enter host password for user 'admin':
table.RecordMode[0].Mode=0
table.RecordMode[0],ModeExtral=0
from my point of view no error with curl.
My fault with the different ip address (I do have the same message from 192.168.2.210); it is the ip address of one of the other nine cameras but they are all having the same issue.
2020-08-06 11:17:00 DEBUG (SyncWorker_6) [homeassistant.components.amcrest] els_wash_210 camera errs: 1
2020-08-06 11:17:00 ERROR (SyncWorker_6) [homeassistant.components.amcrest.camera] Could not get els_wash_210 camera attributes due to error: CommError
2020-08-06 11:17:00 DEBUG (SyncWorker_7) [homeassistant.components.amcrest.camera] Updating els_beik_215 camera
2020-08-06 11:17:00 WARNING (SyncWorker_7) [amcrest.http] <2J0225PZA9A0014:2J0225PZA9A0014> Trying again due to error: HTTPError('403 Client Error: Forbidden for url: http://192.168.2.215:80/cgi-bin/configManager.cgi?action=getConfig&name=RecordMode')
but it seems to be that your component is asking the camera for attributes which might not be there (maybe this RecordMode).
getting rid of the warning messages would be great and ideally getting rid of the connection Error (maybe generating this error only if the connection fails for x times).
tnx
That may be the case, and if it is, then the integration doesn’t support that camera model / firmware version.
Clearly you have debug enabled for homeassistant.components.amcrest
. What do you have amcrest
set to? If not debug, then could you set it to debug? I.e.:
logger:
default: info
logs:
amcrest: debug
homeassistant.components.amcrest: debug
Then look at more of the log. See if that command always fails, or eventually works, possibly on a retry.
If it never works, then the integration just doesn’t support that camera. That’s not necessarily to say that it never could, just that it might not as it is.
@pnbruckner Hello good (CET) eveing and happy New Year
I think you are the mantainer of the Amcrest integration.
I had to switch to a HassOS VM setup from core and I cannot get the cameras (Dahua recognized as amcrest under ha core) to work,
Is there anything specific to be done?
I have stream: and ffmpeg: enabled in configuration.yaml and the same configuration I had in ha core for the cameras
also
I noticed in ssh on the VM that ffmpeg package was not installed and I manually installed .
I read it should have been preinstalled…
Thanks in advance
2021-01-07 22:29:48 ERROR (Amcrest TelecameraCucina) [homeassistant.components.amcrest] TelecameraCucina camera offline: Too many errors
2021-01-07 22:29:48 ERROR (Amcrest TelecameraIngresso) [homeassistant.components.amcrest] TelecameraIngresso camera offline: Too many errors
2021-01-07 22:29:48 ERROR (Amcrest TelecameraPortico) [homeassistant.components.amcrest] TelecameraPortico camera offline: Too many errors
2021-01-07 22:29:48 ERROR (Amcrest TelecameraSoggiorno) [homeassistant.components.amcrest] TelecameraSoggiorno camera offline: Too many errors
2021-01-07 22:29:48 ERROR (Amcrest TelecameraLetto) [homeassistant.components.amcrest] TelecameraLetto camera offline: Too many errors
config
- host: !secret TelecameraLetto_url
name: TelecameraLetto
stream_source: rtsp
username: !secret TelecameraLetto_user
password: !secret TelecameraLetto_password
binary_sensors:
- motion_detected
- online
Hi and Happy New Year.
I’m really not maintaining the integration anymore. Also I know absolutely nothing about HassOS VM. But my guess would be some sort of networking configuration issue; i.e., HA not able to communicate with the cameras. If I were you, I’d ask for help in a forum category more associated with HassOS. Good luck!
Hi thanks for the feedback.
Never mind. I will find a way.
Icould get the cameras stream through onvif.
Well at least some of them… damn dahua