ONVIF camera

Hi,

my config file:

and my log:

About

Home Assistant
0.47.0

Path to configuration.yaml: /home/homeassistant/.homeassistant

Developed by a bunch of awesome people.

Published under the Apache 2.0 license
Source: server — frontend-ui

Built using Python 3, Polymer 1.8.1, Icons by Google and MaterialDesignIcons.com.

The following errors have been logged this session:

2017-06-18 23:05:28 WARNING (MainThread) [homeassistant.setup] Setup of camera is taking over 10 seconds.
2017-06-18 23:05:38 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Traceback (most recent call last):
File “/usr/lib/python3.4/urllib/request.py”, line 1174, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File “/usr/lib/python3.4/http/client.py”, line 1090, in request
self._send_request(method, url, body, headers)
File “/usr/lib/python3.4/http/client.py”, line 1128, in _send_request
self.endheaders(body)
File “/usr/lib/python3.4/http/client.py”, line 1086, in endheaders
self._send_output(message_body)
File “/usr/lib/python3.4/http/client.py”, line 924, in _send_output
self.send(msg)
File “/usr/lib/python3.4/http/client.py”, line 859, in send
self.connect()
File “/usr/lib/python3.4/http/client.py”, line 836, in connect
self.timeout, self.source_address)
File “/usr/lib/python3.4/socket.py”, line 509, in create_connection
raise err
File “/usr/lib/python3.4/socket.py”, line 500, in create_connection
sock.connect(sa)
OSError: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/onvif/client.py”, line 34, in wrapped
return func(*args, **kwargs)
File “/home/homeassistant/.homeassistant/deps/onvif/client.py”, line 201, in wrapped
return call(params, callback)
File “/home/homeassistant/.homeassistant/deps/onvif/client.py”, line 191, in call
ret = func(**params)
File “/home/homeassistant/.homeassistant/deps/suds/client.py”, line 559, in call
return client.invoke(args, kwargs)
File “/home/homeassistant/.homeassistant/deps/suds/client.py”, line 618, in invoke
result = self.send(soapenv)
File “/home/homeassistant/.homeassistant/deps/suds/client.py”, line 652, in send
reply = transport.send(request)
File “/home/homeassistant/.homeassistant/deps/suds/transport/http.py”, line 178, in send
return HttpTransport.send(self, request)
File “/home/homeassistant/.homeassistant/deps/suds/transport/http.py”, line 78, in send
fp = self.u2open(u2request)
File “/home/homeassistant/.homeassistant/deps/suds/transport/http.py”, line 119, in u2open
return url.open(u2request, timeout=tm)
File “/usr/lib/python3.4/urllib/request.py”, line 455, in open
response = self._open(req, data)
File “/usr/lib/python3.4/urllib/request.py”, line 473, in _open
‘_open’, req)
File “/usr/lib/python3.4/urllib/request.py”, line 433, in _call_chain
result = func(*args)
File “/usr/lib/python3.4/urllib/request.py”, line 1202, in http_open
return self.do_open(http.client.HTTPConnection, req)
File “/usr/lib/python3.4/urllib/request.py”, line 1176, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 113] No route to host>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 161, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File “/usr/lib/python3.4/asyncio/tasks.py”, line 372, in wait_for
return fut.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/asyncio/tasks.py”, line 237, in _step
result = next(coro)
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 141, in coro
res = func(*args, **kw)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/camera/onvif.py”, line 48, in async_setup_platform
async_add_devices([ONVIFCamera(hass, config)])
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/camera/onvif.py”, line 68, in init
self._input = media.GetStreamUri().Uri
File “/home/homeassistant/.homeassistant/deps/onvif/client.py”, line 36, in wrapped
raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: <urlopen error [Errno 113] No route to host>

what can i do? :slight_smile:

You have a networking error going on here. Check your IP and make sure it’s correct.
See if you can ping the IP from the command line.

Thanks for your reply!

it seems that my computer can ping this ip, but raspberry can’t :S But i know now where the problem is and i’ll investigate it.

Can you confirm yours is working now? I can’t get mine to work and am wondering if the parameter username should actually be user

No, mine is not yet working. Gotta solve networking problem. You can set username in your config file.

Ok , it seems i’ve solved problem with connection - now i am getting different error:

