add record services (#9062)

This commit is contained in:
Jason Hunter 2019-03-30 04:25:52 -04:00 committed by Paulus Schoutsen
parent 948a96c597
commit dd0514c3d4
2 changed files with 57 additions and 1 deletions

View File

@ -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.
@ -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.

View File

@ -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: