New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Amcrest event monitor to non-async #69640
Conversation
I'm not sure if this was also intended to address #68271, but I've been running this change on 2022.3.5 for about a day and so far have not experienced the issue I was having in that ticket, so this seems to have fixed it. |
6605d11
to
a00eaa5
Compare
a00eaa5
to
23223c4
Compare
I am able to still reproduce that error with this change in place. The best way to do that is to unplug the camera while moving it to trigger the motion detection. When the camera is plugged back in and comes back online, it will still be in the motion detected state. |
Ah, okay. I didn't test that case. I was just referring to the issue I was seeing - where the camera was not rebooting but motion detection would get stuck in the on state. |
Ah, yep, this should help cover that case! I think that issue is related to the reconnecting problems that exist currently, which is what this change is addressing. |
Hi to everyone, sorry for my ignorance but having the same issue on my dahua cameras (5, all configured in yaml) I was wondering if there is something that needs to be done on my part to solve the problem or if there will be a new home assistant release which will take care of everything. Many thanks |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
It doesn't look like an issue has been opened with |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Please move this discussion to the forum as its not discussing the code in this PR. The path forward will be decided when the OP responds to the comment I made above. As there has been no response I can't predict what the outcome of this PR will be. |
Sorry I missed that. I opened up a discussion at encode/httpx#2203 in the httpx project to get the functionality we need there to be able to effectively use that for streaming the event data. I would definitely want to switch back to async once we can figure out how to get httpx working properly, but with the current integration broken until that happens, it would be great if we could land this revent in the interim. |
Proposed change
Several problems have come up since using the async-based event monitor in the Amcrest component that stem from the differences between
requests
(which is used for synchronous http requests) andhttpx
(which is used for asynchronous http requests) and the workarounds that have been put in place to try to handle these differences. The underlying issue is thathttpx
will not drop a streaming connection when the resource is no longer available (eg the camera goes offline) when the read timeout is set to be infinite, whilerequests
will drop such a connection. Adding a timeout tohttpx
leads to the issues linked below.httpx
is the only http library I know of with async support for digest authentication, which is needed to communicate with Amcrest cameras. This change reverts back to using the non-asyncrequests
-based event stream method to get stable behavior back for the integration. I have tested this by running locally and ensuring the event handling works correctly and does not cause any of the error messages that have been reported.Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: