twrecked / hass-aarlo

Asynchronous Arlo Component for Home Assistant
GNU Lesser General Public License v3.0
399 stars 79 forks source link

Service aarlo.camera_start_recording not working #822

Open sambeetm opened 1 year ago

sambeetm commented 1 year ago

It used to work and i was able to see the clips in the native Arlo app and HA as well. Now it does not capture the clips. Getting the below one liner warning in the logfile everytime the service is called.

2023-10-26 23:01:14.682 WARNING (ArloBackgroundWorker) [py.warnings] /config/custom_components/aarlo/camera.py:477: RuntimeWarning: coroutine 'Stream.stop' was never awaited self.stream.stop()

From Developer Tools.... service: aarlo.camera_start_recording data: entity_id: camera.aarlo_backyard_camera duration: 30

Maccas1313 commented 1 year ago

Happening for me also (HACS v0.7.4b20). After the duration period I get the following warnings:

Logger: pyaarlo Source: custom_components/aarlo/pyaarlo/init.py:722 Integration: Arlo Camera Support First occurred: October 27, 2023 at 8:38:44 AM (4 occurrences) Last logged: 8:23:33 AM

error in response={'success': False, 'data': {'error': '5011', 'message': 'The device failed to connect. Please try again.', 'reason': 'Camera did not stream'}}

error in response={'success': False, 'data': {'error': '2503', 'message': 'The device failed to connect. Try again.', 'reason': 'Camera is not streaming'}}

i8nemo commented 1 year ago

Also happening for me. No recording ever takes place

twrecked commented 1 year ago

I think know what the issue is. To record to the library we need to do the following:

  1. we make a start stream request with Arlo
  2. when we get the stream URL in a reply we connect a home assistant stream to it
  3. when these streams are joined we issue a start recording command to Arlo
  4. after duration seconds we issue a stop recording command to Arlo
  5. Arlo updates its library and we download links to the new recording

Step 2 is important, without anybody connecting to the stream Arlo doesn't actually start the stream. I think step 2 is broken, Arlo returns a rtsp URL but I don't believe you can connect to it.

I can get Arlo to return an mpeg-dash stream by changing the user agent I send to it and this endpoint will allow a connection. But when I do this the stream component of Home Assistant complains, it's expecting a rtsp stream.

I'll think about this one. I might need to start my own ffmpeg session to connect and keep the stream active.

The Stream.stop issue is a simple fix but doesn't help with the main problem.

Maccas1313 commented 1 year ago

Thank you😊I appreciate it! I changed the user_agent in pyaarlo as well but got the usual "Error from stream worker: Error opening stream (INVALIDDATA, Invalid data found when processing input)". Its all beyond my ability tbh but if there is anything I can do to help test, let me know

merlinpimpim commented 1 year ago

Same problem for me 😞 (HACS v0.8.1a5)

One interesting thing, however, is that if I call the same service 2 times in a row (see screenshot), I get a record of a few seconds in the Arlo library. (And an error in the logs: Error writing to '/tmp/aarlo-hidden-floodlight_portail.mp4'. There are likely multiple recordings writing to the same file )

image

twrecked commented 1 year ago

I'll revisit this this week. I might need to fix the link between Aarlo and the stream pieces.

The INVALIDDATA happens because a user agent of linux will make Arlo start a mpeg-dash stream and Home Assistant doesn't like that.

twrecked commented 1 year ago

Fix in the alpha release by #839

The code was waiting for the Home Assistant camera record to stop, it should have returned immediately.

I'm looking at the old release as well.

merlinpimpim commented 1 year ago

I can confirm that it works. Thanks a lot!

twrecked commented 1 year ago

I just merged the 0.7 version as well.

i8nemo commented 1 year ago

Updates and it's not working still. I might be miss understanding the camera_start_recording function. I thought that if HA calls this service, it triggers arlo to record on the entity for the duration stated and it would show into the feed

merlinpimpim commented 1 year ago

With v0.8.1a7 it works with this config: image (The only detail would be to say that the final recording is 2 seconds shorter than the set time.)

twrecked commented 1 year ago

I'll add a fudge to that value. It might end up a little longer.

@i8nemo Sorry, I don't understand "show into the feed". All the service does is make a recording to your Arlo library, if you're using the Aarlo Lovelace card you'll be able to play the recording back when it's done.

Maccas1313 commented 1 year ago

All working for me, thank you so much!

i8nemo commented 1 year ago

I'll add a fudge to that value. It might end up a little longer.

@i8nemo Sorry, I don't understand "show into the feed". All the service does is make a recording to your Arlo library, if you're using the Aarlo Lovelace card you'll be able to play the recording back when it's done.

Thank you. After a couple of restarts it's now working as expected. Thank you

i8nemo commented 1 year ago

Spoke too soon. Although it's worked for 2 days, it's now stopped working again. Where can I find the log files?

twrecked commented 1 year ago

https://github.com/twrecked/hass-aarlo#debug-logs

i8nemo commented 10 months ago

It appears that recent update has fixed this issue for me. The HA trigger successfully records video.