Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Make amcrest integration more robust #30843
The amcrest integration has had some lingering communication issues for a while. E.g., when taking a snapshot (i.e.,
This PR includes many improvements, including in the amcrest package it uses, to enhance robustness. It also eliminates communicating with the camera during integration setup to avoid delays caused if the camera is offline, with the added benefit that the entity will always be created, but will go to
List of changes:
Related issue (if applicable): possibly #30523
Pull request with documentation for home-assistant.io (if applicable): N/A
If the code communicates with devices, web services, or third-party tools:
@MartinHjelmare sorry about that. But I didn't move the card from the dev project page. I simply used the Dev Project drop-down at the top-right of this PR page and selected the "Needs review" option from the list. I had no reason to suspect that that would do the wrong thing.
Is there somewhere where project administrative guidelines and/or procedures are documented? I'd like to help out more, but I'm afraid to mess things up (case in point: trying to make a simple change to a PR as I did here.)
@MartinHjelmare I was wondering if you, or someone else, would have time to review this. I understand it's not small or trivial, but I've put in a lot of work to improve the robustness of this integration. I've been testing it on my own system for weeks now and it has definitely reduced the number of warnings, errors and command failures. I'd like to see users benefit from these changes.
Also, I'm working on changing the motion detection sensor from polling to streaming (which will both reduce network traffic, as well as make the sensor much more responsive), but I'd like to get this resolved before submitting that PR.
Thanks for you consideration! I know you're very busy.
Would it help if I removed the following?
That would make the PR smaller and easier to understand. And I have another change to the binary sensors queued up anyway.
Actually, I think I'll go ahead and do that. I'll hopefully push another commit later today or early next week...
- Bump amcrest package to 1.5.6. Includes networking improvements, no longer communicates during Http.__init__(), and allows running snapshot command without using stream mode. - Handle login errors better, and not just at startup. - Increase network connect & read timeout to 6.05 seconds. - Increase network read timeout to 20 seconds for snapshot command. - Run snapshot command in separate task, that cannot be cancelled, to eliminate possibility of two snapshot commands running simultaneously (since AmcrestCam.async_camera_image can be cancelled.) Also makes sure any exceptions from the command are caught properly.
Sorry, I did a force push because it didn't look like anyone had started reading it yet. But basically all that did was to effectively revert all the changes to binary_sensor.py, as well as one related line that was added to const.py. I also took the opportunity to change one line in camera.py -- I simplified
I appreciate you looking at this. Let me know if you have any questions.
@MartinHjelmare do you think you'll be able to review this before too long? Or would it be ok if I just went ahead and merged it? I've tested this extensively so I'm pretty sure it works without causing any bad side effects. Also I have another PR ready to submit that converts the binary sensors from polling to streaming, and I have other improvements I'd like to make (remove old, unneeded, effectively dead code, add config flow, etc.), but I'm kind of stalled here. Kind of hard to keep momentum when one change takes this long to get done.