Arlo: replacement pyarlo module

Hmm it seems after a period of time it locks and doesnt update any more - will need to enable debugging but I definitely miss motion reports as I have home armed with motion reporting/recording and obviously I have plenty of recordings in the cloud …

@collse Try the following in your configuration.yaml. It’ll be chatty but very helpful.

logger:
  default: info
  logs:
    pyaarlo: debug

This one will dump the server event packets into /config/.aarlo/packets.dump

aarlo:
  username: !secret arlo_username
  password: !secret arlo_password
  packet_dump: True

I’ve not seen this issue but I think I need to add a recovery detection - if we haven’t seen anything from the server in X minutes then tear down the connection and start again. I also have a patch to add a time out to requests that I’ll bring in.

looking at the last_ time I think it may have hit within the hour - didnt monitor … will see - everything is enabled and logging …

Classic - you enable debugging nothing happens - I’ll keep it running for the moment to got some pointers if it happens …

That’s always the way! I worked for one company that was thinking of sending a programmer to sit next to a machine on a customer site because it never crashed when we went on site to debug it.

But the event loop and request code needs a few tweaks. It’s needs a timeout adding to the request call and a way to close the event loop on demand so I can re-establish the connection. That’s my weekend job.

I do have a favour to ask. Are you getting a packet dump? Any chance you can look for airQuality in the dump. What I’m after is that value in a packet - either in a small packet similar to the one following or as part of a large resources packet (it’ll have 'resource': 'cameras' in it). Right now we have to get the airQuality by asking for the sensor history of a device and parsing the details from some binary data. It would be much nicer to parse it out of a resource or update packet.

{ 'action': 'is',
  'from': 'XXXXXXXXXXXX',
  'properties': {'motionDetected': True},
  'resource': 'cameras/XXXXXXXXXXXX',
  'transId': 'XXXXXXXXXXXX!c6ccecff!1550285277780'}

I do check your private messages mate

In the latest version, which I just downloaded, the playback of the last recorded video doesn’t work anymore. I get a bunch of error messages:

2019-02-25 23:44:09 ERROR (MainThread) [haffmpeg.core] FFmpeg fails
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/haffmpeg/core.py”, line 114, in open
stderr=stderr
File “/usr/local/lib/python3.6/asyncio/subprocess.py”, line 225, in create_subprocess_exec
stderr=stderr, **kwds)
File “uvloop/loop.pyx”, line 2601, in subprocess_exec
File “uvloop/loop.pyx”, line 2573, in __subprocess_run
File “uvloop/loop.pyx”, line 2570, in uvloop.loop.Loop.__subprocess_run
concurrent.futures._base.CancelledError
2019-02-25 23:44:09 WARNING (MainThread) [haffmpeg.core] FFmpeg isn’t running!
2019-02-25 23:44:09 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 418, in start
resp = await task
File “/usr/local/lib/python3.6/site-packages/aiohttp/web_app.py”, line 458, in _handle
resp = await handler(request)
File “/usr/local/lib/python3.6/site-packages/aiohttp/web_middlewares.py”, line 119, in impl
return await handler(request)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/http/static.py”, line 66, in staticresource_middleware
return await handler(request)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py”, line 34, in real_ip_middleware
return await handler(request)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/http/ban.py”, line 67, in ban_middleware
return await handler(request)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/http/auth.py”, line 99, in auth_middleware
return await handler(request)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/http/view.py”, line 118, in handle
result = await result
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/camera/init.py”, line 407, in get
return await self.handle(request, camera)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/camera/init.py”, line 443, in handle
return await camera.handle_async_mjpeg_stream(request)
File “/config/custom_components/aarlo/camera.py”, line 174, in handle_async_mjpeg_stream
‘multipart/x-mixed-replace;boundary=ffserver’)
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/aiohttp_client.py”, line 106, in async_aiohttp_proxy_stream
await response.prepare(request)
File “/usr/local/lib/python3.6/site-packages/aiohttp/web_response.py”, line 353, in prepare
return await self._start(request)
File “/usr/local/lib/python3.6/site-packages/aiohttp/web_response.py”, line 410, in _start
await writer.write_headers(status_line, headers)
File “/usr/local/lib/python3.6/site-packages/aiohttp/http_writer.py”, line 112, in write_headers
self._write(buf)
File “/usr/local/lib/python3.6/site-packages/aiohttp/http_writer.py”, line 67, in _write
raise ConnectionResetError(‘Cannot write to closing transport’)
ConnectionResetError: Cannot write to closing transport
2019-02-25 23:44:09 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py”, line 447, in start
await resp.prepare(request)
File “/usr/local/lib/python3.6/site-packages/aiohttp/web_response.py”, line 353, in prepare
return await self._start(request)
File “/usr/local/lib/python3.6/site-packages/aiohttp/web_response.py”, line 667, in _start
return await super()._start(request)
File “/usr/local/lib/python3.6/site-packages/aiohttp/web_response.py”, line 410, in _start
await writer.write_headers(status_line, headers)
File “/usr/local/lib/python3.6/site-packages/aiohttp/http_writer.py”, line 112, in write_headers
self._write(buf)
File “/usr/local/lib/python3.6/site-packages/aiohttp/http_writer.py”, line 67, in _write
raise ConnectionResetError(‘Cannot write to closing transport’)
ConnectionResetError: Cannot write to closing transport

