-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhome-assistant.yml
318 lines (288 loc) · 12.3 KB
/
home-assistant.yml
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
---
- hosts: homelab
vars:
application: home-assistant
docker_network: "{{ networks.iot }}"
home_assistant_configuration: "{{ config_directory }}/config/configuration.yaml"
home_assistant_automations_dir: "{{ config_directory }}/config/automations"
home_assistant_addons_dir: "{{ config_directory }}/config/addons"
home_assistant_integrations_dir: "{{ config_directory }}/config/integrations"
handlers:
- name: Restart
community.docker.docker_container:
name: "{{ application }}"
restart: true
comparisons:
'*': ignore
tasks:
- name: Create config folder
ansible.builtin.file:
path: "{{ config_directory }}"
state: directory
owner: "{{ common_user_id }}"
group: "{{ common_root_group }}"
mode: "0771"
- name: Create postgres container
tags:
- integrations
ansible.builtin.import_role:
name: postgres
vars:
postgres_version: 17
postgres_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
32633539336137363933353436636432623537373832643930306335333333616364376162346332
3837343131623965653961313661643363353563626566350a346334356436653337393738383535
36623461656638313732393732363933393734326438646462633830613238353535303637323431
6562633838373165360a343239626161646138666432316566636337343530633963326666326665
61306432353564653366363434666232343731343437343439306361346561366536643635353864
3266623034333431363434306365336361333932613164306264
- name: Create influxdb container
tags:
- integrations
ansible.builtin.import_role:
name: influxdb
vars:
influxdb_version: 2.7
influxdb_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
39383139643961303364626537306531346530373162353465356237386332636239343238633663
6134353665323265386338633634393038663665316239390a623663343530666462623031633662
37656435353865356539353566656133643339656130623938393639303631303665343431393963
6263613830323737390a356566613732656163303430313162303330323330393461653432376166
37333531656136633639373735616532663264633030373365623030336239666262
influxdb_traefik:
enable: "true"
influxdb_homepage:
enable: "true"
name: "Home Assistant InfluxDB"
description: "Long term data from devices"
group: Home Automation
weight: 300
- name: Create container
ansible.builtin.include_role:
name: docker_container
vars:
image: ghcr.io/home-assistant/home-assistant:2025.2.4
env:
TZ: "{{ common_timezone }}"
volumes:
- "{{ config_directory }}/config:/config"
- /etc/localtime:/etc/localtime:ro
ipv4_address: "{{ docker_network.prefix }}.253"
traefik:
-
name: "{{ application }}-short"
port: 8123
rule: Host(`home.{{ common_tld }}`)
-
port: 8123
rule: Host(`{{ application }}.{{ common_tld }}`)
homepage:
name: Home Assistant
group: Home Automation
weight: 50
description: "Home automation"
href: "https://home.{{ common_tld }}"
network_mode: "host"
privileged: true
- name: Wait for config file
ansible.builtin.wait_for:
path: "{{ home_assistant_configuration }}"
- name: Configure integrations
tags:
- integrations
block:
- name: Create integration folder
ansible.builtin.file:
path: "{{ home_assistant_integrations_dir }}"
state: directory
owner: "{{ common_root_id }}"
group: "{{ common_root_group }}"
mode: "0771"
- name: Template integrations
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ home_assistant_integrations_dir }}/{{ item | basename | regex_replace('\\.j2$', '') }}"
mode: "0644"
validate: "echo checking %s && docker exec {{ application }}/usr/local/bin/hass --script check_config --config /config"
notify: Restart
with_fileglob:
- "{{ files_directory }}/integrations/*"
- name: Include integration config within main configuration file
ansible.builtin.lineinfile:
path: "{{ home_assistant_configuration }}"
regexp: "^{{ item | basename | regex_replace('\\.yaml.j2$', '') }}"
line: "{{ item | basename | regex_replace('\\.yaml.j2$', '') }}: !include integrations/{{ item | basename | regex_replace('\\.j2$', '') }}"
state: present
notify: Restart
with_fileglob:
- "{{ files_directory }}/integrations/*"
- name: Install Addons
block:
- name: Create addons folder
ansible.builtin.file:
path: "{{ home_assistant_addons_dir }}"
state: directory
owner: "{{ common_root_id }}"
group: "{{ common_root_group }}"
mode: "0771"
- name: Create python_scripts folder
tags:
- integrations
ansible.builtin.file:
path: "{{ config_directory }}/config/python_scripts"
state: directory
owner: "{{ common_root_id }}"
group: "{{ common_root_group }}"
mode: "0771"
notify: Restart
- name: Copy Google Service Account file
tags:
- integrations
ansible.builtin.copy:
src: "{{ files_directory }}/google-service-account.json"
dest: "{{ home_assistant_integrations_dir }}/google-service-account.json"
owner: "{{ common_root_id }}"
group: "{{ common_root_group }}"
mode: "0771"
notify: Restart
- name: Create Eufy Security WS container
ansible.builtin.include_role:
name: docker_container
vars:
name: "eufy-security-ws"
image: bropat/eufy-security-ws:1.9.1
env:
USERNAME: "{{ application }}{{ common_email_to }}"
PASSWORD: !vault |
$ANSIBLE_VAULT;1.1;AES256
32663633343362623462393864346631393638613933346166653764396530316264616364613065
6339376630643833346639653530333835653037613363620a663464623137663031313931356432
64383264306365656430363137353965643963313136616637626534396362376436626466303965
3839336635646338380a386564356461393564373236333464343835646535663462303862303361
6162
LANGUAGE: "{{ common_language_iso_639 }}"
COUNTRY: "{{ common_country_iso_3166 }}"
TRUSTED_DEVICE_NAME: "{{ application }}"
ACCEPT_INVITATIONS: "true"
volumes:
- "{{ home_assistant_addons_dir }}/eufy-security-ws:/data"
- name: Create govee2mqtt container
ansible.builtin.include_role:
name: docker_container
vars:
name: govee2mqtt
image: ghcr.io/wez/govee2mqtt:latest
env:
GOVEE_EMAIL: govee{{ common_email_to }}
GOVEE_PASSWORD: !vault |
$ANSIBLE_VAULT;1.1;AES256
63626135336533336464663233333834663839333735346164636336306138383234373130666339
3638653662623462343666623664663864313562383430330a616631333435396536376531386234
63313266353363343031663036656634326661363766616137373736346666333032326365303334
6230363664313261300a373161353363656564613964323231666333613838636538306236353739
31613739653138396132363061613737643333363638623761353033396334623865
GOVEE_API_KEY: !vault |
$ANSIBLE_VAULT;1.1;AES256
30376266623532346465363265323737643431373664386430376532333665336261383830393330
3963383166626466653764316163636435383064343832330a303835613061663831353962616433
32376331303563623963313065363632656633393632303838363832336366336439363538636231
3761346139666433320a656130363838636537656631633266373361623463336233363136636439
39663838646335623339326136623861646633626461376233373935636134393830343532623966
6338613462656433343035393333663239323331316563303266
GOVEE_MQTT_HOST: "{{ mqtt_host }}"
GOVEE_MQTT_PORT: "{{ mqtt_port | string }}"
GOVEE_MQTT_USER: "govee2mqtt"
GOVEE_MQTT_PASSWORD: !vault |
$ANSIBLE_VAULT;1.1;AES256
34643464303164333833363364316261356339643035316664386263636538346462316532626435
3432373866383966383863326334333631326361313565390a326561333466623832626464633937
38323162366534663931303830363535363436613962313466393836363863656533323464373132
3865313737383932330a323138396666363061376335633832326530326634653032363535633033
39633232363530663238613331316432346634653661373063396135333937386532
TZ: "{{ common_timezone }}"
- name: Configure Automations
tags:
- automations
block:
- name: Split ui created automations
ansible.builtin.lineinfile:
dest: "{{ home_assistant_configuration }}"
search_string: 'automation: !include automations.yaml'
line: 'automation ui: !include automations.yaml'
state: present
notify: Restart
- name: Create custom automations folder
ansible.builtin.file:
path: "{{ home_assistant_automations_dir }}"
state: directory
owner: "{{ common_root_id }}"
group: "{{ common_root_group }}"
mode: "0771"
- name: Add custom automations folder to configuration
ansible.builtin.lineinfile:
dest: "{{ home_assistant_configuration }}"
line: 'automation custom: !include_dir_merge_list automations/'
state: present
notify: Restart
- name: Copy custom automations
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ home_assistant_automations_dir }}/{{ item | basename }}"
mode: "0644"
notify: Restart
with_fileglob:
- "{{ files_directory }}/automations/*.yaml"
- name: Template custom automations
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ home_assistant_automations_dir }}/{{ item | basename | regex_replace('\\.j2$', '') }}"
mode: "0644"
notify: Restart
with_fileglob:
- "{{ files_directory }}/automations/*.j2"
- name: Copy dashboard
tags:
- dashboard
ansible.posix.synchronize:
src: "{{ files_directory }}/ui_lovelace_minimalist/"
dest: "{{ config_directory }}/config/ui_lovelace_minimalist/"
delete: false
owner: false
group: false
perms: false
- name: Template dashboard items
tags:
- dashboard
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ config_directory }}/config/ui_lovelace_minimalist/dashboard/pages/{{ item | basename | regex_replace('\\.j2$', '') }}"
mode: "0644"
owner: "root"
group: "root"
with_fileglob:
- "{{ files_directory }}/ui_lovelace_minimalist/dashboard/pages/*.j2"
- name: Install HACS
community.docker.docker_container_exec:
container: "{{ application }}"
command: bash -c "wget -O - https://get.hacs.xyz | bash -"
chdir: /config
notify: Restart
register: _command_result
changed_when: "'HACS directory already exist' not in _command_result.stdout"
- name: Create pyscript folder
ansible.builtin.file:
path: "{{ config_directory }}/config/pyscript/"
state: directory
owner: "{{ common_root_id }}"
group: "{{ common_root_group }}"
mode: "0771"
- name: Copy pyscript scripts
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ config_directory }}/config/pyscript/{{ item | basename | regex_replace('\\.j2$', '') }}"
mode: "0644"
notify: Restart
with_fileglob:
- "{{ files_directory }}/pyscript/*"