-
Notifications
You must be signed in to change notification settings - Fork 76
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
snapshot() does not work for some cameras (HASS: Amcrest Cameras fail after update to 0.59.1) #86
Comments
@akerrichardt have you upgraded the firmware of your cameras recently? Do you know which firmware these cameras are running? Finally, could you please share your amcrest settings from configuration.yaml (removing the username/password) ? |
@akerrichardt I just updated mine HASS and I got the same issue on 0.60.1. I'll take a look at what is going on in 2 weeks since I'm leaving on vacations. |
Quick update... I have 4 amcrest cameras running with HASS. 2 of them are working and 2 are failing. Working Failing An important note is that I'm getting the error on the HASS webui, however if I click on the image I can see the live stream: So this seems to be a problem with a newer fewer as we can note on the test below: (python:ha-py36) ↪ amcrest-cli --camera amcrestcam1 --snapshot 1 --save ~/Desktop/lala.jpg ; file ~/Desktop/lala.jpg
/home/mdemello/Desktop/lala.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, comment: "", comment: "DHAV\373", baseline, precision 8, 1920x1080, frames 3 failing one (python:ha-py36) ↪ amcrest-cli --camera amcrestcam4 --snapshot 1 --save ~/Desktop/lala.jpg ; file ~/Desktop/lala.jpg
/home/mdemello/Desktop/lala.jpg: empty Troubleshooting via RPB: In [3]: camera.software_information
Out[3]: ('version=2.400.AC01.15.R', 'build:2017-03-28\r\n')
In [4]: camera.snapshot(0, "/home/user/Desktop/snapshot00.jpeg")
pdb is running on 127.0.0.1:4444
(Pdb) ret
<Response [401]>
(Pdb) ret.headers
{'WWW-Authenticate': 'Digest realm="Login to AMC02<REDACTED>",qop="auth",nonce="392412475",opaque="bb5e1d12c0f69db4ae07a9cb8c901c07c"', 'Connection': 'close', 'CONTENT-LENGTH': '0'}
(Pdb) ret.status_code
401 Firmware changelog: @dougsland is your cameras working fine? |
Digging a little bit more into this, I'm getting 500 errors when trying to snapshot. In [24]: req = requests.get(url, auth=auth2, stream=True)
In [25]: req
Out[25]: <Response [500]>
In [26]: url
Out[26]: 'http://192.168.0.1:80/cgi-bin/snapshot.cgi?channel=0'
In [27]: auth2
Out[27]: <requests.auth.HTTPDigestAuth at 0x7fcd0c1680f0> I think the next step to troubleshoot what is going on is to put a sniffer between the application and the camera to see what is going on. |
One temporarly alternative would be to gather the screenshot via ffmpeg within HASS, however it will not address the issue on |
Other people hitting the same issue: https://amcrest.com/forum/viewtopic.php?f=3&t=3060&p=10410&hilit=snapshot+API#p10410 |
Modified the HASS amcrest code to use ffmpeg to generate the snapshot and it worked as expected. --- a/homeassistant/components/camera/amcrest.py
+++ b/homeassistant/components/camera/amcrest.py
@@ -50,11 +50,19 @@ class AmcrestCam(Camera):
self._resolution = amcrest.resolution
self._token = self._auth = amcrest.authentication
- def camera_image(self):
+ @asyncio.coroutine
+ def async_camera_image(self):
"""Return a still image response from the camera."""
- # Send the request to snap a picture and return raw jpg data
- response = self._camera.snapshot(channel=self._resolution)
- return response.data
+ from haffmpeg import ImageFrame, IMAGE_JPEG
+ ffmpeg = ImageFrame(self._ffmpeg.binary, loop=self.hass.loop)
+ streaming_url = self._camera.rtsp_url(typeno=self._resolution)
+ if streaming_url is None:
+ return
+
+ image = yield from asyncio.shield(ffmpeg.get_image(
+ streaming_url, output_format=IMAGE_JPEG,
+ extra_cmd=self._ffmpeg_arguments), loop=self.hass.loop)
+ return image
@asyncio.coroutine
def handle_async_mjpeg_stream(self, request): @akerrichardt I'm going to create a test file so then you drop on your custom_components to test it |
How to install hotfix on HASS:
cd /home/hass/.homeassistant
mkdir -p custom_components/camera
wget https://raw.githubusercontent.com/tchellomello/home-assistant/hotfix_amcrest/homeassistant/components/camera/amcrest.py -O /home/hass/custom_components/camera/amcrest.py
This should workaround the issue for now. @akerrichardt Please let me know if that worked for you |
I'm not sure if this will help you with a fix, but I tried my own manual fix to use in appdaemon and found that the HTTPDigestAuth needed to be used:
|
Hi all. I suspect these problems have been addressed by recent updates to this package as well as the HA amcrest component. I'm going to close this, but feel free to reopen if necessary. |
**Description of problem:**After upgrade to 0.59.1 only 1 of my Amcrest cameras output appear in both of my Amcrest cameras displays on the Dashboard.
I upgrade my RPI 3 running on Raspbian Stretch Desktop to HA version 0.60.0. Still having the same trouble with my Amcrest Cameras. I did see this in the Info tab if this helps!!
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /cgi-bin/snapshot.cgi?channel=0
2:18 PM components/camera/amcrest.py (WARNING)
The text was updated successfully, but these errors were encountered: