Yes you need to make sure ffmpeg is setup. See ffmpeg hub
The custom_components folder needs to be in the same folder as the configuration.yaml
Yes you need to make sure ffmpeg is setup. See ffmpeg hub
The custom_components folder needs to be in the same folder as the configuration.yaml
Ok matt…
now all is working perfectly!
Installed the ffmpeg and put into the config, then only with the ip i can see the image from cam.
Thanks for all!
I’ve tried adding your custom component which has solved the wsdl issue. However I am now getting an issue with the stream closing unexpectedly.
I am using the official docker image at 0.48.1 and have ffmpeg setup.
2017-07-23 19:25:55 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 422, in start
resp = yield from self._request_handler(request)
File "/usr/local/lib/python3.6/site-packages/aiohttp/web.py", line 306, in _handle
resp = yield from handler(request)
File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 213, in coro
res = yield from res
File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 213, in coro
res = yield from res
File "/usr/src/app/homeassistant/components/http/ban.py", line 58, in ban_middleware_handler
return (yield from handler(request))
File "/usr/src/app/homeassistant/components/http/__init__.py", line 424, in handle
result = yield from result
File "/usr/src/app/homeassistant/components/camera/__init__.py", line 338, in get
response = yield from self.handle(request, camera)
File "/usr/src/app/homeassistant/components/camera/__init__.py", line 376, in handle
yield from camera.handle_async_mjpeg_stream(request)
File "/config/custom_components/camera/onvif.py", line 99, in handle_async_mjpeg_stream
yield from stream.close()
File "/usr/local/lib/python3.6/site-packages/haffmpeg/core.py", line 131, in close
yield from self._proc.communicate(input=b'q')
File "/usr/local/lib/python3.6/asyncio/subprocess.py", line 195, in communicate
loop=self._loop)
File "/usr/local/lib/python3.6/asyncio/futures.py", line 331, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
future.result()
File "/usr/local/lib/python3.6/asyncio/futures.py", line 244, in result
raise self._exception
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 179, in _step
result = coro.send(None)
File "/usr/local/lib/python3.6/asyncio/subprocess.py", line 143, in _feed_stdin
self.stdin.write(input)
File "/usr/local/lib/python3.6/asyncio/streams.py", line 294, in write
self._transport.write(data)
File "uvloop/handles/stream.pyx", line 632, in uvloop.loop.UVStream.write (uvloop/loop.c:74612)
File "uvloop/handles/handle.pyx", line 150, in uvloop.loop.UVHandle._ensure_alive (uvloop/loop.c:54917)
RuntimeError: unable to perform operation on <WriteUnixTransport closed=True reading=False 0x7f2fc0f8dbd8>; the handler is closed
What camera are you using? Do you get a picture at all?
It’s a Digoo DG-M1Q. I can get a picture using rstp but not onvif.
Try adding debug logging for the component.
logger:
logs:
homeassistant.components.camera: debug
custom_components.camera.onvif: debug
You should then see the steam URL in the log. That should be a rtsp URL.
Not sure that logging config is correct. I get this error.
2017-07-23 21:20:22 ERROR (MainThread) [homeassistant.config] Invalid config for [logger]: [homeassistant.components.camera] is an invalid option for [logger]. Check: logger->logger->homeassistant.components.camera. (See /config/configuration.yaml, line 133). Please check the docs at https://home-assistant.io/components/logger/
2017-07-23 21:20:22 ERROR (MainThread) [homeassistant.setup] Setup failed for logger: Invalid config.
It looks like it gets the correct URL for rtsp from the onvif service. However it doesn’t include the username and password. If I manually add an ffmpeg component with the username and password included in the url it works.
2017-07-24 07:05:54 DEBUG (MainThread) [custom_components.camera.onvif] ONVIF Camera Using the following URL for Thumper Cam: rtsp://192.168.0.57:554/onvif1
Working url rtsp://username:[email protected]:554/onvif1
.
That’ll be the issue. I’ll have a look at the code tonight and update once i’ve got a fix. I’ll need to test that it doesn’t break existing code.
I’ve made another change to allow RTSP auth
here is the custom_component (https://gist.githubusercontent.com/matt2005/c9bd5972219652ee3b27584f8951662e/raw/7162a7319fb78ecaafd1c84300bf44c04ed89b6f/onvif.py)
You will need to add STREAM_AUTH in you config if your camera requires RTSP authentication.
No luck here, it works with Onvifier on my phone though:
Network Video Transmitter (NVT) name: IPCAM NVT type: ONVIF Model: C6F0SgZ0N0P0L0 Address/URL: 192.168.1.111:8080 Media Profile: MainProfile Resolution: 1920x1088 Encoding: H264 H.264: Main Profile Level: 4.2 Transport protocol: RTP/RTSP/TCP RTP packets received: 2056 RTP packets lost: 0 Frame rate (fps): 14.4 Audio: G.711 A-Law ONVIF port: 8080 RTSP port: 554 Data Rate (Mbit/s): 0.950 1501187908110:1501187908110
What error are you seeing? Have you added the debug logging?
Yeah, installed the custom component and enabled logging. It looks like my camera’s rtsp port is 554 if that’s any use. It looks like it’s not even getting to the point where it receives the stream url
2017-07-29 11:09:47 INFO (MainThread) [homeassistant.components.camera] Setting up camera.onvif
2017-07-29 11:09:53 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Traceback (most recent call last):
File "/config/deps/suds/transport/http.py", line 78, in send
fp = self.u2open(u2request)
File "/config/deps/suds/transport/http.py", line 119, in u2open
return url.open(u2request, timeout=tm)
File "/usr/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/config/deps/suds/client.py", line 652, in send
reply = transport.send(request)
File "/config/deps/suds/transport/http.py", line 178, in send
return HttpTransport.send(self, request)
File "/config/deps/suds/transport/http.py", line 86, in send
raise TransportError(e.msg, e.code, e.fp)
suds.transport.TransportError: Bad Request
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/onvif/client.py", line 34, in wrapped
return func(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/onvif/client.py", line 201, in wrapped
return call(params, callback)
File "/usr/lib/python3.6/site-packages/onvif/client.py", line 191, in call
ret = func(**params)
File "/config/deps/suds/client.py", line 559, in __call__
return client.invoke(args, kwargs)
File "/config/deps/suds/client.py", line 618, in invoke
result = self.send(soapenv)
File "/config/deps/suds/client.py", line 664, in send
result = self.failed(binding, e)
File "/config/deps/suds/client.py", line 726, in failed
raise Exception((status, reason))
Exception: (400, 'Bad Request')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File "/usr/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
return fut.result()
File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result
raise self._exception
File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
result = coro.send(None)
File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro
res = func(*args, **kw)
File "/config/custom_components/camera/onvif.py", line 51, in async_setup_platform
async_add_devices([ONVIFCamera(hass, config)])
File "/config/custom_components/camera/onvif.py", line 72, in __init__
self._input = media.GetStreamUri().Uri
File "/usr/lib/python3.6/site-packages/onvif/client.py", line 36, in wrapped
raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: (400, 'Bad Request')
I’ve seen the error 400 when the credentials are incorrect. Have you configured them in the configuration?
Yeah, here’s my configuration and some screenshots from the camera’s control website. Thanks for the help by the way.
What are you seeing in the debug logs?
Having a similar problem to others with a KKmoon Wireless Wifi 720P HD H.264 P2P 1MP AP IP Network Home IR Security Camera P/T Webcam
I’m using HA 0.53.0 and loaded the custom component but, it doesn’t appear to be providing the debug URL.
(homeassistant) homeassistant@HassPi:~/.homeassistant/custom_components/camera$ ls -l
total 8
-rw-r--r-- 1 homeassistant nogroup 3604 Sep 11 03:21 onvif.py
drwxr-xr-x 2 homeassistant nogroup 4096 Sep 11 03:22 __pycache__
Here is my logger config:
logger:
default: warn
logs:
homeassistant.components.camera: debug
homeassistant.util.package: info
custom_components.camera.onvif: debug
homeassistant.components.camera.onvif: debug
ONVIF Config:
ffmpeg:
ffmpeg_bin: /usr/bin/ffmpeg
camera:
- platform: onvif
host: 192.168.1.219
port: 8080
username: ****
password: ****
Here is my traceback:
Sep 11 03:23:36 HassPi hass[1064]: 2017-09-11 03:23:36 INFO (Thread-11) [homeassistant.util.package] Attempting install of http://github.com/tgaugry/suds-passworddigest-py3/archive/86fc50e39b4d2b8997481967d6a7fe1c57118999.zip#suds-passworddigest-py3==0.1.2a
Sep 11 03:23:50 HassPi hass[1064]: 2017-09-11 03:23:50 INFO (MainThread) [homeassistant.components.camera] Setting up camera.onvif
Sep 11 03:23:57 HassPi hass[1064]: 2017-09-11 03:23:57 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Sep 11 03:23:57 HassPi hass[1064]: Traceback (most recent call last):
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/suds/transport/http.py”, line 78, in send
Sep 11 03:23:57 HassPi hass[1064]: fp = self.u2open(u2request)
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/suds/transport/http.py”, line 119, in u2open
Sep 11 03:23:57 HassPi hass[1064]: return url.open(u2request, timeout=tm)
Sep 11 03:23:57 HassPi hass[1064]: File “/usr/lib/python3.4/urllib/request.py”, line 461, in open
Sep 11 03:23:57 HassPi hass[1064]: response = meth(req, response)
Sep 11 03:23:57 HassPi hass[1064]: File “/usr/lib/python3.4/urllib/request.py”, line 571, in http_response
Sep 11 03:23:57 HassPi hass[1064]: ‘http’, request, response, code, msg, hdrs)
Sep 11 03:23:57 HassPi hass[1064]: File “/usr/lib/python3.4/urllib/request.py”, line 499, in error
Sep 11 03:23:57 HassPi hass[1064]: return self._call_chain(*args)
Sep 11 03:23:57 HassPi hass[1064]: File “/usr/lib/python3.4/urllib/request.py”, line 433, in _call_chain
Sep 11 03:23:57 HassPi hass[1064]: result = func(*args)
Sep 11 03:23:57 HassPi hass[1064]: File “/usr/lib/python3.4/urllib/request.py”, line 579, in http_error_default
Sep 11 03:23:57 HassPi hass[1064]: raise HTTPError(req.full_url, code, msg, hdrs, fp)
Sep 11 03:23:57 HassPi hass[1064]: urllib.error.HTTPError: HTTP Error 400: Bad Request
Sep 11 03:23:57 HassPi hass[1064]: During handling of the above exception, another exception occurred:
Sep 11 03:23:57 HassPi hass[1064]: Traceback (most recent call last):
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/suds/client.py”, line 652, in send
Sep 11 03:23:57 HassPi hass[1064]: reply = transport.send(request)
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/suds/transport/http.py”, line 178, in send
Sep 11 03:23:57 HassPi hass[1064]: return HttpTransport.send(self, request)
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/suds/transport/http.py”, line 86, in send
Sep 11 03:23:57 HassPi hass[1064]: raise TransportError(e.msg, e.code, e.fp)
Sep 11 03:23:57 HassPi hass[1064]: suds.transport.TransportError: Bad Request
Sep 11 03:23:57 HassPi hass[1064]: During handling of the above exception, another exception occurred:
Sep 11 03:23:57 HassPi hass[1064]: Traceback (most recent call last):
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/onvif/client.py”, line 34, in wrapped
Sep 11 03:23:57 HassPi hass[1064]: return func(*args, **kwargs)
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/onvif/client.py”, line 201, in wrapped
Sep 11 03:23:57 HassPi hass[1064]: return call(params, callback)
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/onvif/client.py”, line 191, in call
Sep 11 03:23:57 HassPi hass[1064]: ret = func(**params)
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/suds/client.py”, line 559, in call
Sep 11 03:23:57 HassPi hass[1064]: return client.invoke(args, kwargs)
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/suds/client.py”, line 618, in invoke
Sep 11 03:23:57 HassPi hass[1064]: result = self.send(soapenv)
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/suds/client.py”, line 664, in send
Sep 11 03:23:57 HassPi hass[1064]: result = self.failed(binding, e)
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/suds/client.py”, line 726, in failed
Sep 11 03:23:57 HassPi hass[1064]: raise Exception((status, reason))
Sep 11 03:23:57 HassPi hass[1064]: Exception: (400, ‘Bad Request’)
Sep 11 03:23:57 HassPi hass[1064]: During handling of the above exception, another exception occurred:
Sep 11 03:23:57 HassPi hass[1064]: Traceback (most recent call last):
Sep 11 03:23:57 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 164, in _async_setup_platform
Sep 11 03:23:57 HassPi hass[1064]: SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
Sep 11 03:23:57 HassPi hass[1064]: File “/usr/lib/python3.4/asyncio/tasks.py”, line 372, in wait_for
Sep 11 03:23:57 HassPi hass[1064]: return fut.result()
Sep 11 03:23:57 HassPi hass[1064]: File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
Sep 11 03:23:57 HassPi hass[1064]: raise self._exception
Sep 11 03:23:57 HassPi hass[1064]: File “/usr/lib/python3.4/asyncio/tasks.py”, line 237, in _step
Sep 11 03:23:57 HassPi hass[1064]: result = next(coro)
Sep 11 03:23:58 HassPi hass[1064]: File “/usr/lib/python3.4/asyncio/coroutines.py”, line 141, in coro
Sep 11 03:23:58 HassPi hass[1064]: res = func(*args, **kw)
Sep 11 03:23:58 HassPi hass[1064]: File “/home/homeassistant/.homeassistant/custom_components/camera/onvif.py”, line 48, in async_setup_platform
Sep 11 03:23:58 HassPi hass[1064]: async_add_devices([ONVIFCamera(hass, config)])
Sep 11 03:23:58 HassPi hass[1064]: File “/home/homeassistant/.homeassistant/custom_components/camera/onvif.py”, line 70, in init
Sep 11 03:23:58 HassPi hass[1064]: self._input = media.GetStreamUri().Uri
Sep 11 03:23:58 HassPi hass[1064]: File “/srv/homeassistant/lib/python3.4/site-packages/onvif/client.py”, line 36, in wrapped
Sep 11 03:23:58 HassPi hass[1064]: raise ONVIFError(err)
Sep 11 03:23:58 HassPi hass[1064]: onvif.exceptions.ONVIFError: Unknown error: (400, ‘Bad Request’)
It appears the change was merged, is the custom component even required still?
Custom component is no longer required as the change was merged. However error 400 bad request usually means you have the wrong ip or port.
Same config I’m using for ONVIFER app.