ONVIF camera

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.

I’ve a problem with my onvif camera. My log shows:

    2017-09-20 22:37:10 INFO (MainThread) [homeassistant.components.camera] Setting up camera.onvif
    2017-09-20 22:37:12 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
    Traceback (most recent call last):
      File "/srv/homeassistant/lib/python3.4/site-packages/zeep/client.py", line 212, in create_service
        binding = self.wsdl.bindings[binding_name]
    KeyError: ''
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/onvif/client.py", line 24, in wrapped
    return func(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/onvif/client.py", line 102, in __init__
    self.ws_client = self.zeep_client.create_service(binding_name, self.xaddr)
  File "/srv/homeassistant/lib/python3.4/site-packages/zeep/client.py", line 216, in create_service
    "are: %s" % (', '.join(self.wsdl.bindings.keys())))
ValueError: No binding found with the given QName. Available bindings are: {http://www.onvif.org/ver10/media/wsdl}MediaBinding

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 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/lib/python3.4/site-packages/homeassistant/components/camera/onvif.py", line 49, 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__
    '{}/wsdl/media.wsdl'.format(os.path.dirname(onvif.__file__))
  File "/srv/homeassistant/lib/python3.4/site-packages/onvif/client.py", line 28, in wrapped
    raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: No binding found with the given QName. Available bindings are: {http://www.onvif.org/ver10/media/wsdl}MediaBinding

My configuration is:

ffmpeg:
  ffmpeg_bin: /usr/local/bin/ffmpeg

camera:
  - platform: onvif
    host: 192.168.1.7
    name: webcam1
    port: 5000

And Home Assistant version 0.53.1 in virtual environment.
Thank you so much for the help you’ll give me.

Not sure if this helps but, I’m not sure the response is coming back right from the camera.

After I couldn’t get python-onvif to parse the XML correctly, I tried following this post here:
https://gist.github.com/vincenthsu/6eb1f9b2c07d123c526b#file-onvif_request-py-L5

devanl@HassPi:~/wsdl $ cat request.xml
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
    <s:Header>
        <Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <UsernameToken>
                <Username>admin</Username>
                <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">nOinjmDazig9KSjU474fmJFiZZE=</Password>
                <Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">arhRIvzxGs5hmCPxWwe218qmopQ=</Nonce>
                <Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-09-21T18:59:04.000Z</Created>
            </UsernameToken>
        </Security>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <GetCapabilities xmlns="http://www.onvif.org/ver10/device/wsdl">
            <Category>All</Category>
        </GetCapabilities>
    </s:Body>
</s:Envelope>
devanl@HassPi:~/wsdl $ curl --silent -X POST --header 'Content-Type: text/xml; charset=utf-8' -d @request.xml 'http://192.168.1.219:8080/onvif/device_service' | xmllint --format -
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsbf2="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsr2="http://docs.oasis-open.org/wsrf/r-2" xmlns:daae="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding" xmlns:dare="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:decpp="http://www.onvif.org/ver10/events/wsdl/CreatePullPointBinding" xmlns:dee="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:denc="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding" xmlns:denf="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:depp="http://www.onvif.org/ver10/events/wsdl/PullPointBinding" xmlns:depps="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:depsm="http://www.onvif.org/ver10/events/wsdl/PausableSubscriptionManagerBinding" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:desm="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:dndl="http://www.onvif.org/ver10/network/wsdl/DiscoveryLookupBinding" xmlns:dnrd="http://www.onvif.org/ver10/network/wsdl/RemoteDiscoveryBinding" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tad="http://www.onvif.org/ver10/analyticsdevice/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tls="http://www.onvif.org/ver10/display/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:trv="http://www.onvif.org/ver10/receiver/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tnsn="http://www.eventextension.com/2011/event/topics">
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
    <tds:GetCapabilitiesResponse>
      <tds:Capabilities>
        <tt:Analytics>
          <tt:XAddr>http://192.168.1.219:8080/onvif/analytics</tt:XAddr>
          <tt:RuleSupport>true</tt:RuleSupport>
          <tt:AnalyticsModuleSupport>true</tt:AnalyticsModuleSupport>
        </tt:Analytics>
        <tt:Device>
          <tt:XAddr>http://192.168.1.219:8080/onvif/devices</tt:XAddr>
          <tt:Network>
            <tt:IPFilter>false</tt:IPFilter>
            <tt:ZeroConfiguration>false</tt:ZeroConfiguration>
            <tt:IPVersion6>false</tt:IPVersion6>
            <tt:DynDNS>false</tt:DynDNS>
            <tt:Extension>
              <tt:Dot11Configuration>false</tt:Dot11Configuration>
            </tt:Extension>
          </tt:Network>
          <tt:System>
            <tt:DiscoveryResolve>false</tt:DiscoveryResolve>
            <tt:DiscoveryBye>false</tt:DiscoveryBye>
            <tt:RemoteDiscovery>false</tt:RemoteDiscovery>
            <tt:SystemBackup>false</tt:SystemBackup>
            <tt:SystemLogging>false</tt:SystemLogging>
            <tt:FirmwareUpgrade>false</tt:FirmwareUpgrade>
            <tt:SupportedVersions>
              <tt:Major>2</tt:Major>
              <tt:Minor>4</tt:Minor>
            </tt:SupportedVersions>
            <tt:Extension>
              <tt:HttpFirmwareUpgrade>false</tt:HttpFirmwareUpgrade>
              <tt:HttpSystemBackup>false</tt:HttpSystemBackup>
              <tt:HttpSystemLogging>false</tt:HttpSystemLogging>
              <tt:HttpSupportInformation>false</tt:HttpSupportInformation>
            </tt:Extension>
          </tt:System>
          <tt:IO>
            <tt:InputConnectors>0</tt:InputConnectors>
            <tt:RelayOutputs>0</tt:RelayOutputs>
          </tt:IO>
          <tt:Security>
            <tt:TLS1.1>false</tt:TLS1.1>
            <tt:TLS1.2>false</tt:TLS1.2>
            <tt:OnboardKeyGeneration>false</tt:OnboardKeyGeneration>
            <tt:AccessPolicyConfig>false</tt:AccessPolicyConfig>
            <tt:X.509Token>false</tt:X.509Token>
            <tt:SAMLToken>false</tt:SAMLToken>
            <tt:KerberosToken>false</tt:KerberosToken>
            <tt:RELToken>false</tt:RELToken>
          </tt:Security>
        </tt:Device>
        <tt:Events>
          <tt:XAddr>http://192.168.1.219:8080/onvif/events</tt:XAddr>
          <tt:WSSubscriptionPolicySupport>false</tt:WSSubscriptionPolicySupport>
          <tt:WSPullPointSupport>false</tt:WSPullPointSupport>
          <tt:WSPausableSubscriptionManagerInterfaceSupport>false</tt:WSPausableSubscriptionManagerInterfaceSupport>
        </tt:Events>
        <tt:Imaging>
          <tt:XAddr>http://192.168.1.219:8080/onvif/imaging</tt:XAddr>
        </tt:Imaging>
        <tt:Media>
          <tt:XAddr>http://192.168.1.219:8080/onvif/media</tt:XAddr>
          <tt:StreamingCapabilities>
            <tt:RTPMulticast>false</tt:RTPMulticast>
            <tt:RTP_TCP>true</tt:RTP_TCP>
            <tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP>
          </tt:StreamingCapabilities>
        </tt:Media>
        <tt:PTZ>
          <tt:XAddr>http://192.168.1.219:8080/onvif/ptz</tt:XAddr>
        </tt:PTZ>
        <tt:Extension>
          <tt:Extensions>
            <tt:TelexCapabilities>
              <tt:XAddr>http://192.168.1.219:8080/onvif/telecom_service</tt:XAddr>
              <tt:MotionDetectorSupport>true</tt:MotionDetectorSupport>
              <tt:TamperDetectorSupport>true</tt:TamperDetectorSupport>
            </tt:TelexCapabilities>
          </tt:Extensions>
        </tt:Extension>
      </tds:Capabilities>
    </tds:GetCapabilitiesResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Is there a way to enable logging such that I can see the request that is failing (from previous post)?

Hi,
I did not succeeded in including a Yosee YY Chinese camera in Home Assistant.
I am using Home Assistant 57.3 on a Raspberry Pi 3 with hassio,
I can correctly connect to the camera via standard yyp2p app on a iPhone
I can connect through VLC application on Mac OS X/iOS opening stream rtsp://192.168.1.28:554/onvif1 without user and password

this is my configuration.yaml for the camera

camera:
  - platform: onvif
    host: 192.168.1.28
    port: 554
    name: Camera1

this is for the logger…

logger:
  default: critical
  logs:
    homeassistant.components.camera: debug
    custom_components.camera.onvif: debug    

this is what I get in log:

2017-11-17 09:02:24 INFO (MainThread) [homeassistant.components.camera] Setting up camera.onvif
2017-11-17 09:04:00 WARNING (MainThread) [homeassistant.components.camera] Setup of platform onvif is taking over 10 seconds.
2017-11-17 09:04:00 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
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 "/usr/lib/python3.6/site-packages/suds/client.py", line 559, in __call__
    return client.invoke(args, kwargs)
  File "/usr/lib/python3.6/site-packages/suds/client.py", line 618, in invoke
    result = self.send(soapenv)
  File "/usr/lib/python3.6/site-packages/suds/client.py", line 652, in send
    reply = transport.send(request)
  File "/usr/lib/python3.6/site-packages/suds/transport/http.py", line 178, in send
    return HttpTransport.send(self, request)
  File "/usr/lib/python3.6/site-packages/suds/transport/http.py", line 78, in send
    fp = self.u2open(u2request)
  File "/usr/lib/python3.6/site-packages/suds/transport/http.py", line 119, in u2open
    return url.open(u2request, timeout=tm)
  File "/usr/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  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 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.6/urllib/request.py", line 1321, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/usr/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out
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 170, 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 "/usr/lib/python3.6/site-packages/homeassistant/components/camera/onvif.py", line 49, in async_setup_platform
    async_add_devices([ONVIFCamera(hass, config)])
  File "/usr/lib/python3.6/site-packages/homeassistant/components/camera/onvif.py", line 70, 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: timed out

thank you for the help

From looking at the logs, you’re using the standard component. Can you try the one I posted as a gist onvif v2

Looking at your config in more detail. You’re specifying the wrong port it should be the onvif port not the rtsp port.
Matt

Tried but it stay hours without finishing. I should say that I did not install
#Prerequistes# sudo apt-get install python3-dev libxml2-dev libxslt-dev
because I do not know how to do in hassio. Maybe this is the problem

How to know what port to use ? taking the defualt one (5000 to my understanding) does not change the result

Try 5000 with the standard component. ONVIF port: 5000 yosee faq

i’ll see if i can get it working with hass.io

ok, defining the right port at least change the error message, it looks like it is the wdsl doesn’t exist problem… here in the following the log.
Still I have the problem of how to install onvif.py v2 in hassio.

2017-11-21 08:58:19 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Traceback (most recent call last):
  File "/config/deps/lib/python3.6/site-packages/onvif/client.py", line 24, in wrapped
    return func(*args, **kwargs)
  File "/config/deps/lib/python3.6/site-packages/onvif/client.py", line 90, in __init__
    raise ONVIFError('%s doesn`t exist!' % url)
onvif.exceptions.ONVIFError: Unknown error: /config/deps/lib/python3.6/site-packages/onvif/wsdl/media.wsdl doesn`t exist!

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 170, 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 "/usr/lib/python3.6/site-packages/homeassistant/components/camera/onvif.py", line 49, in async_setup_platform
    async_add_devices([ONVIFCamera(hass, config)])
  File "/usr/lib/python3.6/site-packages/homeassistant/components/camera/onvif.py", line 68, in __init__
    '{}/wsdl/media.wsdl'.format(os.path.dirname(onvif.__file__))
  File "/config/deps/lib/python3.6/site-packages/onvif/client.py", line 28, in wrapped
    raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: Unknown error: /config/deps/lib/python3.6/site-packages/onvif/wsdl/media.wsdl doesn`t exist!

here’s a quick edit, try this one out onvif v3

Hi Matt, done, this is the result.

Edoardo

2017-11-23 09:00:15 ERROR (MainThread) [custom_components.camera.onvif] Unable to communicate with ONVIF Camera: Unknown error: (‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))
2017-11-23 09:00:15 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py”, line 170, 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 49, in async_setup_platform
async_add_devices([ONVIFCamera(hass, config)])
File “/config/custom_components/camera/onvif.py”, line 79, in init
self._input = stream_uri.Uri.replace(
UnboundLocalError: local variable ‘stream_uri’ referenced before assignment

fixed the error, it works in my Hassio and hassbian.
onvif v3

This is what I get now with version 3

2017-11-24 18:29:52 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/aiohttp/web_protocol.py”, line 422, in start
resp = yield from self._request_handler(request)
File “/usr/lib/python3.6/site-packages/aiohttp/web.py”, line 306, in _handle
resp = yield from handler(request)
File “/usr/lib/python3.6/asyncio/coroutines.py”, line 213, in coro
res = yield from res
File “/usr/lib/python3.6/asyncio/coroutines.py”, line 213, in coro
res = yield from res
File “/usr/lib/python3.6/site-packages/homeassistant/components/http/ban.py”, line 58, in ban_middleware_handler
return (yield from handler(request))
File “/usr/lib/python3.6/site-packages/homeassistant/components/http/init.py”, line 423, in handle
result = yield from result
File “/usr/lib/python3.6/site-packages/homeassistant/components/camera/init.py”, line 387, in get
response = yield from self.handle(request, camera)
File “/usr/lib/python3.6/site-packages/homeassistant/components/camera/init.py”, line 425, in handle
yield from camera.handle_async_mjpeg_stream(request)
File “/config/custom_components/camera/onvif.py”, line 104, in handle_async_mjpeg_stream
self._input, extra_cmd=self._ffmpeg_arguments)
AttributeError: ‘ONVIFCamera’ object has no attribute ‘_input’
2017-11-24 18:29:55 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/aiohttp/web_protocol.py”, line 422, in start
resp = yield from self._request_handler(request)
File “/usr/lib/python3.6/site-packages/aiohttp/web.py”, line 306, in _handle
resp = yield from handler(request)
File “/usr/lib/python3.6/asyncio/coroutines.py”, line 213, in coro
res = yield from res
File “/usr/lib/python3.6/asyncio/coroutines.py”, line 213, in coro
res = yield from res
File “/usr/lib/python3.6/site-packages/homeassistant/components/http/ban.py”, line 58, in ban_middleware_handler
return (yield from handler(request))
File “/usr/lib/python3.6/site-packages/homeassistant/components/http/init.py”, line 423, in handle
result = yield from result
File “/usr/lib/python3.6/site-packages/homeassistant/components/camera/init.py”, line 387, in get
response = yield from self.handle(request, camera)
File “/usr/lib/python3.6/site-packages/homeassistant/components/camera/init.py”, line 407, in handle
image = yield from camera.async_camera_image()
File “/config/custom_components/camera/onvif.py”, line 92, in async_camera_image
self._input, output_format=IMAGE_JPEG,
AttributeError: ‘ONVIFCamera’ object has no attribute ‘_input’

I’m having the exact same issues that Gorinie has. With the slightly older version 3, I got the "stream_uri’ referenced before assignment. With the current V3 (from 11/23), I get the same ‘OnvifCamera’ object has no attribute ‘_input’. I appear to be in the same boat as gorinie is.

I grabbed these newer versions for testing after getting the common error 400 on the original code version despite using the correct port and user/pass as verified by multiple other tools. Let me know if I can help with any additional details. Would love to get this working.

Thanks.

I’ve added some more debug logging to the v3 gist, but you need to remember to enable the debug logging for the custom component

logger:
  logs:
    custom_components.camera.onvif: debug

it should display something like this in the homeassistant.log

2017-11-26 21:22:47 DEBUG (MainThread) [custom_components.camera.onvif] ONVIF Version: 
201711262117 - Attempting to communicate with ONVIF Camera: 192.168.1.186 on port 5000
2017-11-26 21:23:09 DEBUG (MainThread) [custom_components.camera.onvif] ONVIF Camera 
Using the following URL for Cam1: rtsp://admin:[email protected]:554/onvif1

Here’s the error log I get:

2017-11-26 16:18:17 WARNING (MainThread) [homeassistant.setup] Setup of camera is taking over 10 seconds.
2017-11-26 16:18:18 INFO (SyncWorker_18) [homeassistant.util.package] Attempting install of http://github.com/tgaugry/suds-passworddigest-py3/archive/86fc50e39b4d2b8997481967d6a7fe1c57118999.zip#suds-passworddigest-py3==0.1.2a
2017-11-26 16:18:29 INFO (MainThread) [homeassistant.components.camera] Setting up camera.onvif
2017-11-26 16:18:30 DEBUG (MainThread) [custom_components.camera.onvif] ONVIF Version: 201711262117 - Attempting to communicate with ONVIF Camera: 192.168.1.76 on port 8000
2017-11-26 16:18:32 ERROR (MainThread) [custom_components.camera.onvif] Unable to communicate with ONVIF Camera: Unknown error: AnySimpleType.pytonvalue() not implemented
2017-11-26 16:18:32 ERROR (MainThread) [homeassistant.components.camera] Error while setting up platform onvif
Traceback (most recent call last):
File “/config/deps/lib/python3.6/site-packages/onvif/client.py”, line 24, in wrapped
return func(*args, **kwargs)
File “/config/deps/lib/python3.6/site-packages/onvif/client.py”, line 180, in wrapped
return call(params, callback)
File “/config/deps/lib/python3.6/site-packages/onvif/client.py”, line 167, in call
ret = func(**params)
File “/usr/local/lib/python3.6/site-packages/zeep/client.py”, line 41, in call
self._op_name, args, kwargs)
File “/usr/local/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py”, line 121, in send
return self.process_reply(client, operation_obj, response)
File “/usr/local/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py”, line 185, in process_reply
result = operation.process_reply(doc)
File “/usr/local/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py”, line 366, in process_reply
return self.output.deserialize(envelope)
File “/usr/local/lib/python3.6/site-packages/zeep/wsdl/messages/soap.py”, line 90, in deserialize
body_result = self._deserialize_body(body)
File “/usr/local/lib/python3.6/site-packages/zeep/wsdl/messages/soap.py”, line 411, in _deserialize_body
result = self.body.parse(xmlelement, self.wsdl.types)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 114, in parse
schema_type=self.type)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/types/complex.py”, line 169, in parse_xmlelement
elements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/indicators.py”, line 600, in parse_xmlelements
xmlelements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 160, in parse_xmlelements
xmlelement, schema, allow_none=True, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 114, in parse
schema_type=self.type)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/types/complex.py”, line 169, in parse_xmlelement
elements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/indicators.py”, line 600, in parse_xmlelements
xmlelements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 160, in parse_xmlelements
xmlelement, schema, allow_none=True, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 114, in parse
schema_type=self.type)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/types/complex.py”, line 169, in parse_xmlelement
elements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/indicators.py”, line 600, in parse_xmlelements
xmlelements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 160, in parse_xmlelements
xmlelement, schema, allow_none=True, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 114, in parse
schema_type=self.type)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/types/complex.py”, line 169, in parse_xmlelement
elements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/indicators.py”, line 600, in parse_xmlelements
xmlelements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 160, in parse_xmlelements
xmlelement, schema, allow_none=True, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 114, in parse
schema_type=self.type)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/types/complex.py”, line 169, in parse_xmlelement
elements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/indicators.py”, line 600, in parse_xmlelements
xmlelements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 160, in parse_xmlelements
xmlelement, schema, allow_none=True, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 114, in parse
schema_type=self.type)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/types/complex.py”, line 169, in parse_xmlelement
elements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/indicators.py”, line 600, in parse_xmlelements
xmlelements, schema, name, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 160, in parse_xmlelements
xmlelement, schema, allow_none=True, context=context)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py”, line 114, in parse
schema_type=self.type)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/types/complex.py”, line 189, in parse_xmlelement
init_kwargs[name] = attribute.parse(value)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/attribute.py”, line 22, in parse
return self.type.pythonvalue(value)
File “/usr/local/lib/python3.6/site-packages/zeep/xsd/types/simple.py”, line 68, in pythonvalue
‘%s.pytonvalue() not implemented’ % self.class.name)
NotImplementedError: AnySimpleType.pytonvalue() not implemented

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/entity_component.py”, line 171, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/local/lib/python3.6/asyncio/futures.py”, line 245, in result
raise self._exception
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 180, in _step
result = coro.send(None)
File “/usr/local/lib/python3.6/asyncio/coroutines.py”, line 210, in coro
res = func(*args, **kw)
File “/config/custom_components/camera/onvif.py”, line 50, in async_setup_platform
async_add_devices([ONVIFCameraHASS(hass, config)])
File “/config/custom_components/camera/onvif.py”, line 72, in init
profiles = media_service.GetProfiles()
File “/config/deps/lib/python3.6/site-packages/onvif/client.py”, line 28, in wrapped
raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: AnySimpleType.pytonvalue() not implemented