Axis camera component

PR submitted https://github.com/home-assistant/home-assistant.github.io/pull/3435

I’m in the middle of a rewrite of the component from using Gstreamer and threads to only using native Python and async. My goals are to be following HASS guidelines as close as possible as well as making it fully plug and play since using Gstreamer complicates the setup of the environment too much.

Information now available on component website. Thanks :+1:t2:

I’ve published a new PR that will remove all dependencies to anything outside of python meaning this should work directly without any need to do extra installs or symlinks. https://github.com/home-assistant/home-assistant/pull/9791

If someone more than me could try it out and verify that it doesn’t break stuff I’d be really glad :smiley:

/R

I’m running Hass.io 0.55.0 and after installing this PR all camera and motion detection functionality was restored to the way it used to work under hassbian with the GI dependancy loaded…
Thanks

Glad to hear! A lot less installation complexity now :slight_smile:

Just keep a watch for a few days that it performs stable, it is really a bit of a gamble if no-one else evaluates stuff before merging.

/R

Hi Robban,

Today, after the upgrade to 0.57, I’ve got the following errors in my log. Is it related to the Axis component?

2017-11-04 18:43:03 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback _SelectorSocketTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/events.py", line 126, in _run
    self._callback(*self._args)
  File "/usr/lib/python3.5/asyncio/selector_events.py", line 730, in _read_ready
    self._protocol.data_received(data)
  File "/srv/homeassistant/lib/python3.5/site-packages/axis/rtsp.py", line 76, in data_received
    self.transport.write(self.method.message.encode())
  File "/srv/homeassistant/lib/python3.5/site-packages/axis/rtsp.py", line 190, in message
    message = self.message_methods[self.session.method]()
  File "/srv/homeassistant/lib/python3.5/site-packages/axis/rtsp.py", line 224, in SETUP
    message = "SETUP " + self.session.control_url + " RTSP/1.0\r\n"
TypeError: Can't convert 'NoneType' object to str implicitly

By the way. My Axis camera is functioning well in HA.

For some reason the rtsp handshake doesn’t work properly. Can you enable debug and post the printouts? Follow the instructions here https://home-assistant.io/components/logger/

I have now upgraded my system, and RTSP setup does work for me. Though it is with the same devices used in the development system. But since all Axis devices behave more or less the same you might have a system issue or found a bug in the component. Lets try to solve it!

Ok. This is my default logger setup:

logger:
  default: error
  logs:
    homeassistant.components.camera.generic: critical
    aiohttp.access: critical
    aiohttp.server: critical
    requests.packages.urllib3.connectionpool: critical

What do you want me to change, to collect some more information?

Btw: I have an Axis M1031-W camera. Quite an oldy.

Well that cameras firmware is too old unfortunately. You really need a device with 5.50 to get the sensors working.

Yeah, I know. But I only use the camera.

axis:
  m1031w:
    host: !secret mijn_axis_ip
    username: !secret mijn_axis_username
    password: !secret mijn_axis_password
    include:
    - camera
    trigger_time: 0
    location: parkeerplaats

Yes, you found a bug :slight_smile:

Would you mind creating an issue on GitHub then I’ll do a fix.

/R

I get exactly the same error - AXIS P1344

axis:
  m1065lw:
    host: !secret axis_ip
    username: !secret axis_username
    password: !secret axis_password
    include:
      - camera
    trigger_time: 0

Yes it’s a bug which will occur when you try to set up the event stream with no events specified

https://github.com/home-assistant/home-assistant/issues/10402

1 Like

Hi,

I’m running HASS.io on a RPi2 and trying to get a Axis M1034-W to work with it. A couple of versions ago, probably a week or two, I got it to work but now I don’t. Have tried to configure it through the front-end and also through input in configuration.yaml.

My configuration file:

axis:
m1034w:
host: 192.168.1.77
username: homeassistant
password: !secret axis_password
include:
- camera
- motion
- pir
- sound
- tampering
- input
location: “Köket”

Error message:

2017-11-13 22:11:38 ERROR (MainThread) [asyncio] Unhandled error in exception handler
context: {‘exception’: KeyError(‘Source_value’,)}
Traceback (most recent call last):
File “uvloop/handles/udp.pyx”, line 339, in uvloop.loop.__uv_udp_on_receive (uvloop/loop.c:105874)
File “uvloop/handles/udp.pyx”, line 241, in uvloop.loop.UDPTransport._on_receive (uvloop/loop.c:104790)
File “/usr/lib/python3.6/site-packages/axis/rtsp.py”, line 168, in datagram_received
self.callback(‘data’)
File “/usr/lib/python3.6/site-packages/axis/streammanager.py”, line 62, in session_callback
self.event.manage_event(self.data)
File “/usr/lib/python3.6/site-packages/axis/event.py”, line 81, in manage_event
new_event = AxisEvent(data)
File “/usr/lib/python3.6/site-packages/axis/event.py”, line 110, in init
self.id = data[‘Source_value’]
KeyError: ‘Source_value’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “uvloop/loop.pyx”, line 1879, in uvloop.loop.Loop.call_exception_handler (uvloop/loop.c:35032)
File “/usr/lib/python3.6/site-packages/homeassistant/core.py”, line 94, in async_loop_exception_handler
_LOGGER.error(“Error doing job: %s”, context[‘message’], **kwargs)
KeyError: ‘message’

So it worked as it should in an earlier hass-release? Weird, haven’t changed the parsing afaik.

The received event doesn’t contain all expected values necessary to register a new event according to the backtrace. Can you enable debug?

Any ideas why the frame rate would be much lower when uses the Axis camera component versus just using the MJPEG component?

With the Axis component, the frame rate feels like its around 1 or 2 FPS. But with the MJPEG component, the frame rate is very smooth.

I’m using an M3113 on firmware version 5.50.5.1

Are you using the same resolution as Axis component? It’s the same code beneath

Hi Robban. Sorry, it’s me again. After upgrading to 0.58 with your patch, my log file is flooded with axis errors every minute.

Failed to parse headers (url=http://192.168.2.7:80/axis-cgi/mjpg/video.cgi): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
08:47 lib/python3.5/site-packages/urllib3/util/response.py (WARNING)
Failed to parse headers (url=http://192.168.2.7:80/axis-cgi/mjpg/video.cgi): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
08:46 lib/python3.5/site-packages/urllib3/util/response.py (WARNING)
Failed to parse headers (url=http://192.168.2.7:80/axis-cgi/mjpg/video.cgi): [StartBoundaryNotFoundDefect(), 

Detail error:

Failed to parse headers (url=http://192.168.2.7:80/axis-cgi/mjpg/video.cgi): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/urllib3/connectionpool.py", line 399, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/srv/homeassistant/lib/python3.5/site-packages/urllib3/util/response.py", line 66, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''

Any idea what this could be? The camera is functioning alright. And thank you for all your efforts!

Kind regards,

  • Wilfred