-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotion.yaml
108 lines (104 loc) · 3.7 KB
/
motion.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
# Ending time range needs to match next automation's beginning time.
- alias: Motion - Turn On Guest Bathroom When Motion Detected Daytime
id: motion_turn_on_guest_bathroom_when_motion_detected_daytime
triggers:
- trigger: state
entity_id: binary_sensor.4_in_1_sensor_home_security_motion_detection
from: "off"
to: "on"
conditions:
- condition: state
entity_id: light.zooz_unknown_type_a000_id_a008_level
state: "off"
- condition: time
after: "06:00:00"
before: "21:15:00"
actions:
- action: light.turn_on
entity_id: light.zooz_unknown_type_a000_id_a008_level
data:
brightness_pct: 100
# Beginning time range needs to match previous automation's ending time.
- alias: Motion - Turn On Guest Bathroom When Motion Detected Night
id: motion_turn_on_guest_bathroom_when_motion_detected_night
triggers:
- trigger: state
entity_id: binary_sensor.4_in_1_sensor_home_security_motion_detection
from: "off"
to: "on"
conditions:
- condition: state
entity_id: light.zooz_unknown_type_a000_id_a008_level
state: "off"
- condition: time
after: "21:15:00"
before: "06:15:00"
actions:
- action: light.turn_on
entity_id: light.zooz_unknown_type_a000_id_a008_level
data:
brightness_pct: 21
- alias: Motion - Turn Off Guest Bathroom When No Motion Detected
id: motion_turn_off_guest_bathroom_when_no_motion_detected
triggers:
- trigger: state
entity_id: binary_sensor.4_in_1_sensor_home_security_motion_detection
from: "on"
to: "off"
for: "00:03:00"
conditions:
- condition: state
entity_id: light.zooz_unknown_type_a000_id_a008_level
state: "on"
actions:
- action: light.turn_off
entity_id: light.zooz_unknown_type_a000_id_a008_level
- alias: Motion - Send Camera Snapshot Notification On Motion
id: motion_send_camera_snapshot_notification_on_motion
description: >
Send a notification to the Companion App with a camera snapshot.
triggers:
- trigger: state
entity_id: binary_sensor.office_motion_alarm
to: "on"
variables:
camera_name: camera.office_main
- trigger: state
entity_id: binary_sensor.laundry_motion_alarm
to: "on"
variables:
camera_name: camera.laundry_main
- trigger: state
entity_id: binary_sensor.front_door_cross_region_detection
to: "on"
variables:
camera_name: camera.front_door_main
variables:
# Filename made up of several components for later identification:
# - Camera name. It's clear from viewing the image but makes it easier
# to browse a particular camera later.
# - Time of snapshot (not all cameras stamp the date and time).
# - Additional randomness to filename, in this case it's milliseconds.
# This is added to make guessing the filename more difficult.
snapshot_filename: >
{{ camera_name }}-{{ now().strftime('%Y%m%d-%H%M%S.%f') }}.jpg
snapshot_absolute_path: www/images/snapshots/{{ snapshot_filename }}
# Secret made available as a variable in order to be able to concatenate
# it with the filename.
snapshot_base_url: !secret camera_snapshots_public_url
actions:
- delay:
seconds: 4
- action: camera.snapshot
data:
entity_id: "{{ camera_name }}"
filename: "{{ snapshot_absolute_path }}"
- action: notify.mobile_apps
data:
title: Camera Motion Detected
message: "{{ trigger.to_state.name }}"
data:
image: "{{ snapshot_base_url }}/{{ snapshot_filename }}"
# Use this instead for debugging. Only accessible from intranet.
# image: "/api/camera_proxy/{{ camera_name }}"