Skip to content

Commit

Permalink
add record services (#9062)
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterjm authored and frenck committed Mar 30, 2019
1 parent fda7b33 commit 6280623
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
29 changes: 28 additions & 1 deletion source/_components/camera.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Take a snapshot from a camera.
| Service data attribute | Optional | Description |
| ---------------------- | -------- | ----------- |
| `entity_id` | no | Name(s) of entities to create a snapshot from, e.g., `camera.living_room_camera`. |
| `filename ` | no | Template of a file name. Variable is `entity_id`, e.g., {% raw %}`/tmp/snapshot_{{ entity_id }}`{% endraw %}. |
| `filename` | no | Template of a file name. Variable is `entity_id`, e.g., {% raw %}`/tmp/snapshot_{{ entity_id }}`{% endraw %}. |

The path part of `filename` must be an entry in the `whitelist_external_dirs` in your [`homeassistant:`](/docs/configuration/basic/) section of your `configuration.yaml` file.

Expand All @@ -73,6 +73,33 @@ action:
```
{% endraw %}
#### {% linkable_title Service `record` %}

Make a `.mp4` recording from a camera stream. Requires `stream` component to be set up.

Both `duration` and `lookback` options are suggestions, but should be consistent per camera. The actual length of the recording may vary. It is suggested that you tweak these settings to fit your needs.

| Service data attribute | Optional | Description |
| ---------------------- | -------- | ----------- |
| `entity_id` | no | Name(s) of entities to create a snapshot from, e.g., `camera.living_room_camera`. |
| `filename` | no | Template of a file name. Variable is `entity_id`, e.g., {% raw %}`/tmp/{{ entity_id }}.mp4`{% endraw %}. |
| `duration` | yes | Target recording length (in seconds). Default: 30 |
| `lookback` | yes | Target lookback period (in seconds) to include in addition to duration. Only available if there is currently an active HLS stream. Default: 0 |

The path part of `filename` must be an entry in the `whitelist_external_dirs` in your [`homeassistant:`](/docs/configuration/basic/) section of your `configuration.yaml` file.

For example, the following action in an automation would take a recording from "yourcamera" and save it to /tmp with a timestamped filename.

{% raw %}
```yaml
action:
service: camera.record
data:
entity_id: camera.yourcamera
filename: '/tmp/{{ entity_id }}_{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4'
```
{% endraw %}

#### {% linkable_title Service `play_stream` %}

Play a live stream from a camera to selected media player(s). Requires `stream` component to be set up.
Expand Down
29 changes: 29 additions & 0 deletions source/_components/stream.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,35 @@ To enable this component, add the following lines to your `configuration.yaml` f
stream:
```
### {% linkable_title Services %}
Once loaded, the `stream` platform will expose services that can be called to perform various actions.

#### {% linkable_title Service `record` %}

Make a `.mp4` recording from a provided stream. While this service can be called directly, it is used internally by the [`camera.record`](/components/camera#service-record) service.

Both `duration` and `lookback` options are suggestions, but should be consistent per stream. The actual length of the recording may vary. It is suggested that you tweak these settings to fit your needs.

| Service data attribute | Optional | Description |
| ---------------------- | -------- | ----------- |
| `stream_source` | no | The input source for the stream, e.g., `rtsp://my.stream.feed:554`. |
| `filename` | no | The file name string. Variable is `entity_id`, e.g., `/tmp/my_stream.mp4`. |
| `duration` | yes | Target recording length (in seconds). Default: 30 |
| `lookback` | yes | Target lookback period (in seconds) to include in addition to duration. Only available if there is currently an active HLS stream for `stream_source`. Default: 0 |

The path part of `filename` must be an entry in the `whitelist_external_dirs` in your [`homeassistant:`](/docs/configuration/basic/) section of your `configuration.yaml` file.

For example, the following action in an automation would take a recording from `rtsp://my.stream.feed:554` and save it to `/tmp`.

```yaml
action:
service: camera.record
data:
stream_source: rtsp://my.stream.feed:554
filename: '/tmp/my_stream.mp4'
```

## {% linkable_title Troubleshooting %}

Some users on manual installs may see the following error in their logs after restarting:
Expand Down

0 comments on commit 6280623

Please sign in to comment.