2017-06-19 21:31:18 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/onvif/client.py”, line 34, in wrapped
return func(*args, **kwargs)
File “/home/homeassistant/.homeassistant/deps/onvif/client.py”, line 201, in wrapped
return call(params, callback)
File “/home/homeassistant/.homeassistant/deps/onvif/client.py”, line 191, in call
ret = func(**params)
File “/home/homeassistant/.homeassistant/deps/suds/client.py”, line 559, in call
return client.invoke(args, kwargs)
File “/home/homeassistant/.homeassistant/deps/suds/client.py”, line 618, in invoke
result = self.send(soapenv)
File “/home/homeassistant/.homeassistant/deps/suds/client.py”, line 658, in send
result = self.succeeded(binding, reply.message)
File “/home/homeassistant/.homeassistant/deps/suds/client.py”, line 696, in succeeded
reply, result = binding.get_reply(self.method, reply)
File “/home/homeassistant/.homeassistant/deps/suds/bindings/binding.py”, line 150, in get_reply
soapenv.promotePrefixes()
AttributeError: ‘NoneType’ object has no attribute ‘promotePrefixes’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 161, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File “/usr/lib/python3.4/asyncio/tasks.py”, line 372, in wait_for
return fut.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/asyncio/tasks.py”, line 237, in _step
result = next(coro)
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 141, in coro
res = func(*args, **kw)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/camera/onvif.py”, line 48, in async_setup_platform
async_add_devices([ONVIFCamera(hass, config)])
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/camera/onvif.py”, line 68, in init
self._input = media.GetStreamUri().Uri
File “/home/homeassistant/.homeassistant/deps/onvif/client.py”, line 36, in wrapped
raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: ‘NoneType’ object has no attribute ‘promotePrefixes’

May I ask how can i solve this?

The camera is rejecting your login.

and whaat can i do? i mean, is this camera setting or what?

Yes it’d be a camera setting.

Hello!
config:
camera:

  • platform: onvif
    host: 192.168.2.38
    name: holl
    username: admin
    port: 8899

HA 0.47.1

