-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.yaml
631 lines (574 loc) · 17.9 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
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
homeassistant:
name: Home
latitude: !secret latitude
longitude: !secret longitude
elevation: !secret elevation
time_zone: Asia/Shanghai
unit_system: metric
customize: !include customize.yaml
customize_domain:
climate:
icon: mdi:air-conditioner
packages: !include_dir_named packages
frontend:
themes: !include_dir_merge_named themes
lovelace:
mode: yaml
resources:
- url: /local/glance-card.js?v=2
type: module
- url: /local/mini-media-player.js?v=15
type: module
- url: /local/simple-thermostat.js?v=5
type: module
# - url: /local/slider-entity-row.js?v=7
# type: module
- url: /local/state-icon.js?v=8
type: module
- url: /local/zigbee2mqtt-networkmap.js?v=22
type: module
config:
http:
server_host: 127.0.0.1
use_x_forwarded_for: yes
trusted_proxies:
- 127.0.0.1
updater:
reporting: no
# discovery:
conversation:
intents:
TurnOnOff:
- (?P<action>打开|关闭|关掉)(?P<name>.+)
Query:
- (?P<name>温度|室内温度|室内湿度|室外温度|室外湿度|天气|空气|空气质量)
- 查看{name}
- 查询{name}
Rain:
- '{name}会下雨吗'
Know:
- '{who}认识{thing}吗'
Default:
- '{name}'
history:
# hotword_snowboy:
# model: snowboy/alexa.umdl
# sensitivity: 0.15
# apply_frontend: no
intent_script:
Default:
async_action: yes
speech:
text: &intent_default 不明白什么是{{ name }}
action:
- service: script.say
data_template:
message: *intent_default
Know:
async_action: yes
speech:
text: &intent_know >-
{{ who }}不认识{{ thing }}
action:
- service: script.say
data_template:
message: *intent_know
Query:
async_action: yes
speech:
text: &intent_query >-
{% if name == '温度' %}
室内{{ states('sensor.ht_bedroom_temperature') | round }}度,湿度{{ states('sensor.ht_bedroom_humidity') | round }}%。室外{{ states('sensor.dark_sky_apparent_temperature') | round }}度,湿度{{ states('sensor.dark_sky_humidity') | round }}%
{% elif name == '室内温度' %}
室内{{ states('sensor.ht_bedroom_temperature') | round }}度
{% elif name == '室内湿度' %}
室内湿度{{ states('sensor.ht_bedroom_humidity') | round }}%
{% elif name == '室外温度' %}
室外{{ states('sensor.dark_sky_apparent_temperature') | round }}度
{% elif name == '室外湿度' %}
室外湿度{{ states('sensor.dark_sky_humidity') | round }}%
{% elif name == '天气' %}
当前{{ states('sensor.dark_sky_summary') }},
{% if now().hour <= 14 %}
今天最高{{ states('sensor.dark_sky_daytime_high_apparent_temperature') | round }}度,
{% set percent = states('sensor.dark_sky_precip_probability') | round %}
{% if percent > 0 %}
降水可能性{{ percent }}%。
{% endif %}
{% else %}
明天最高{{ states('sensor.dark_sky_daytime_high_apparent_temperature_1') | round }}度,
{% set percent = states('sensor.dark_sky_precip_probability_1') | round %}
{% if percent > 0 %}
降水可能性{{ percent }}%。
{% endif %}
{% endif %}
{{ states('sensor.dark_sky_hourly_summary') }}
未来一周{{ states('sensor.dark_sky_daily_summary') | regex_replace('°C', '度') }}
{% elif name | regex_match('空气') %}
{% set aqi = states('sensor.us_air_quality_index') | int %}
当前空气质量
{% if aqi == 0 %}
未知
{% elif aqi <= 50 %}
优
{% elif aqi <= 100 %}
良
{% elif aqi <= 150 %}
轻度污染
{% elif aqi <= 200 %}
中度污染
{% elif aqi <= 300 %}
重度污染
{% else %}
严重污染
{% endif %}
{% else %}
查询不到{{ name }}
{% endif %}
action:
- service: script.say
data_template:
message: *intent_query
Rain:
async_action: yes
speech:
text: &intent_rain >-
{% set map = {
'今天': 'sensor.dark_sky_precip_probability',
'明天': 'sensor.dark_sky_precip_probability_1'
}%}
{% set sensor = map[name] | default(None) %}
{% if sensor %}
{% set percent = states(sensor) | round %}
{% if percent == 0 %}
{{ name }}应该不会下雨
{% else %}
{{ name }}降水可能性{{ percent }}%
{% endif %}
{% else %}
查询不到{{ name }}会不会下雨
{% endif %}
action:
- service: script.say
data_template:
message: *intent_rain
TurnOnOff:
async_action: yes
speech:
text: &intent_turn_on_off >-
{% if name | regex_match('电视|客厅|吸顶|卧室|空调|热水|阅读|看书|月光') %}
已{{ action }}{{ name }}
{% else %}
找不到{{ name }}
{% endif %}
action:
- service: script.say
data_template:
message: *intent_turn_on_off
- service_template: homeassistant.turn_{% if action == '打开' %}on{% else %}off{% endif %}
data_template:
entity_id: >-
{% if name | regex_match('电视') %}
media_player.tv
{% elif name | regex_match('客厅|吸顶') %}
light.living_room
{% elif name | regex_match('卧室') %}
light.bedroom
{% elif name | regex_match('空调') %}
climate.bedroom
{% elif name | regex_match('热水') %}
switch.water_heater
{% elif name | regex_match('阅读|看书') %}
switch.reading_living_room
{% elif name | regex_match('月光') %}
switch.moonlight_living_room
{% else %}
input_boolean.dummy
{% endif %}
logbook:
# map:
sun:
sensor:
- platform: darksky
latitude: !secret alt_latitude
longitude: !secret alt_longitude
language: zh
api_key: !secret darksky_api_key
scan_interval: '00:10:00'
forecast:
- 1
monitored_conditions:
- apparent_temperature
- apparent_temperature_high
- apparent_temperature_low
- daily_summary
- hourly_summary
- humidity
- precip_probability
- precip_type
- summary
- platform: derivative
name: Climate bedroom temperature change
source: sensor.ht_climate_bedroom_temperature
unit_time: min
# time_window: '00:10:00'
- platform: mqtt
name: Zigbee2mqtt Networkmap
state_topic: zigbee2mqtt/bridge/networkmap/raw
value_template: >-
{{ now().strftime('%Y-%m-%d %H:%M:%S') }}
json_attributes_topic: zigbee2mqtt/bridge/networkmap/raw
- platform: season
type: meteorological
- platform: systemmonitor
resources:
- type: disk_use_percent
arg: /home
- platform: template
sensors:
climate_bedroom_mode:
value_template: >-
{% set climate = states('sensor.ht_climate_bedroom_temperature') | float %}
{% set air = states('sensor.ht_bedroom_temperature') | float %}
{% set diff = climate - air %}
{% set change = states('sensor.climate_bedroom_temperature_change') | float %}
{% if not is_state('device_tracker.broadlink', 'home') %}
unavailable
{% elif change >= 0.5 %}
{% if diff > 0 %}
heat
{% else %}
off
{% endif %}
{% elif change < 1 and change >= 0 %}
{% if diff > 10 and climate > 30 %}
heat
{% else %}
off
{% endif %}
{% elif change < 0 and change >= -0.5 %}
{% if diff < -0.3 and climate < 26 %}
cool
{% else %}
off
{% endif %}
{% else %} {# change < -0.5 #}
{% if diff < 0 %}
cool
{% else %}
off
{% endif %}
{% endif %}
- platform: waqi
token: !secret waqi_token
locations:
- !secret waqi_location
# - platform: yr
# monitored_conditions:
# - humidity
# - symbol
# - temperature
tts:
- platform: google_translate
language: zh-cn
aligenie:
expire_hours: 8640
binary_sensor:
# - platform: bayesian
# name: Occupancy living room
# prior: 0.5
# probability_threshold: 0.8
# device_class: occupancy
# observations:
# - platform: state
# entity_id: binary_sensor.motion_living_room
# prob_given_true: 0.9
# to_state: 'on'
# - platform: state
# entity_id: binary_sensor.motion_dining_room
# prob_given_true: 0.9
# to_state: 'on'
# - platform: state
# entity_id: binary_sensor.motion_sofas
# prob_given_true: 0.9
# to_state: 'on'
- platform: mqtt
name: mqtt_motion_sofas
state_topic: motion/sofas
device_class: motion
- platform: template
sensors:
motion_sofas:
friendly_name: Motion sofas
value_template: >-
{{ is_state('binary_sensor.mqtt_motion_sofas', 'on') }}
delay_off: '00:05:00'
device_class: motion
occupancy_living_room:
friendly_name: Occupancy living room
value_template: >-
{% if is_state('binary_sensor.motion_dining_room', 'on')
or is_state('binary_sensor.motion_living_room', 'on')
or states('sensor.plug_power') | float >= 1 %}
true
{% elif is_state('binary_sensor.motion_dining_room', 'off')
and is_state('binary_sensor.motion_living_room', 'off')
and is_state('binary_sensor.motion_sofas', 'off') %}
false
{% else %}
{{ states('binary_sensor.occupancy_living_room') }}
{% endif %}
device_class: occupancy
camera:
- platform: mjpeg
mjpeg_url: http://127.0.0.1:8081
name: Living room
climate:
- platform: xiaomi_miio_airconditioningcompanion
name: AC partner
host: !secret ac_partner_host
token: !secret ac_partner_token
target_sensor: sensor.ht_bedroom_temperature
- platform: smartir
name: Bedroom
device_code: 1180
controller_data: remote.broadlink1_remote
temperature_sensor: sensor.ht_bedroom_temperature
humidity_sensor: sensor.ht_bedroom_humidity
mode_sensor: sensor.climate_bedroom_mode
device_tracker:
- platform: ubus
host: !secret ubus_host_1
username: !secret ubus_username
password: !secret ubus_password
dhcp_software: none
consider_home: 20
new_device_defaults:
track_new_devices: no
- platform: ubus
host: !secret ubus_host_2
username: !secret ubus_username
password: !secret ubus_password
dhcp_software: none
consider_home: 20
new_device_defaults:
track_new_devices: no
input_boolean:
dummy:
yeelight:
devices:
!secret yeelight_living_room_host:
name: Living room
model: ceiling4
transition: 1000
!secret yeelight_bedroom_host:
name: Bedroom
model: ceiling3
transition: 1000
!secret yeelight_kitchen_host:
name: Kitchen
model: mono1
transition: 1000
media_player:
- platform: braviatv_psk
name: TV
host: !secret braviatv_host
mac: !secret braviatv_mac
psk: !secret braviatv_psk
- platform: vlc
mqtt:
discovery: yes
broker: 127.0.0.1
username: local
password: local
birth_message:
topic: hass/status
payload: online
will_message:
topic: hass/status
payload: offline
notify:
- name: html5
platform: html5
vapid_pub_key: !secret vapid_pub_key
vapid_prv_key: !secret vapid_prv_key
vapid_email: !secret vapid_email
owntracks:
max_gps_accuracy: 200
paplay:
pulseaudio: yes
person:
recorder:
db_url: postgresql://@/hass
exclude:
entities:
- binary_sensor.mqtt_motion_sofas
- climate.ac_partner
smartir:
check_updates: no
switch:
- platform: template
switches:
light_living_room:
friendly_name: Light living room
value_template: >-
{{ is_state('light.living_room', 'on') }}
turn_on:
service: light.turn_on
data_template:
entity_id: light.living_room
brightness: >-
{% if now().hour >= 12 or state_attr('sun.sun', 'elevation') > 3 %}
255
{% else %}
1
{% endif %}
kelvin: >-
{% if now().hour >= 12 or state_attr('sun.sun', 'elevation') > 3 %}
6500
{% else %}
2700
{% endif %}
turn_off:
service: light.turn_off
data:
entity_id: light.living_room
reading_living_room:
friendly_name: Reading living room
value_template: >-
{{ is_state('light.living_room', 'on') and state_attr('light.living_room', 'brightness') >= 200 }}
icon_template: mdi:book-open-page-variant
turn_on:
service: light.turn_on
data:
entity_id: light.living_room
brightness: 240
kelvin: 6500
transition: 5
turn_off:
service: light.turn_on
data:
entity_id: light.living_room
brightness: 162
kelvin: 6500
transition: 5
moonlight_bedroom:
friendly_name: Moonlight bedroom
value_template: >-
{{ is_state('binary_sensor.bedroom_nightlight', 'on') and is_state('light.bedroom', 'on') }}
icon_template: mdi:weather-night
turn_on:
service: yeelight.set_mode
data:
entity_id: light.bedroom
mode: moonlight
turn_off:
service: yeelight.set_mode
data:
entity_id: light.bedroom
mode: normal
moonlight_living_room:
friendly_name: Moonlight living room
value_template: >-
{{ is_state('binary_sensor.living_room_nightlight', 'on') and is_state('light.living_room', 'on') }}
icon_template: mdi:weather-night
turn_on:
service: yeelight.set_mode
data:
entity_id: light.living_room
mode: moonlight
turn_off:
service: yeelight.set_mode
data:
entity_id: light.living_room
mode: normal
water_heater:
friendly_name: Water heater
value_template: >-
{{ state_attr('climate.ac_partner', 'load_power') | int > 100 }}
icon_template: mdi:fire
turn_on:
- &water_heater_condition
condition: template
value_template: >-
{{ state_attr('climate.ac_partner', 'load_power') | int < 100 }}
- &water_heater_heating
service: xiaomi_miio_airconditioningcompanion.climate_send_command
data:
command: FE00000000000000000000000006002E2254003600A901C403860D6D138832000100010100000001000000000100010000010101000101010101000100000001000001000101010001043205C4
- &water_heater_wait
delay: '00:00:03'
- &water_heater_update
service: homeassistant.update_entity
entity_id: climate.ac_partner
- *water_heater_condition
- &water_heater_power
service: xiaomi_miio_airconditioningcompanion.climate_send_command
data:
command: FE00000000000000000000000005002C2251003600A801C403841388320001000101000000010000000001000100000101010001010101000100000000010001000101010100010410
- &water_heater_delay
delay: '00:00:01'
- *water_heater_heating
- *water_heater_wait
- *water_heater_update
- *water_heater_condition
- *water_heater_power
- *water_heater_delay
- *water_heater_heating
- *water_heater_wait
- *water_heater_update
- *water_heater_condition
- condition: time
after: '16:29'
before: '16:31'
- service: notify.html5
data:
message: Failed to turn on water heater
turn_off:
- condition: template
value_template: >-
{{ state_attr('climate.ac_partner', 'load_power') | int > 100 }}
- *water_heater_heating
- *water_heater_wait
- *water_heater_update
weather:
- platform: darksky
name: Hangzhou
mode: daily
api_key: !secret darksky_api_key
latitude: !secret alt_latitude
longitude: !secret alt_longitude
# web_speech:
# chrome_extra_args: --enable-low-end-device-mode --no-sandbox
# cleanup: yes
# lang: cmn-Hans-CN
# pulseaudio: yes
# xvfb: yes
# xiaomi_aqara:
# interface: !secret interface
# gateways:
# - mac: !secret ac_partner_mac
# key: !secret ac_partner_key
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
zone: !include zones.yaml
logger:
default: warning
logs:
custom_components.aligenie: debug
homeassistant.components.switch.broadlink: info
homeassistant.components.yeelight: critical
urllib3.connectionpool: critical
# custom_components.derivative.sensor: debug
# custom_components.hotword_snowboy: debug
# custom_components.rhasspy_train: debug
# custom_components.smartir.climate: debug
# custom_components.stt_pocketsphinx: debug
# custom_components.web_speech: debug
# custom_components.xiaomi_miio_airconditioningcompanion.climate: debug
# miio: debug
# homeassistant.components.binary_sensor.xiaomi_aqara: debug
# homeassistant.components.device_tracker: debug
# homeassistant.components.xiaomi_aqara: debug
# xiaomi_gateway: debug