/
presence.yaml
132 lines (120 loc) · 4.23 KB
/
presence.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
---
automation:
- alias: "Presence: Alter automations based on whether anyone is home"
id: "presence_alter_automations_based_on_whether_anyone_is_home"
trigger:
- platform: state
id: departing
entity_id: sensor.proximity_zone
from: Home
for: "00:00:10"
- platform: state
id: arriving
entity_id: sensor.proximity_zone
from:
- Away
- Edge
- Nearby
to: Home
action:
- if:
- alias: "We are departing"
condition: trigger
id: departing
then:
- parallel:
- alias: "Turn various entities off"
service: homeassistant.turn_off
target:
entity_id:
- automation.master_bedroom_cycle_toilet_fan_during_the_day
- automation.modes_automatically_handle_sunrise
- alias: "Turn various entities on"
service: homeassistant.turn_on
target:
entity_id:
- automation.garage_notify_when_the_garage_door_is_left_open
- automation.security_notify_when_the_house_is_empty_and_insecure
- automation.security_notify_when_the_overall_security_status_changes
- automation.security_simulate_someone_being_home
- alias: "Set the Eufy base station to 'Away' mode"
service: alarm_control_panel.alarm_arm_away
target:
entity_id: alarm_control_panel.eufy_base_station
else:
- parallel:
- alias: "Turn various entities off"
service: homeassistant.turn_off
target:
entity_id:
- automation.security_notify_when_the_overall_security_status_changes
- automation.security_simulate_someone_being_home
- input_boolean.vacation_mode
- remote.basement_tv
- remote.living_room_tv
- alias: "Turn various entities on"
service: homeassistant.turn_on
target:
entity_id:
- automation.garage_notify_when_the_garage_door_is_left_open
- automation.master_bedroom_cycle_toilet_fan_during_the_day
- automation.modes_automatically_handle_sunrise
- automation.security_automatically_lock_up_the_house_when_appropriate
- automation.security_notify_when_the_house_is_empty_and_insecure
- switch.guardian_b4e62d98118d_valve
- switch.humidistat_switchbot
- alias: "Set the Eufy base station to 'Home' mode"
service: alarm_control_panel.alarm_arm_home
target:
entity_id: alarm_control_panel.eufy_base_station
group:
people:
name: People
entities:
- person.aaron
- person.spouse
input_number:
edge_radius:
name: Edge Radius
min: 0
max: 10
step: 1
unit_of_measurement: miles
icon: mdi:radius-outline
home_radius:
name: Home Radius
min: 0
max: 10
step: 1
unit_of_measurement: miles
icon: mdi:radius-outline
nearby_radius:
name: Nearby Radius
min: 0
max: 10
step: 1
unit_of_measurement: miles
icon: mdi:radius-outline
template:
sensor:
- name: Proximity Zone
state: >
{% set proximity = states("proximity.home") %}
{% if proximity == "not set" %}
# Default to Aaron's presence state if proximity isn't set up yet:
{{ states("person.aaron") | title }}
{% else %}
{% set prox_mi = states("proximity.home")|int / 5280 %}
{% set home = states("input_number.home_radius")|int %}
{% set nearby = states("input_number.nearby_radius")|int %}
{% set edge = states("input_number.edge_radius")|int %}
{% if prox_mi <= home %}
Home
{% elif home < prox_mi <= nearby %}
Nearby
{% elif nearby < prox_mi <= edge %}
Edge
{% else %}
Away
{% endif %}
{% endif %}