diff --git a/README.md b/README.md index 1a97c38a..8d6186c2 100644 --- a/README.md +++ b/README.md @@ -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", @@ -1104,7 +1104,7 @@ The component provides the following services: | `aarlo.sirens_on` | `entity_id` - name(s) of entities to use
`duration` - amount of time in seconds to record
`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` diff --git a/changelog b/changelog index 9118dd7b..2acd1424 100644 --- a/changelog +++ b/changelog @@ -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 diff --git a/custom_components/aarlo/__init__.py b/custom_components/aarlo/__init__.py index ed211350..8d657801 100644 --- a/custom_components/aarlo/__init__.py +++ b/custom_components/aarlo/__init__.py @@ -45,7 +45,7 @@ from .cfg import BlendedCfg, PyaarloCfg -__version__ = "0.8.1a6" +__version__ = "0.8.1a7" _LOGGER = logging.getLogger(__name__) diff --git a/custom_components/aarlo/camera.py b/custom_components/aarlo/camera.py index 7ffece96..7c0b7451 100644 --- a/custom_components/aarlo/camera.py +++ b/custom_components/aarlo/camera.py @@ -7,6 +7,7 @@ """ from __future__ import annotations +import asyncio import base64 import logging import voluptuous as vol @@ -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 @@ -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 @@ -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() @@ -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)) diff --git a/custom_components/aarlo/manifest.json b/custom_components/aarlo/manifest.json index 43d9e430..ca44172d 100644 --- a/custom_components/aarlo/manifest.json +++ b/custom_components/aarlo/manifest.json @@ -15,5 +15,5 @@ "unidecode", "pyaarlo>=0.8.0.2" ], - "version": "0.8.1a6" + "version": "0.8.1a7" }