-
Notifications
You must be signed in to change notification settings - Fork 0
/
HA-Blueprint-Sleep-by-Presence
75 lines (69 loc) · 2.48 KB
/
HA-Blueprint-Sleep-by-Presence
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
blueprint:
name: Motion Detection with `occupied` Check
description: Executes an action when motion is detected and the room remains `occupied` without further motion. If the same sensor reports both motion and occupancy, select it in both fields.
domain: automation
input:
motion_sensor:
name: Motion Sensor
description: Select the motion sensor that detects movement. If the same sensor reports both motion and occupancy, select it here as well.
selector:
entity:
domain: binary_sensor
device_class: motion
occupied_sensor:
name: Occupancy Sensor
description: Select the sensor that reports the `occupied` status. If the same sensor reports both motion and occupancy, select it here as well.
selector:
entity:
domain: binary_sensor
device_class: occupancy
timer_duration:
name: No Motion Timer Duration
description: The duration after which the action will be executed if the room remains `occupied` without further motion.
default: "00:05:00"
selector:
time:
action:
name: Action to Perform
description: The action to execute when the room remains `occupied` without motion.
default: []
selector:
action: {}
automation:
- alias: 'Motion Detection with `occupied` Check'
trigger:
# Trigger when motion is detected
- platform: state
entity_id: !input motion_sensor
to: 'on'
action:
# When motion is detected, check `occupied` status
- choose:
- conditions:
- condition: state
entity_id: !input occupied_sensor
state: 'on' # Sensor reports `occupied`
sequence:
- service: script.turn_off
target:
entity_id: script.occupied_timer_expired
- service: script.turn_on
target:
entity_id: script.occupied_timer_expired
data:
variables:
timer_duration: !input timer_duration
default:
- service: script.turn_off
target:
entity_id: script.occupied_timer_expired
script:
occupied_timer_expired:
alias: 'Occupied Timer Expired'
sequence:
- delay: "{{ timer_duration }}"
- condition: state
entity_id: !input occupied_sensor
state: 'on' # Sensor reports `occupied`
- choose:
- sequence: !input action