Thanks for your response - I am in a virtual env and was working fine with version 0.90, but something has broke with live streaming since beta 0.91.
2019-04-02 21:39:34 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 68, in ban_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 206, in auth_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/view.py", line 112, in handle
result = await result
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/camera/__init__.py", line 475, in get
return await self.handle(request, camera)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/camera/__init__.py", line 511, in handle
return await camera.handle_async_mjpeg_stream(request)
File "/home/homeassistant/.homeassistant/custom_components/aarlo/camera.py", line 164, in handle_async_mjpeg_stream
from haffmpeg import CameraMjpeg
ImportError: cannot import name 'CameraMjpeg'
@woodmoose
I’m still going to implement the get_snapshot websocket call.
Can you try the latest build from the snapshot branch? This one will only move out of the snapshot state when the snapshot has been taken and the image downloaded to the home-assistant device - ie, camera_thumbnail will read it.
So I just tried your update. I’m now using from ‘taking snapshot’ to ‘idle’ as a trigger for sending the snapshot over with notify.
There is a major bug though - the state of the cameras freezes and stay on ‘taking snapshot’ state. While testing, I even got one of my binary_sensor.aarlo_motion_cameraName that froze and stay on ‘detected’ state… ?
Not sure if I did something wrong though… I don’t think so …
Here is the code I’m currently using:
- alias: "[Alarm] Take Snapshot When Motion Detected - Frontdoor"
initial_state: 'on'
trigger:
platform: state
entity_id: binary_sensor.aarlo_motion_frontdoor
from: 'off'
to: 'on'
action:
- service: camera.aarlo_request_snapshot_to_file
data_template:
entity_id: camera.aarlo_frontdoor
filename: "/config/www/cameras/frontdoor/frontdoor_snapshot.jpg"
- alias: "[Alarm] Notify With Snapshot When Motion Detected - Frontdoor"
initial_state: 'on'
trigger:
platform: state
entity_id: camera.aarlo_frontdoor
from: 'taking snapshot'
to: 'idle'
action:
- service: notify.iphone
data:
message: "Motion detected at the front door"
data:
attachment:
url: "http://hassio.local:8123/local/cameras/frontdoor/frontdoor_snapshot.jpg"
content-type: jpeg
hide-thumbnail: false
Using this code allows me now to get the correct picture sent to my phone, but it takes pretty long time - almost 5/7seconds ? My local network is not slow… don’t know how to improve the speed ?
edit: actually, I need to improve my code in order to get these automation triggered only when motion is detected, otherwise, each time the camera are taking snapshot (eg. for updating the thumbnail <-- the state stays frozen here too), I will receive a false one…
edit/2: ok I need to go back to the master branch because it stays stucked on taking snapshot each 5 minutes… let me know if you can reproduce and fix - Thanks again
And I reproduced the problem almost immediately. I’ll have a fix in a few minutes. The snapshot request went in but I didn’t handle the shift into idle before it came back.
It’s working for me in docker and virtualenv. The stream code will use the Mjpeg code if it can’t find a stream_source() method in the custom camera component. Can you check the code is the latest?
Yes I am wondering why it takes so long - I will make some new test and let you know.
I didn’t think about the fact it could move back to ‘recording’ … Do you have any recommendation of what could be more efficient ?
@grantc@Swiftnesses
Is there any ‘stream’ related messages in the start up?
Which branch are you using?
@woodmoose
The speed is mostly controlled by Arlo. I ask it to take a snapshot, it tells me when that is finished, I download the image and then I change the state from ‘taking a snapshot’. If you turn on logging you can follow the messages and state changes.
If you are already recording when taking a snapshot then it is a lot faster then if the camera is idle.
The latest version you committed seems better in term of speed…
In your previous message, you were saying that it’s not guaranteed to move from ‘taking snapshot’ to ‘idle’ - so which trigger should I choose to be best ?
edit: I guess using only from parameter will be fine…
Oh nice, I will give a try and see which one is faster to notify.
Actually, the automation I’m using now seem working well but I’m curious of your solution !
Thanks