Skip to content

Commit

Permalink
Alpha 7 (#839)
Browse files Browse the repository at this point in the history
* Fixed recording issue.
Fixed typo.

* Fixed recording issue.
Fixed typo.

* Fixed recording issue.
Fixed typo.
  • Loading branch information
twrecked authored Nov 23, 2023
1 parent cc06f37 commit 17401f6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ The logs will now include dumps of packets sent by _Arlo_. The following
is an example of a subscription response:
```json
{"status": "connected"},
{ "status": "connected"},
{ "action": "is",
"from": "XXXXXXXXXXXXX",
"resource": "subscriptions/XXXXXX-XXX-XXXXXXX_web",
Expand Down Expand Up @@ -1104,7 +1104,7 @@ The component provides the following services:
| `aarlo.sirens_on` | `entity_id` - name(s) of entities to use <br>`duration` - amount of time in seconds to record<br/>`volume` - how loud to set siren | Turns all sirens on. |
| `aarlo.siren_off` | `entity_id` - name(s) of entities to use | Turns a siren off. |
| `aarlo.sirens_off` | | Turns all sirens off. |
| `aarlo.restart_device` | `entity_id` - name(s) of entities to reboot | Turns a siren off. |
| `aarlo.restart_device` | `entity_id` - name(s) of entities to reboot | Restarts a base station. You need admin access to do this. |
| `aarlo.inject_response` | `filename` - file to read packet from | Inject a packet into the event stream. |

For recordings longer than 30 seconds you will need to white list the `/tmp`
Expand Down
3 changes: 3 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
aarlo
0.8.1a7
Fix camera recording.
Tidy up a docs issue.
0.8.1a6
Make some instance variables explicit
Fix service entries
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 @@ -45,7 +45,7 @@
from .cfg import BlendedCfg, PyaarloCfg


__version__ = "0.8.1a6"
__version__ = "0.8.1a7"

_LOGGER = logging.getLogger(__name__)

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

import asyncio
import base64
import logging
import voluptuous as vol
Expand Down Expand Up @@ -354,6 +355,8 @@ def update_state(_device, attr, value):
self.clear_stream()
elif value == "fullFrameSnapshot":
self._attr_is_recording = True
elif value == "startUserStream":
pass
else:
self._state = STATE_IDLE
self._attr_is_streaming = False
Expand Down Expand Up @@ -454,7 +457,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 @@ -581,7 +586,7 @@ def _attach_hidden_stream(self, duration):
CONF_DURATION: duration,
CONF_LOOKBACK: 0,
}
self.hass.services.call(CAMERA_DOMAIN, SERVICE_RECORD, data, blocking=True)
self.hass.services.call(CAMERA_DOMAIN, SERVICE_RECORD, data, blocking=False)

_LOGGER.debug("waiting on stream connect")
return self._camera.wait_for_user_stream()
Expand Down Expand Up @@ -643,11 +648,21 @@ 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()
_LOGGER.debug("attached, recording")
self._camera.start_recording(duration=duration)
return source
_LOGGER.warning("failed to start recording for {}".format(self._camera.name))
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 @@ -15,5 +15,5 @@
"unidecode",
"pyaarlo>=0.8.0.2"
],
"version": "0.8.1a6"
"version": "0.8.1a7"
}

0 comments on commit 17401f6

Please sign in to comment.