@sherrell
I have observed high levels of battery consumption since enabling aarlo with ‘armed home’

I have lost over 30% in 2 days not sure if this is related to how you query device/base states …

@ffm777 is that from the standard picture card?

I haven’t noticed that.

Hmm interesting- mine went from over 70 to 30ies on all my cams … dont know how much actually motion events may cause this

No. It‘s the aarlo-glance card.

@ffm777 try reloading the web page, the aarlo-glance shouldn’t go anywhere near the ffmpeg piece, it streams directly from Arlo into a HTML <video> component.

@collse It could be the Baby Arlo polling, I slowed it down in the latest build. Other than that the code only talks the Arlo servers and pings out to basestations. We stream through the Arlo servers too.

To emphasize: you really need to reload the web page - CTRL+R/F5-whatever-it-is-on-your-browser - there is a new web socket for getting library videos and the aarlo-glance card needs upgrading to use it.

Hi Everyone :slight_smile:

Started using the module a few weeks ago, apart from the odd ‘freeze’ (snapshots stop working occasionally), things have been working much better than the current HA component…

I am however seeing high CPU usage (host is running in a VM with plenty of resources). Before the module I saw 4 or 5%, now I’m seeing in excess of 25% for periods of time, is this a known issue?

P.S. Downloading and testing the latest Github version now, will see if anything changes…

@sherrell the Baby is actually powered so thats not an issue … I wonder if its the constant triggering and recording causing the battery to flatten this quickly …

I had to delete the cache in Firefox to make it work. Just reloading the page didn’t work. In the newest version, it is even replaying the videos on my iOS devices. Great work! My only wish would be to have an option to turn on specific cameras (meaning to enable the recording on detected motion) without having to switch modes on the base station. But the component is already working very nicely as it is now! Thanks again!

@Swiftnesses you might see it hit 25% but it shouldn’t stay there too long. I just tried on my system and 25% is always accompanied by activity from a camera and updating of an image and then it soon drops off. But - and this might tie in with some of @collse observations - the code is a little overly cautious and does too much work when pinging the Arlo servers and downloading the video library and, knowing more about what’s going on now, I’m going to optimize that this week.

@ffm777 the cache is a pain - to try out the latest scripts on my Android device I had to initiate a remote Chrome debug session and force a reload. I have an idea how to do the individual cameras but it’ll be a week or two before I can get to look at it. (@onkelfarmor did you try clearing the cache? This was the same backtrace you were seeing.)

And a general question (because frontends are still a bit of mystery to me): I don’t have a Mac, are people with Macs getting the videos OK? I’ve tested on Windows, Linux, Firefox, Chrome and iPads and Android devices just not a Mac. And are people seeing the recordings screen OK (you click on the captured icon)?

So, you mean I don’t need to enable ffmpeg? Its not working on hass.io anyhow…

Short answer: no.

Long answer: if you only use the custom aarlo-glance card then no. If you use the standard picture cards then you still need ffmpeg because it is used to convert the library recordings from mp4 to a motion JPEG stream.

Even longer answer: when I get streaming working you might need to enable ffmpeg, the streams come in as rtsps and can’t be displayed directly in a web browser so have to be converted by ffmpeg. But as you noted, ffmpeg is broke in hass.io and docker anyway…

That’s no problem at all. Take the time you need. I really appreciate your efforts!

I’m using a Mac. The videos are working fine in Firefox for Mac.