From 14ec591668e1497a7571fd6943cfab7aacc16005 Mon Sep 17 00:00:00 2001 From: Andrew Peebles Date: Sun, 28 Jan 2024 15:17:46 -0800 Subject: [PATCH 1/5] Simplysafe doc for motion events --- source/_integrations/simplisafe.markdown | 89 +++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/source/_integrations/simplisafe.markdown b/source/_integrations/simplisafe.markdown index b4c39a37a14a..0c546c5d065e 100644 --- a/source/_integrations/simplisafe.markdown +++ b/source/_integrations/simplisafe.markdown @@ -37,6 +37,7 @@ There is currently support for the following device types within Home Assistant: - **Smoke Detector**: reports on the smoke sensor status*. - **Smoke+CO Detector**: reports on the smoke and carbon monoxide sensor status*. - **Water Sensor**: reports on water sensor status*. +- **Outdoor Camera**: capture motion event images and media clips - Sensor status is only available for SimpliSafe V3 systems and is updated once every 30 seconds, so information displayed in Home Assistant may be delayed. @@ -88,6 +89,25 @@ Set one or more system properties. | `light` | yes | Whether the light on the base station should display when armed | | `voice_prompt_volume` | yes | The volume of the base station's voice prompts | +### `simplisafe.capture_motion_image` + +Capture a motion event jpeg image. + +| Service Data Attribute | Optional | Description | +| ---------------------- | -------- | ---------------------------------------------------------------------------- | +| `entity_id` | no | The entity id of a camera | +| `width` | yes | Desired width in pixels of the captured image. Default is 720. 240-1080. | +| `filename` | no | A file name (or template) to save the image to | + +### `simplisafe.capture_motion_clip` + +Capture a motion event mp4 clip. + +| Service Data Attribute | Optional | Description | +| ---------------------- | -------- | ---------------------------------------------------------------------------- | +| `entity_id` | no | The entity id of a camera | +| `filename` | no | A file name (or template) to save the video clip to | + ## Events ### `SIMPLISAFE_EVENT` @@ -104,6 +124,7 @@ following keys: - `last_event_sensor_type`: the type of sensor that triggered the event (if appropriate) - `system_id`: the system ID to which the event belongs - `last_event_timestamp`: the UTC datetime at which the event was received +- `media_urls`: a dict containing media URLs if the event_type is `camera_motion_detected` (see below) For example, when someone rings the doorbell, a `SIMPLISAFE_EVENT` event will fire with the following event data: @@ -141,7 +162,22 @@ For example, when someone rings the doorbell, a - `sensor_paired_and_named` - `user_initiated_test` -To build an automation using one of these, use `SIMPLISAFE_EVENT` +If `last_event_type` is `camera_motion_detected` then `SIMPLISAFE_EVENT` will include +a `media_urls` key that is a dictionary that looks like + +```python +{ + 'image_url': "https://xxx.us-east-1.prd.cam.simplisafe.com/xxx", + 'clip_url': "https://xxx.us-east-1.prd.cam.simplisafe.com/xxx" +} +``` + +The 'image_url' is an absolute URL to a JPEG file. The 'clip_url' is an absolute URL +to a short MPEG4 video clip. Both refer to the motion detected by the camera. You +can obtain these files locally using the "capture_motion_image" and "capture_motion_clip" +services respectively. + +To build an automation using one of these event types, use `SIMPLISAFE_EVENT` as an event trigger, with `last_event_type` as the `event_data`. For example, the following will trigger when the doorbell rings: @@ -168,3 +204,54 @@ Note that when Home Assistant restarts, `SIMPLISAFE_NOTIFICATION` events will fi again for any notifications still active in the SimpliSafe web and mobile apps. To prevent this, either (a) clear them in the web/mobile app or (b) utilize the `clear_notifications` button provided by the alarm control panel. + +### `MOTION EVENT AUTOMATIONS` + +When a `camera_motion_event` occurs on a camera (currently only outdoor cameras are supported), +you may want to capture the image and video clip associated with that event. First create a trigger +that looks something like this: + +```yaml +trigger: + - platform: event + event_type: SIMPLISAFE_EVENT + event_data: + last_event_type: camera_motion_detected + last_event_sensor_type: OUTDOOR_CAMERA + last_event_sensor_serial: f11b6abd +``` + +where the `last_event_sensor_serial` is the serial number of a specifc camera you are targetting. One +way to obtain that serial number is to use the "Developer tools" and listen on `SIMPLISAFE_EVENT` events +and then walk in front of your camera. `last_event_sensor_serial` will contain that serial number. + +Then for actions associated with that trigger, something like this: + +```yaml +service: simplisafe.capture_motion_clip +data: + entity_id: camera.back_yard_camera_one + filename: >- + /config/www/simplisafe/back_yard/clips/{{now().strftime('%Y%m%d%H%M%S')}}.mp4 +``` + +and + +```yaml +service: simplisafe.capture_motion_image +data: + width: 720 + filename: "/config/www/simplisafe/back_yard/latest.jpg" + entity_id: camera.back_yard_camera_one +``` + +In this example, we are creating a directory structure that contains the latest image, and a history of +video clips. You could use the "files" integration and this snipet in your "configuration.yaml" file: + +```yaml +sensor: + - platform: files + folder: /config/www/simplisafe/back_yard/clips + name: back_yard_media +``` + From ef1743208a1d8ec9d26f77b3783d78553d75ca85 Mon Sep 17 00:00:00 2001 From: Andrew Peebles Date: Sun, 28 Jan 2024 23:46:00 +0000 Subject: [PATCH 2/5] working on lint fixes --- source/_integrations/simplisafe.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_integrations/simplisafe.markdown b/source/_integrations/simplisafe.markdown index 0c546c5d065e..d0c0d4312041 100644 --- a/source/_integrations/simplisafe.markdown +++ b/source/_integrations/simplisafe.markdown @@ -246,7 +246,7 @@ data: ``` In this example, we are creating a directory structure that contains the latest image, and a history of -video clips. You could use the "files" integration and this snipet in your "configuration.yaml" file: +video clips. You could use the "files" integration and this snippet in your "configuration.yaml" file: ```yaml sensor: From 3ea7fc92757e16ed79818ad9d3acc1536477e060 Mon Sep 17 00:00:00 2001 From: Andrew Peebles Date: Sun, 28 Jan 2024 23:53:44 +0000 Subject: [PATCH 3/5] working on lint fixes --- source/_integrations/simplisafe.markdown | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/source/_integrations/simplisafe.markdown b/source/_integrations/simplisafe.markdown index d0c0d4312041..1c1b5444c0a0 100644 --- a/source/_integrations/simplisafe.markdown +++ b/source/_integrations/simplisafe.markdown @@ -162,7 +162,7 @@ For example, when someone rings the doorbell, a - `sensor_paired_and_named` - `user_initiated_test` -If `last_event_type` is `camera_motion_detected` then `SIMPLISAFE_EVENT` will include +If `last_event_type` is `camera_motion_detected` then `SIMPLISAFE_EVENT` will include a `media_urls` key that is a dictionary that looks like ```python @@ -172,10 +172,10 @@ a `media_urls` key that is a dictionary that looks like } ``` -The 'image_url' is an absolute URL to a JPEG file. The 'clip_url' is an absolute URL -to a short MPEG4 video clip. Both refer to the motion detected by the camera. You -can obtain these files locally using the "capture_motion_image" and "capture_motion_clip" -services respectively. +The 'image_url' is an absolute URL to a JPEG file. The 'clip_url' is an absolute URL +to a short MPEG4 video clip. Both refer to the motion detected by the camera. You +can obtain these files locally using the "capture_motion_image" and "capture_motion_clip" +services respectively. To build an automation using one of these event types, use `SIMPLISAFE_EVENT` as an event trigger, with `last_event_type` as the `event_data`. @@ -202,13 +202,13 @@ event data that contains the following keys: Note that when Home Assistant restarts, `SIMPLISAFE_NOTIFICATION` events will fire once again for any notifications still active in the SimpliSafe web and mobile apps. To -prevent this, either (a) clear them in the web/mobile app or (b) utilize the +prevent this, either (a) clear them in the web/mobile app or (b) utilize the `clear_notifications` button provided by the alarm control panel. ### `MOTION EVENT AUTOMATIONS` -When a `camera_motion_event` occurs on a camera (currently only outdoor cameras are supported), -you may want to capture the image and video clip associated with that event. First create a trigger +When a `camera_motion_event` occurs on a camera (currently only outdoor cameras are supported), +you may want to capture the image and video clip associated with that event. First create a trigger that looks something like this: ```yaml @@ -221,7 +221,7 @@ trigger: last_event_sensor_serial: f11b6abd ``` -where the `last_event_sensor_serial` is the serial number of a specifc camera you are targetting. One +where the `last_event_sensor_serial` is the serial number of a specifc camera you are targeting. One way to obtain that serial number is to use the "Developer tools" and listen on `SIMPLISAFE_EVENT` events and then walk in front of your camera. `last_event_sensor_serial` will contain that serial number. @@ -245,7 +245,7 @@ data: entity_id: camera.back_yard_camera_one ``` -In this example, we are creating a directory structure that contains the latest image, and a history of +In this example, we are creating a directory structure that contains the latest image, and a history of video clips. You could use the "files" integration and this snippet in your "configuration.yaml" file: ```yaml @@ -254,4 +254,3 @@ sensor: folder: /config/www/simplisafe/back_yard/clips name: back_yard_media ``` - From 6692e4f150fb1fe753bae2313c8a0f44be23b5c1 Mon Sep 17 00:00:00 2001 From: Andrew Peebles Date: Mon, 29 Jan 2024 00:05:10 +0000 Subject: [PATCH 4/5] working on lint fixes --- source/_integrations/simplisafe.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_integrations/simplisafe.markdown b/source/_integrations/simplisafe.markdown index 1c1b5444c0a0..6c5cca3e05bb 100644 --- a/source/_integrations/simplisafe.markdown +++ b/source/_integrations/simplisafe.markdown @@ -232,7 +232,7 @@ service: simplisafe.capture_motion_clip data: entity_id: camera.back_yard_camera_one filename: >- - /config/www/simplisafe/back_yard/clips/{{now().strftime('%Y%m%d%H%M%S')}}.mp4 + /config/www/simplisafe/back_yard/clips/{{now()}}.mp4 ``` and From 08350c555468ab31c583e806f0dab196d3c033f7 Mon Sep 17 00:00:00 2001 From: Andrew Peebles Date: Mon, 29 Jan 2024 00:12:08 +0000 Subject: [PATCH 5/5] working on lint fixes --- source/_integrations/simplisafe.markdown | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/_integrations/simplisafe.markdown b/source/_integrations/simplisafe.markdown index 6c5cca3e05bb..52034dbdd40a 100644 --- a/source/_integrations/simplisafe.markdown +++ b/source/_integrations/simplisafe.markdown @@ -227,14 +227,18 @@ and then walk in front of your camera. `last_event_sensor_serial` will contain Then for actions associated with that trigger, something like this: +{% raw %} + ```yaml service: simplisafe.capture_motion_clip data: entity_id: camera.back_yard_camera_one filename: >- - /config/www/simplisafe/back_yard/clips/{{now()}}.mp4 + /config/www/simplisafe/back_yard/clips/{{now().strftime('%Y%m%d%H%M%S')}}.mp4 ``` +{% endraw %} + and ```yaml