-
Notifications
You must be signed in to change notification settings - Fork 0
/
automations.yaml
200 lines (191 loc) · 5.74 KB
/
automations.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
- id: startup
alias: Startup
trigger:
- platform: homeassistant
event: start
condition: []
action:
- service: google_assistant.request_sync
data:
agent_user_id: e39e4023324640a1a5867893e80c3e8c
- id: bathroom_switch_1_hold
alias: Bathroom Switch "ON" Hold
trigger:
- platform: state
entity_id: sensor.bathroom_switch
to: '1_hold'
condition: []
action:
- service: switch.turn_on
data:
entity_id: switch.bathroom_fan
- id: bathroom_switch_4_hold
alias: Bathroom Switch "OFF" Hold
trigger:
- platform: state
entity_id: sensor.bathroom_switch
to: '4_hold'
condition: []
action:
- service: switch.turn_off
data:
entity_id: switch.bathroom_fan
- id: control_cd_player
alias: Control CD Player
trigger:
- platform: state
entity_id: switch.cd_player
- platform: state
entity_id: media_player.living_room_receiver
condition: []
action:
- data_template:
entity_id: >
{% if trigger.entity_id == 'media_player.living_room_receiver' %}
switch.cd_player
{% else %}
media_player.living_room_receiver
{% endif %}
service_template: >
{% if trigger.entity_id == 'media_player.living_room_receiver' %}
{% if trigger.to_state.attributes['source'] == 'CD' %}
switch.turn_on
{% elif trigger.from_state.attributes['source'] == 'CD' %}
switch.turn_off
{% else %}
script.noop
{% endif %}
{% else %}
{% if trigger.to_state.state == 'on' %}
media_player.turn_on
{% else %}
{% if is_state_attr('media_player.living_room_receiver','source', 'CD') %}
media_player.turn_off
{% else%}
script.noop
{% endif %}
{% endif %}
{% endif %}
- condition: and
conditions:
- condition: template
value_template: "{{ trigger.entity_id == 'switch.cd_player' }}"
- condition: template
value_template: "{{ trigger.to_state.state == 'on' }}"
- condition: template
value_template: "{{ state_attr('media_player.living_room_receiver','source') != 'CD' }}"
- service: media_player.select_source
data:
entity_id: media_player.living_room_receiver
source: 'CD'
- id: notify_light_unavailable
alias: Notify Light Unavailable
trigger:
- entity_id: !include entity_lists/lights/lights.yaml
for:
minutes: 5
platform: state
to: 'unavailable'
condition: []
action:
- data_template:
title: "An entity is unavailable"
message: >
{{ trigger.to_state.attributes.friendly_name }} has been {{ trigger.to_state.state }} for more than {{ trigger.for }} (was {{ trigger.from_state.state }})
target: email/[email protected]
service: notify.pushbullet
- id: notify_zwave_unavailable
alias: Notify Z-Wave Unavailable
trigger:
- entity_id: !include entity_lists/zwave.yaml
platform: state
to: 'dead'
condition: []
action:
- data_template:
title: "An entity is unavailable"
message: >
{{ trigger.to_state.attributes.friendly_name }} has been marked as {{ trigger.to_state.state }} (was {{ trigger.from_state.state }})
target: email/[email protected]
service: notify.pushbullet
- id: notify_front_door
alias: Notify Front Door Opened
trigger:
- platform: state
entity_id: binary_sensor.front_door_sensor
to: 'on'
condition: []
action:
- service: notify.pushbullet
data_template:
target: email/[email protected]
title: "The Front Door is Open"
message: >-
The Front Door was opened at {{ as_timestamp(states.binary_sensor.front_door_sensor.last_updated ) | timestamp_custom("%I:%M %p on %a %b %d (%Y-%m-%d %H:%M:%S)", true) -}}
- id: arrival
alias: Arrival Home
trigger: # Assume the door opening means some one is coming home, for now.
- platform: state
entity_id: binary_sensor.front_door_sensor
to: 'on'
condition: []
action:
- condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
- service: light.turn_on
data_template:
entity_id:
- light.living_room
brightness: "{{ [128, state_attr('light.living_room', 'brightness') | int] | max }}"
kelvin: "{{ state_attr('sensor.circadian_values', 'colortemp') }}"
- service: light.turn_on
data_template:
entity_id:
- light.kitchen
brightness: "{{ [128, state_attr('light.kitchen', 'brightness') | int] | max }}"
kelvin: "{{ state_attr('sensor.circadian_values', 'colortemp') }}"
- id: control_bedroom_tv
alias: Control Bedroom TV
trigger:
- platform: state
entity_id: media_player.bedroom_tv
condition: []
action:
- service_template: >
{%- if trigger.from_state.state == 'off' and trigger.to_state.state != 'unavailable' -%}
switch.turn_on
{%- elif trigger.to_state.state == 'off' and trigger.from_state.state != 'unavailable' -%}
switch.turn_off
{%- else -%}
script.noop
{%- endif -%}
data:
entity_id: switch.bedroom_tv
- id: control_living_room_tv_lights
alias: Control Living Room TV Lights
trigger:
- platform: state
entity_id: media_player.living_room_receiver
condition: []
action:
- service_template: >
{%- if trigger.to_state.state == 'off' and trigger.from_state.state != 'unavailable' -%}
light.turn_off
{%- else -%}
script.noop
{%- endif -%}
data:
entity_id: light.living_room_tv
- service_template: >
{%- if trigger.from_state.state == 'off' and trigger.to_state.state != 'unavailable' -%}
light.turn_on
{%- else -%}
script.noop
{%- endif -%}
data:
entity_id: light.living_room_tv
brightness: 80