Skip to content

Commit

Permalink
Fix camera recording issue. (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
twrecked authored Nov 23, 2023
1 parent 612a228 commit 830f319
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
2 changes: 2 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
aarlo/pyaarlo
0.7.4.1:
Fix camera recording issue.
0.7.4:
Remove the beta because 0.8.1 alpha coming.
0.7.4b20:
Expand Down
4 changes: 2 additions & 2 deletions custom_components.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"aarlo": {
"version": "0.7.4",
"version": "0.7.4.1",
"local_location": "/custom_components/aarlo/__init__.py",
"remote_location": "https://raw.githubusercontent.com/twrecked/hass-aarlo/master/custom_components/aarlo/__init__.py",
"visit_repo": "https://github.com/twrecked/hass-aarlo",
Expand All @@ -18,7 +18,7 @@
]
},
"pyaarlo": {
"version": "0.7.4",
"version": "0.7.4.1",
"local_location": "/custom_components/aarlo/pyaarlo/__init__.py",
"remote_location": "https://raw.githubusercontent.com/twrecked/hass-aarlo/master/custom_components/aarlo/pyaarlo/__init__.py",
"visit_repo": "https://github.com/twrecked/hass-aarlo",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
SIREN_STATE_KEY
)

__version__ = "0.7.4"
__version__ = "0.7.4.1"

_LOGGER = logging.getLogger(__name__)

Expand Down
23 changes: 19 additions & 4 deletions custom_components/aarlo/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
from __future__ import annotations

import asyncio
import base64
import logging

Expand Down Expand Up @@ -380,6 +381,8 @@ def update_state(_device, attr, value):
elif value == "unavailable":
self._state = "Unavailable"
self.clear_stream()
elif value == "startUserStream":
pass
else:
self._state = STATE_IDLE
self.clear_stream()
Expand Down Expand Up @@ -474,7 +477,9 @@ def clear_stream(self):
if hasattr(self, "stream"):
if self.stream:
_LOGGER.debug("clearing out stream variable")
self.stream.stop()
asyncio.run_coroutine_threadsafe(
self.stream.stop(), self.hass.loop
)
self.stream = None

@property
Expand Down Expand Up @@ -641,7 +646,7 @@ def _attach_hidden_stream(self, duration):
CONF_DURATION: duration,
CONF_LOOKBACK: 0,
}
self.hass.services.call(DOMAIN, SERVICE_RECORD, data, blocking=True)
self.hass.services.call(DOMAIN, SERVICE_RECORD, data, blocking=False)

_LOGGER.debug("waiting on stream connect")
return self._camera.wait_for_user_stream()
Expand Down Expand Up @@ -703,12 +708,22 @@ async def async_siren_off(self):
return await self.hass.async_add_executor_job(self.siren_off)

def start_recording(self, duration=30):
""" Create a recording in the Arlo library.
Has to do 3 things:
- start a stream on the camera
- attach a dummy local stream to tell Arlo to really start the stream
- send a "record-this-stream" request.
We force the "arlo" user agent to get an rtsp stream.
"""
source = self._camera.start_recording_stream(user_agent="arlo")
if source:
_LOGGER.debug(f"stream-url={source}")
active = self._attach_hidden_stream(duration + 10)
if active:
# source = self._camera.start_recording_stream()
self._camera.start_recording(duration=duration)
_LOGGER.debug("attached, recording")
source = self._camera.start_recording(duration=duration)
return source
_LOGGER.warning("failed to start recording for {}".format(self._camera.name))
return None
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aarlo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"iot_class": "cloud_push",
"issue_tracker": "https://github.com/twrecked/hass-aarlo/issues",
"requirements": ["unidecode","cloudscraper>=1.2.71", "paho-mqtt"],
"version": "0.7.4"
"version": "0.7.4.1"
}
2 changes: 1 addition & 1 deletion custom_components/aarlo/pyaarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

_LOGGER = logging.getLogger("pyaarlo")

__version__ = "0.7.4"
__version__ = "0.7.4.1"


class PyArlo(object):
Expand Down

0 comments on commit 830f319

Please sign in to comment.