2017-06-27 11:34:56 DEBUG (MainThread) [suds.metrics] message for ‘GetStreamUri’ created: 12 (ms)
2017-06-27 11:34:56 DEBUG (MainThread) [suds.transport.http] sending:
URL:http://192.168.2.38:8899/onvif/device_service
HEADERS: {‘Content-type’: ‘application/soap+xml’, ‘Soapaction’: ‘“http://www.onvif.org/ver10/media/wsdl/GetStreamUri”’, ‘Content-Type’: ‘application/soap+xml’, ‘SOAPAction’: ‘“http://www.onvif.org/ver10/media/wsdl/GetStreamUri”’}
MESSAGE:
b’<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:wsu=“http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd” xmlns:wsse=“http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd” xmlns:ns0=“http://www.onvif.org/ver10/media/wsdl” xmlns:ns1=“http://www.w3.org/2003/05/soap-envelope” xmlns:SOAP-ENV=“http://www.w3.org/2003/05/soap-envelope”>SOAP-ENV:Header<wsse:Security mustUnderstand=“true”>wsse:UsernameTokenwsse:Usernameadmin</wsse:Username><wsse:Password Type=“http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest”>b’61afpyQL0/dD7rO/NhsqsGi6AVA=’</wsse:Password><wsse:Nonce EncodingType=“http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary”>b’N2E3OTgxMmQxYTA2NTBhMjMxODAyNTA0ODQzNzg1NzY=’</wsse:Nonce>wsu:Created2017-06-27T11:34:56.048941+00:00</wsu:Created></wsse:UsernameToken></wsse:Security></SOAP-ENV:Header>ns1:Bodyns0:GetStreamUrins0:StreamSetup/ns0:ProfileToken/</ns0:GetStreamUri></ns1:Body></SOAP-ENV:Envelope>’
2017-06-27 11:34:56 WARNING (MainThread) [homeassistant.components.camera] Setup of platform onvif is taking over 10 seconds.
2017-06-27 11:34:56 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Traceback (most recent call last):
File “/root/.homeassistant/deps/suds/transport/http.py”, line 78, in send
fp = self.u2open(u2request)
File “/root/.homeassistant/deps/suds/transport/http.py”, line 119, in u2open
return url.open(u2request, timeout=tm)
File “/usr/lib/python3.5/urllib/request.py”, line 472, in open
response = meth(req, response)
File “/usr/lib/python3.5/urllib/request.py”, line 582, in http_response
‘http’, request, response, code, msg, hdrs)
File “/usr/lib/python3.5/urllib/request.py”, line 510, in error
return self._call_chain(*args)
File “/usr/lib/python3.5/urllib/request.py”, line 444, in _call_chain
result = func(*args)
File “/usr/lib/python3.5/urllib/request.py”, line 590, 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 “/root/.homeassistant/deps/suds/client.py”, line 652, in send
reply = transport.send(request)
File “/root/.homeassistant/deps/suds/transport/http.py”, line 178, in send
return HttpTransport.send(self, request)
File “/root/.homeassistant/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 “/root/.homeassistant/deps/onvif/client.py”, line 34, in wrapped
return func(*args, **kwargs)
File “/root/.homeassistant/deps/onvif/client.py”, line 201, in wrapped
return call(params, callback)
File “/root/.homeassistant/deps/onvif/client.py”, line 191, in call
ret = func(**params)
File “/root/.homeassistant/deps/suds/client.py”, line 559, in call
return client.invoke(args, kwargs)
File “/root/.homeassistant/deps/suds/client.py”, line 618, in invoke
result = self.send(soapenv)
File “/root/.homeassistant/deps/suds/client.py”, line 664, in send
result = self.failed(binding, e)
File “/root/.homeassistant/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/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 161, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File “/usr/lib/python3.5/asyncio/tasks.py”, line 392, in wait_for
return fut.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 274, in result
raise self._exception
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/usr/lib/python3.5/asyncio/coroutines.py”, line 206, in coro
res = func(*args, **kw)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/camera/onvif.py”, line 48, in async_setup_platform
async_add_devices([ONVIFCamera(hass, config)])
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/camera/onvif.py”, line 68, in init
self._input = media.GetStreamUri().Uri
File “/root/.homeassistant/deps/onvif/client.py”, line 36, in wrapped
raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: (400, ‘Bad Request’)
2017-06-27 11:34:56 INFO (MainThread) [homeassistant.setup] Setup of domain camera took 31.5 seconds.
2017-06-27 11:34:56 INFO (MainThread) [homeassistant.setup] Setup of domain device_tracker took 29.9 seconds.
2017-06-27 11:34:56 INFO (MainThread) [homeassistant.setup] Setting up ios
2017-06-27 11:34:56 INFO (MainThread) [homeassistant.setup] Setup of domain ios took 0.0 seconds.
2017-06-27 11:34:56 INFO (MainThread) [homeassistant.components.notify] Setting up notify.ios
2017-06-27 11:34:56 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.ios
2017-06-27 11:35:00 ERROR (MainThread) [aiohttp.access] Error in logging
Traceback (most recent call last):
File “/root/.homeassistant/deps/aiohttp/helpers.py”, line 416, in log
for key, value in fmt_info:
File “/root/.homeassistant/deps/aiohttp/helpers.py”, line 399, in
return ((key, method(args)) for key, method in self._methods)
File “/root/.homeassistant/deps/aiohttp/helpers.py”, line 352, in _format_a
peername = args[3].get_extra_info(‘peername’)
File “/usr/lib/python3.5/asyncio/sslproto.py”, line 306, in get_extra_info
return self._ssl_protocol._get_extra_info(name, default)
File “/usr/lib/python3.5/asyncio/sslproto.py”, line 537, in _get_extra_info
return self._transport.get_extra_info(name, default)
AttributeError: ‘NoneType’ object has no attribute ‘get_extra_info’

I get the same error now: BAD REQUEST.

can anybody confirm that this component work?

I have an AXIS M3203 and with ONVIF enabled and it doesn’t work for me.

I get following error :

2017-07-06 13:01:22 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/onvif/client.py", line 34, in wrapped
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/onvif/client.py", line 98, in __init__
    raise ONVIFError('%s doesn`t exist!' % url)
onvif.exceptions.ONVIFError: Unknown error: /config/deps/onvif/wsdl/media.wsdl doesn`t exist!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_component.py", line 161, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
    return fut.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/coroutines.py", line 210, in coro
    res = func(*args, **kw)
  File "/usr/src/app/homeassistant/components/camera/onvif.py", line 48, in async_setup_platform
    async_add_devices([ONVIFCamera(hass, config)])
  File "/usr/src/app/homeassistant/components/camera/onvif.py", line 66, in __init__
    '{}/deps/onvif/wsdl/media.wsdl'.format(hass.config.config_dir)
  File "/usr/local/lib/python3.6/site-packages/onvif/client.py", line 36, in wrapped
    raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: Unknown error: /config/deps/onvif/wsdl/media.wsdl doesn`t exist!

Maybe @matt2005 has an idea ?

Is it running in a virtual environment?
Mine is running on Hassbian and it also works on the docker build.
What version of python?

If you’re specifying the username, have you also specified the password?

