-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscripts.yaml
248 lines (230 loc) · 9.72 KB
/
scripts.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#---------------- SMASH.PY ------------------
# Generated: 2023-Dec-04 11:23:53
#--------------------------------------------
#--- scripts/blink_trigger_camera.yaml ---
blink_trigger_camera:
alias: Script - Blink Trigger Camera
sequence:
- service: blink.trigger_camera
data:
name: "Camera1"
- delay: 00:00:05
- service: blink.trigger_camera
data:
name: "CameraKS"
- delay: 00:00:05
- service: blink.blink_update
#--- scripts/github_pull.yaml ---
github_pull:
alias: Pull Config from Github
sequence:
- service: shell_command.github_pull
- service: homeassistant.restart
#--- scripts/speech_engine.yaml ---
# For all TTS processing
# Inspired by @CCOSTAN https://github.com/CCOSTAN/Home-AssistantConfig
speech_engine:
sequence:
- condition: or
conditions:
- condition: state
entity_id: sensor.occupancy
state: 'home'
- condition: state
entity_id: input_boolean.guest_mode
state: 'on'
# Speak to all google home devices
- service: script.speech_processing
data_template:
speech_message: >
{%- macro dark_outside() -%}
{{ [
"It's getting late, I will turn on the outside lights.",
"The sun has set, time to turn the lights on outside. I'm on it.",
"I'll go ahead and turn the outside lights on, it's getting dark.",
"Looks like it's time to turn the lights on outside. I got it."
] | random }}
{%- endmacro -%}
{%- macro garbage_night() -%}
{%if now().strftime("%a") == 'Mon' %}
{{ [
"Just a reminder to take the garbage out. Pickup is tomorrow.",
"Beep beep. I don't mean to interrupt, but I wanted to make sure to remind you that it's garbage night.",
"It's starting to smell in here. I think someone should take the trash out considering pick up is tomorrow.",
"Garbage pickup is tomorrow morning. Just a friendly reminder!"
] | random }}
{% endif %}
{%- endmacro -%}
{%- macro washer_status() -%}
{% if states.sensor.washer.state == 'Not Running' %}
{{ [
"Washer cycle is complete, time to throw the clothes into the dryer.",
"Looks like the wash just finished. Figured I should let you know.",
"Just popping in to let you know the wash is done.",
] | random }}
{% endif %}
{%- endmacro -%}
{%- macro fire_co2() -%}
{% if states.sensor.smoke_alarm_kitchen.state == 'Fire' %}
{{ [
"Are you cooking? Because there seems to be a fire in the kitchen.",
"There's a fire... sale. OH MY GOD THE BURNING. Seriously though, you should probably check the Kitchen because a fire has been detected.",
"Warning, fire detected in Kitchen.",
] | random }}
{% elif (states.sensor.smoke_alarm_living_room.state == 'Fire') or (states.sensor.smoke_alarm_nursery.state == 'Fire') %}
{{ [
"Fire detected in the house. Please find a safe exit.",
"Warning, there seems to be a fire in the house!",
"Fire! Please leave the house immediately. I repeat: Fire!",
] | random }}
{% elif (states.sensor.smoke_alarm_living_room.state == 'CO') or (states.sensor.smoke_alarm_nursery.state == 'CO') or (states.sensor.smoke_alarm_kitchen.state == 'CO') %}
{{ [
"Alert! Carbon Monoxide detected, please exit the house and call nine one one",
"Warning! Carbon Monoxide detected in house. I repeat: Warning! Carbon Monoxide has been detected in the house.",
] | random }}
{% endif %}
{%- endmacro -%}
{% if call_dark_outside == 1 %}
{{ dark_outside() }}
{% endif %}
{% if call_garbage_night == 1 %}
{{ garbage_night() }}
{% endif %}
{% if call_washer_status == 1 %}
{{ washer_status() }}
{% endif %}
{% if call_fire_co2 == 1 %}
{{ fire_co2() }}
{% endif %}
#--- scripts/ssl_renew_certificate.yaml ---
ssl_renew_certificate:
alias: SSL Renew Certificate
sequence:
- service: notify.notify_kevin_phone
data:
message: "SSL Renew Instructions - 1) Open Port 80 2) Restart router 3) Run ./ssl_renew from pi's home directory 4) Close Port 80 5) Restart router"
#--- scripts/wake_computer.yaml ---
# Wake computer and turn on lights
wake_computer:
alias: Wake Computer
sequence:
- service: light.turn_on
entity_id:
- light.basement_corner
- light.basement_computer
- light.desk
- service: wake_on_lan.send_magic_packet
data:
mac: !secret wake_mac_address
#--- scripts/flux.yaml ---
flux:
alias: Flux - Global
sequence:
- service: input_boolean.turn_on
entity_id:
- input_boolean.flux_living_room
- input_boolean.flux_family_room
- input_boolean.flux_master_bedroom
- input_boolean.flux_office
#--- scripts/notify_all_engine.yaml ---
notify_all_engine:
sequence:
- service: notify.notify
data_template:
message: >
{%- macro fire_co2() -%}
'ALERT! {{ now().strftime("%h %d, %Y at %H:%M:%S") }} triggered by {{trigger.entity_id}} with staus {{ trigger.to_state.state }}'
{%- endmacro -%}
{%- macro leak_detected() -%}
'ALERT! {{ now().strftime("%h %d, %Y at %H:%M:%S") }} Leak Detected with {{trigger.entity_id}}'
{%- endmacro %}
{##################}
{# BEGIN ROUTINES #}
{##################}
{% if call_fire_co2 == 1 %}
{{ fire_co2() }}
{% endif %}
{% if call_leak_detected == 1 %}
{{ leak_detected() }}
{% endif %}
#--- scripts/hass_upgrade.yaml ---
hass_upgrade:
alias: Upgrade Homeassistant
sequence:
- service: shell_command.hass_upgrade
- service: homeassistant.restart
#--- scripts/notify_kevin_engine.yaml ---
notify_kevin_engine:
sequence:
- service: notify.notify_kevin_phone
data_template:
message: >
{%- macro on_restart() -%}
Home Assistant restarted {{ now().strftime("%h %d, %Y at %H:%M:%S") }}
{%- endmacro -%}
{%- macro system_use() -%}
{% if states.sensor.glances_ram_use.state | float <= 100.0 %}
RAM Usage at {{states.sensor.glances_ram_use.state}}% and Swap at {{states.sensor.glances_swap_use.state}}%!
{% elif states.sensor.glances_ram_use_2.state | float <= 100.0 %}
RAM Usage at {{states.sensor.glances_ram_use_2.state}}% and Swap at {{states.sensor.glances_swap_use.state}}%!
{% endif %}
{%- endmacro -%}
{%- macro ssl_cert_expiry() -%}
Warning - SSL Certificate expires in {{states.sensor.ssl_cert_expiry.state}} days and has not been renewed!
{%- endmacro -%}
{%- macro failed_login() -%}
Failed Login! {{ now().strftime("%h %d, %Y at %H:%M:%S") }}
{% if states.sensor.fail2ban_hass_iptables.state != "None" %}
HASS Attempt(s) from {{states.sensor.fail2ban_hass_iptables.state}} {% endif %} {% if states.sensor.fail2ban_nginx_http_auth.state != "None" %}
NGINX Attempt(s) from {{states.sensor.fail2ban_nginx_http_auth.state}}{% endif %}{% if states.sensor.fail2ban_organizr_auth.state != "None" %}
Organizr Attempt(s) from {{states.sensor.fail2ban_organizr_auth.state}}
{% endif %}
{%- endmacro -%}
{##################}
{# BEGIN ROUTINES #}
{##################}
{% if call_on_restart == 1 %}
{{ on_restart() }}
{% endif %}
{% if call_system_use == 1 %}
{{ system_use() }}
{% endif %}
{% if call_ssl_cert_expiry == 1 %}
{{ ssl_cert_expiry() }}
{% endif %}
{% if call_failed_login == 1 %}
{{ failed_login() }}
{% endif %}
#--- scripts/speech_processing.yaml ---
speech_processing:
sequence:
- service: media_player.volume_set
entity_id: media_player.google_home
data:
volume_level: 0.5
- service: tts.google_say
entity_id: media_player.google_home
data_template:
message: >
{{ speech_message }}
#--- scripts/upgrade_pihole.yaml ---
upgrade_pihole:
alias: Upgrade PiHole
sequence:
- service: shell_command.pihole_upgrade
#--- scripts/zwave_fix_dead_node.yaml ---
zwave_fix_dead_node:
alias: Script - Fix Dead ZWave Node
sequence:
- condition: or
conditions:
- condition: template
value_template: '{{ states.zwave.driveway.attributes.is_failed }}'
- condition: template
value_template: '{{ 1 < 0 }}'
- service: zwave.test_node
data_template:
node_id: '{{states.zwave.driveway.attributes.node_id}}'
- service: notify.notify_kevin_phone
data_template:
message: 'Driveway switch dead, trying to fix. {{now().strftime("h %d, %Y at %H:%M:%S")}}'