-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.yaml
executable file
·575 lines (501 loc) · 14.5 KB
/
configuration.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
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
homeassistant:
# Name of the location where Home Assistant is running
name: !secret home_name
# Location required to calculate the time the sun rises and sets
latitude: !secret home_latitude
longitude: !secret home_longitude
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: !secret home_elevation
# metric for Metric, imperial for Imperial
unit_system: metric
# Localization
currency: !secret home_currency
country: !secret home_country
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: !secret home_timezone
# Customization file
customize: !include customize.yaml
# URLs
external_url: !secret external_url
internal_url: !secret internal_url
# Show links to resources in log and frontend
# introduction: false
# Enables the frontend
frontend:
extra_module_url:
- /local/plugins/card-mod.js?v=3.1.1
# Handles redirects from the My Home Assistant service.
my:
# Enables configuration UI
config:
# Enables the mobile companion app
mobile_app:
# Enable python scripts
python_script:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
http:
use_x_forwarded_for: true
trusted_proxies:
- !secret reverse_proxy_server
# Allows you to issue voice commands from the frontend in enabled browsers
conversation:
# Voice assistant
assist_pipeline:
# Required for text-to-speech
media_source:
# Enables support for tracking state changes over time
history:
exclude:
domains:
- automation
- updater
- camera
- device_tracker
- group
- input_text
- persistent_notification
- script
- sensor
- variable
entities:
- binary_sensor.updater
entity_globs:
- binary_sensor.macbook_pro_*
- binary_sensor.mqtt_*
- switch.*_sensor
- switch.ip_webcam
- sensor.mqtt_*
- sensor.*dimmer*
include:
domains:
- light
- binary_sensor
- switch
- sensor
- sun
- switch
- vacuum
entities:
- sensor.ip_webcam_motion
- sensor.oneplus_6t_geocoded_location
- media_player.tv
- device_tracker.oneplus_a6013
- binary_sensor.macbook_pro
- binary_sensor.macbook_pro_at_desk
# View all events in a logbook
logbook:
exclude:
domains:
- updater
- media_player
# Purge database regularly
recorder:
purge_keep_days: 7
exclude:
domains:
- automation
- updater
- camera
- group
- persistent_notification
- script
# Enables a map showing the location of tracked devices
map:
# Track the sun
sun:
# Global variables for templates
input_text:
video_url:
name: Video URL
initial: !secret magic_mirror_video
# MQTT Binary sensors
mqtt:
binary_sensor:
- name: Hallway motion sensor
state_topic: "home/OMG_lilygo_rtl_433_ESP/RTL_433toMQTT/Nexa-Security/1/25412630"
value_template: "{{ value_json.state }}"
payload_on: "ON"
payload_off: "OFF"
device_class: motion
- name: Bathroom motion sensor
state_topic: "home/OMG_lilygo_rtl_433_ESP/RTL_433toMQTT/Nexa-Security/1/29404962"
value_template: "{{ value_json.state }}"
payload_on: "ON"
payload_off: "OFF"
device_class: motion
event:
- name: Kids Room Remote
event_types:
- 'on'
- 'off'
state_topic: "home/OMG_lilygo_rtl_433_ESP/RTL_433toMQTT/Nexa-Security/3/32595538"
device_class: "button"
value_template: |
{
"button": "{{ value_json['id'] }}",
"unit": "{{ value_json['unit']}}",
"event_type": "{{ value_json['state'] | lower }}",
"group": {{ iif(value_json['group']) | to_json }}
}
# Template
template:
- binary_sensor:
- name: Bill Device On
state: >
{{ states("sensor.tasmota_bill_energy_power") | float(0) > 1 | float(0) }}
- name: MacBook Pro
state: >
{{ is_state('binary_sensor.macbook_pro_active', 'on')
or is_state('binary_sensor.macbook_pro_active_work', 'on')
}}
- name: MacBook Pro at desk
state: >
{{ not is_state('sensor.macbook_pro_internal_battery_state', 'Not Charging') }}
# Switches
switch:
- platform: wake_on_lan
name: Computer Power
mac: !secret computer_mac
host: !secret computer_ip
turn_off:
service: script.turn_computer_off
- platform: group
name: Speakers
entities:
- switch.speaker_left
- switch.speaker_right
- platform: group
name: Kitchen advent candlestick
entities:
- switch.tasmota_bub
- platform: group
name: Living room christmas tree
entities:
- switch.tasmota_bob
- platform: group
name: Bedroom advent candlestick
entities:
- switch.tasmota_bill
- platform: group
name: Magic mirror
entities:
- switch.galaxy_tab_s2_screen
- platform: template
switches:
tv_sound:
friendly_name: TV sound
value_template: "{{ is_state_attr('media_player.tv', 'is_volume_muted', 'true') }}"
turn_on:
service: script.toggle_tv_mute
turn_off:
service: script.toggle_tv_mute
hallway_camera:
friendly_name: Show hallway camera on TV
value_template: "{{ is_state_attr('media_player.google_tv', 'media_content_id', states('input_text.video_url')) }}"
turn_on:
service: script.cast_magic_mirror_camera
data:
media_player: media_player.google_tv
turn_off:
service: media_player.turn_off
data:
entity_id: media_player.google_tv
# Google Assistant - https://www.home-assistant.io/components/google_assistant
google_assistant:
project_id: !secret ga_project_id
service_account:
private_key: !secret ga_private_key
client_email: !secret ga_client_email
expose_by_default: false
entity_config:
# Bedroom
switch.bedroom_bedside_table_1:
name: Crib side light
room: Bedroom / Sovrum
expose: true
switch.bedroom_bedside_table_2:
name: Window side light
room: Bedroom / Sovrum
expose: true
switch.bedroom_sideboard_light:
name: Sideboard light
room: Bedroom / Sovrum
expose: true
# Hallway
switch.magic_mirror:
name: Magic Mirror
room: Hallway / Hallen
aliases:
- Mirror
expose: true
switch.hallway_sideboard_light:
name: Sideobard light
room: Hallway / Hallen
expose: true
switch.hallway_camera:
name: Hallway camera
room: Hallway / Hallen
aliases:
- Kameran i hallen
- Security camera
expose: true
# Kitchen
sensor.mqtt_kitchen_temperature:
name: Indoors temperature
room: Kitchen / Kök
aliases:
- Kitchen temperature
- Temperature
expose: true
# Balcony
sensor.balcony_climate_temperature:
name: Outdoors temperature
room: Balcony
aliases:
- Balcony temperature
- Outside temperature
- Temperature outdoors
- Temperature
expose: true
# Living room
media_player.tv:
name: Philips TV
room: LivingroomVardagsrum
aliases:
- TV Screen
expose: false
# Office
switch.computer_power:
name: Computer
room: Office
aliases:
- PC
expose: true
# Proxy stream
stream:
# Channge UI config mode
lovelace:
mode: yaml
resources:
- url: /local/plugins/slider-entity-row.js?v=17.2.1
type: module
- url: /local/plugins/fold-entity-row.js?v=2.0.14
type: module
- url: /local/plugins/button-card.js?v=3.4.2
type: module
- url: /local/plugins/homekit-panel-card.js?v=0.6.2
type: module
- url: /local/plugins/slider-button-card.js?v=1.10.3
type: module
- url: /local/plugins/vacuum-card.js?v=2.2.5
type: module
- url: /local/plugins/mini-media-player-bundle.js?v1.15.0
type: module
- url: /local/plugins/auto-entities.js?v1.9.1
type: module
# Text to speech
tts:
- platform: google_translate
service_name: google_say
# History stats
sensor:
- platform: history_stats
name: TV on time
entity_id: media_player.tv
state: "on"
type: time
start: "{{ 0 }}"
end: "{{ now() }}"
- platform: rest
name: Goodnight playlist story indexes
resource: !secret spotify_sectionize_url
verify_ssl: false
scan_interval: 14400
# Cloud
cloud:
# Wake on LAN
wake_on_lan:
# System health
system_health:
# For casting YouTube videos
media_extractor:
# Notify Group
notify:
- name: mobile_app
platform: group
services:
- service: !secret mobile_device_name
# Light groups
light:
- platform: group
name: Living Room Ceiling
entities:
- light.living_room_ceiling_1
- light.living_room_ceiling_2
- light.living_room_ceiling_3
- platform: group
name: Office lights
entities:
- light.office_top_corner
- light.office_spotlights
- light.office_desk_lamp
- platform: template
lights:
flic_twist:
friendly_name: Flic Twist
turn_on:
turn_off:
set_level:
service: media_player.volume_set
target:
entity_id: media_player.spotify_paq
data:
volume_level: "{{ (brightness / 255 * 100)|int / 100 }}"
office_lights_smart: &smart_light
friendly_name: "Office lights smart"
unique_id: office_lights_dimming
level_template: >
{{ (expand('group.office')
| map(attribute='attributes.brightness', default=0)
| select("greaterthan", 0)
| list or [0])
| average
| round }}
value_template: >
{{ expand('group.office')
| map(attribute='attributes.brightness', default=0)
| sum > 0 }}
temperature_template: >
{{ ((expand('group.office')
| map(attribute='attributes.color_temp', default=-1)
| select("greaterthan", 0)
| list or [0])| average | round) or Undefined }}
min_mireds_template: >
{{ expand('group.office')
| selectattr('domain', '==', 'light')
| selectattr('attributes.min_mireds')
| map(attribute='attributes.min_mireds')
| list | min | int }}
max_mireds_template: >
{{ expand('group.office')
| selectattr('domain', '==', 'light')
| selectattr('attributes.max_mireds')
| map(attribute='attributes.max_mireds')
| list | max | int }}
turn_on:
service: light.turn_on
target:
entity_id: group.office
turn_off:
service: light.turn_off
target:
entity_id: group.office
set_temperature:
- service: light.turn_on
data:
color_temp: "{{ color_temp }}"
target:
entity_id: >
{{ expand('group.office')
| selectattr('attributes.brightness')
| map(attribute='entity_id')
| list }}
set_level:
# Set brightness by amount to all lights (when all are off), OR only the lights that would remain on by the brightness change
- service: light.turn_on
data:
brightness_step: "{{ brightness - state_attr('light.office_lights_smart', 'brightness')|int }}"
target:
entity_id: >
{% set brightness_from = state_attr('light.office_lights_smart', 'brightness')|int %}
{% set brightness_change = brightness - brightness_from %}
{{ expand("group.office")
| selectattr('attributes.brightness')
| selectattr('attributes.brightness', '>', -brightness_change)
| map(attribute='entity_id')
| list or
expand('group.office')
| selectattr('domain', '==', 'light')
| map(attribute='entity_id')
| list if brightness != 255 else [] }}
# Set brightness to 1 for all lights that would turn off, keeping them on
- service: light.turn_on
data:
brightness_pct: 1
target:
entity_id: >
{% set brightness_from = state_attr('light.office_lights_smart', 'brightness')|int %}
{% set brightness_change = brightness - brightness_from %}
{{ expand('group.office')
| selectattr('attributes.brightness')
| selectattr('attributes.brightness', '<=', -brightness_change)
| map(attribute='entity_id')
| list
}}
# Set brightness to 100 for all lights currently on when slider moves to 100%, or all the lights if all are currently off
- service: light.turn_on
data:
brightness_pct: 100
target:
entity_id: >
{{ expand("group.office")
| selectattr('attributes.brightness')
| map(attribute='entity_id')
| list or
expand('group.office')
| selectattr('domain', '==', 'light')
| map(attribute='entity_id')
| list if brightness == 255 else [] }}
office_smart_lights_v:
<<: *smart_light
friendly_name: "Office lights smart V2"
unique_id: office_lights_dimming_v2
shell_command:
turn_off_computer: ssh {{ ssh_user }} net rpc shutdown -I {{ ip }} -U {{ user }} -t {{ timeout }}
# Variables
variable:
apartment_size:
value: !secret apartment_size
restore: true
spotify_user_name:
value: !secret spotify_user_name
restore: true
# Spotcast
spotcast:
sp_dc: !secret spotify_sp_dc
sp_key: !secret spotify_sp_key
## HELPERS
# Button
input_button:
# Counter
counter:
# Date/time
input_datetime:
# Select
input_select:
# Schedule
schedule:
# Timer
timer:
# Input numbers
input_number:
tv_volume:
name: TV Volume
initial: 8
min: 0
max: 16
step: 1
# Input booleans
input_boolean:
is_christmas_time:
name: Is Christmas time
icon: mdi:string-lights
# Includes
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
intent_script: !include intent_scripts.yaml
# TODO
# Add more security:
# Abort shutdown