The error mentions it cannot find the wsdl, I suspect something errored during the installation of python-onvif

I have exactly the same issue as donnib.
Hass tries to install http://github.com/tgaugry/suds-passworddigest-py3/archive/86fc50e39b4d2b8997481967d6a7fe1c57118999.zip#suds-passworddigest-py3==0.1.2a
but not in time for the onvif platform setup.

Thanks for narrowing the issue I’ll take a look and check the dependancies.
Does it install it at all?

I cleaned out all locations containing python packages but it still won’t install properly. Or at least it tries to install suds-passworddigest-py3 at every reboot.

2017-07-18 17:51:47 INFO (Thread-8) [homeassistant.util.package] Attempting install of onvif-py3==0.1.3
2017-07-18 17:51:50 INFO (Thread-7) [homeassistant.util.package] Attempting install of http://github.com/tgaugry/suds-passworddigest-py3/archive/86fc50e39b4d2b8997481967d6a7fe1c57118999.zip#suds-passworddigest-py3==0.1.2a
2017-07-18 17:51:56 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Traceback (most recent call last):
  File "/home/tatsch/.homeassistant/deps/lib/python3.5/site-packages/onvif/client.py", line 34, in wrapped
    return func(*args, **kwargs)
  File "/home/tatsch/.homeassistant/deps/lib/python3.5/site-packages/onvif/client.py", line 98, in __init__
    raise ONVIFError('%s doesn`t exist!' % url)
onvif.exceptions.ONVIFError: Unknown error: /home/tatsch/.homeassistant/deps/onvif/wsdl/media.wsdl doesn`t exist!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tatsch/home-assistant/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/usr/lib/python3.5/asyncio/coroutines.py", line 210, in coro
    res = func(*args, **kw)
  File "/home/tatsch/home-assistant/homeassistant/components/camera/onvif.py", line 48, in async_setup_platform
    async_add_devices([ONVIFCamera(hass, config)])
  File "/home/tatsch/home-assistant/homeassistant/components/camera/onvif.py", line 66, in __init__
    '{}/deps/onvif/wsdl/media.wsdl'.format(hass.config.config_dir)
  File "/home/tatsch/.homeassistant/deps/lib/python3.5/site-packages/onvif/client.py", line 36, in wrapped
    raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: Unknown error: /home/tatsch/.homeassistant/deps/onvif/wsdl/media.wsdl doesn`t exist

The file really doesnt exist at that location but at /home/tatsch/.homeassistant/deps/lib/python3.5/site-packages/onvif/wsdl/media.wsdl

Are you running in a venv? How was home assistant installed?

I’ll rebuild my Dev box and see if I see similar issues.
Does it work if you manually install suds-passworddigest-py3?
pip3 install http://github.com/tgaugry/suds-passworddigest-py3/archive/86fc50e39b4d2b8997481967d6a7fe1c57118999.zip#suds-passworddigest-py3==0.1.2a

I have the same issue using the docker image

I’ve made a quick change, it appears that if onvif not installed in a venv then the component cannot find the wsdl path.
I’ve tested it in docker, hassbian and vagrant.

I’ve made a quick file to test.
Please create a custom_components folder in the home-assistant config folder and then a camera folder under the custom_components folder.
Then add the following file in to the camera folder as onvif.py
github gist onvif.py

Then restart Home-assistant

I’ve submitted a pull request to get it fixed in the next release
https://github.com/home-assistant/home-assistant/pull/8592

Hi,
this is my log file…
I have a Sricam with ONVIF enabled, all works with other platform but nut with HA (running on a PI).

Uffff…

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/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.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 141, in coro
    res = func(*args, **kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/camera/onvif.py", line 48, in async_setup_platform
    async_add_devices([ONVIFCamera(hass, config)])
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/camera/onvif.py", line 68, in __init__
    self._input = media.GetStreamUri().Uri
  File "/home/homeassistant/.homeassistant/deps/onvif/client.py", line 36, in wrapped
    raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: <urlopen error [Errno -2] Name or service not known>
2017-07-22 11:32:42 WARNING (MainThread) [homeassistant.components.media_player] Setup of platform cast is taking over 10 seconds.
2017-07-22 11:32:42 WARNING (MainThread) [homeassistant.components.media_player] Setup of platform cast is taking over 10 seconds.
2017-07-22 11:32:43 WARNING (MainThread) [homeassistant.components.media_player] Setup of platform cast is taking over 10 seconds.
2017-07-22 11:32:43 WARNING (MainThread) [homeassistant.components.media_player] Setup of platform cast is taking over 10 seconds.