-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathsystem_monitoring.yaml
executable file
·1198 lines (1178 loc) · 40.5 KB
/
system_monitoring.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
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
################################
# Proxmox for VM running on NUC
################################
proxmoxve:
host: 10.10.5.10
username: !secret pve_user
password: !secret pve_pass
realm: pve
verify_ssl: false
nodes:
- node: pve
vms:
- 102
- 103
- 110
- 120
###############################
# Monitoring Docker Containers
###############################
monitor_docker:
- name: Docker
containers:
- appdaemon
- esphome-dashboard
- hass
- hass-db
- mqtt
- influxdb
- grafana
- portainer
- unifi-poller
- swag
- snapserver
rename:
appdaemon: AppDaemon
esphome-dashboard: "ESPHome-Dashboard"
hass: Home Assistant
hass-db: Home Assistant DB
mqtt: Mosquitto
influxdb: InfluxDB
grafana: Grafana
portainer: Portainer
unifi-poller: "Unifi-Poller"
swag: NGINX
snapserver: Snapserver
monitored_conditions:
- version
- status
- image
- cpu_percentage
- memory_percentage
sensor:
################
# Date and Time
################
- platform: time_date
display_options:
- time
- date
- date_time
- date_time_iso
- time_date
- time_utc
- beat
########################
# SystemMonitor for NUC
########################
- platform: systemmonitor
resources:
- type: disk_use_percent
arg: /home
- type: disk_use
arg: /home
- type: disk_free
arg: /home
- type: memory_free
- type: memory_use
- type: memory_use_percent
- type: swap_use_percent
- type: swap_use
- type: swap_free
- type: load_1m
- type: load_5m
- type: load_15m
- type: network_in
arg: ens18
- type: network_out
arg: ens18
- type: throughput_network_in
arg: ens18
- type: throughput_network_out
arg: ens18
- type: packets_in
arg: ens18
- type: packets_out
arg: ens18
- type: processor_use
- type: last_boot
- type: ipv4_address
arg: ens18
##################
# Temperature NUC
##################
- platform: command_line
name: temperature_cpu_nuc
command: 'ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] cat /sys/class/thermal/thermal_zone3/temp'
value_template: "{{ value | int / 1000 }}"
unit_of_measurement: "°C"
###################
# Home Assitant DB Size
###################
- platform: sql
db_url: !secret db_url
queries:
- name: DB size Hass
query: "SELECT (pg_database_size('smart_home')/1024/1024) as db_size;"
column: "db_size"
unit_of_measurement: MB
####################
# Software Versions
####################
# Home Assistant
- platform: version
name: latest_version_homeassistant
source: docker
beta: true
- platform: version
name: current_version_homeassistant
# AppDaemon
- platform: command_line
name: latest_version_appdaemon
command: >-
curl -L
-H "User-Agent: Home Assistant"
-H "Content-Type: application/json"
https://pypi.python.org/pypi/appdaemon/json
value_template: '{{ value_json.info.version }}'
scan_interval: 3600
# Pi-hole
## Pi-hole Core
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: latest_version_pihole_core
value_template: "{{ value_json.core_latest[1:] }}"
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: current_version_pihole_core
value_template: "{{ value_json.core_current[1:] }}"
## Pi-hole Web
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: latest_version_pihole_web
value_template: "{{ value_json.web_latest[1:] }}"
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: current_version_pihole_web
value_template: "{{ value_json.web_current[1:] }}"
## Pi-hole FTL
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: latest_version_pihole_ftl
value_template: "{{ value_json.FTL_latest[1:] }}"
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: current_version_pihole_ftl
value_template: "{{ value_json.FTL_current[1:] }}"
# Mosquitto
- platform: mqtt
state_topic: "docker-image-updates/mosquitto"
name: Update Mosquitto
# ESP Home
- platform: mqtt
state_topic: "docker-image-updates/esphome"
name: Update ESPHome
# Grafana
- platform: mqtt
state_topic: "docker-image-updates/grafana"
name: Update Grafana
# InfluxDB
- platform: mqtt
state_topic: "docker-image-updates/influxdb"
name: Update InfluxDB
# UniFi Poller
- platform: mqtt
state_topic: "docker-image-updates/unifi-poller"
name: Update UniFi Poller
# Portainer
- platform: mqtt
state_topic: "docker-image-updates/portainer"
name: Update Portainer
# Swag
- platform: mqtt
state_topic: "docker-image-updates/swag"
name: Update Swag
# Proxmox
- platform: command_line
name: Version Proxmox VE
command: 'ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] pveversion | cut -f2 -d/'
scan_interval: 3600
###############
# Backup Synology NAS
###############
# Model
- platform: snmp
name: Model Backup NAS
host: 10.10.40.15
community: 'public'
baseoid: 1.3.6.1.4.1.6574.1.5.1.0
# Firmware
- platform: snmp
name: Firmware Backup NAS
host: 10.10.40.15
community: 'public'
baseoid: 1.3.6.1.4.1.6574.1.5.3.0
# Uptime
- platform: snmp
name: Uptime Backup NAS
host: 10.10.40.15
community: 'public'
baseoid: 1.3.6.1.2.1.25.1.1.0
value_template: >
{%- set time = value | int // 100 %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
###############
# Main Synology NAS
###############
# Model
- platform: snmp
name: Model NAS
host: 10.10.40.80
community: 'public'
baseoid: 1.3.6.1.4.1.6574.1.5.1.0
# Firmware
- platform: snmp
name: Firmware NAS
host: 10.10.40.80
community: 'public'
baseoid: 1.3.6.1.4.1.6574.1.5.3.0
# Uptime
- platform: snmp
name: Uptime NAS
host: 10.10.40.80
community: 'public'
baseoid: 1.3.6.1.2.1.25.1.1.0
value_template: >
{%- set time = value | int // 100 %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
################
# Unifi Devices
################
# AP Livingroom
## Model
- platform: snmp
name: Model AP livingroom
host: 10.10.0.14
community: 'public'
baseoid: 1.3.6.1.4.1.41112.1.6.3.3.0
## Uptime
- platform: snmp
name: Uptime AP livingroom
host: 10.10.0.14
community: 'public'
baseoid: 1.3.6.1.2.1.1.3.0
value_template: >
{%- set time = value | int // 100 %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
## Firmware
- platform: snmp
name: Firmware AP livingroom
host: 10.10.0.14
community: 'public'
baseoid: 1.3.6.1.4.1.41112.1.6.3.6.0
## Firmware Upgrade Available
- platform: template
sensors:
firmware_upgrade_ap_livingroom:
friendly_name: Firmware Upgrade AP Wohnzimmer
value_template: >
{{ 'Update available' if state_attr('device_tracker.ap_livingroom', 'upgradable') == true else 'Up-to-date' }}
# Switch Livingroom
## Temperature
- platform: snmp
name: Temperature Switch Livingroom
host: 10.10.0.6
community: 'public'
baseoid: 1.3.6.1.4.1.4413.1.1.43.1.8.1.5.1.0
unit_of_measurement: "°C"
## Uptime
- platform: snmp
name: Uptime Switch Livingroom
host: 10.10.0.6
community: 'public'
baseoid: 1.3.6.1.2.1.1.3.0
value_template: >
{%- set time = value | int // 100 %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
## Model
- platform: snmp
name: Model Switch Livingroom
host: 10.10.0.6
community: 'public'
baseoid: 1.3.6.1.4.1.4413.1.1.1.1.1.2.0
## Firmware
- platform: snmp
name: Firmware Switch Livingroom
host: 10.10.0.6
community: 'public'
baseoid: 1.3.6.1.4.1.4413.1.1.1.1.1.13.0
## Firmware Upgrade Available
- platform: template
sensors:
firmware_upgrade_switch_livingroom:
friendly_name: Firmware Upgrade Switch Wohnzimmer
value_template: >
{{ 'Update available' if state_attr('device_tracker.switch_livingroom', 'upgradable') == true else 'Up-to-date' }}
# Switch Storageroom
## Uptime
- platform: snmp
name: Uptime Switch Storageroom
host: 10.10.0.10
community: 'public'
baseoid: 1.3.6.1.2.1.1.3.0
value_template: >
{%- set time = value | int // 100 %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
## Model
- platform: snmp
name: Model Switch Storageroom
host: 10.10.0.10
community: 'public'
baseoid: 1.3.6.1.4.1.4413.1.1.1.1.1.2.0
## Firmware
- platform: snmp
name: Firmware Switch Storageroom
host: 10.10.0.10
community: 'public'
baseoid: 1.3.6.1.4.1.4413.1.1.1.1.1.13.0
## Firmware Upgrade Available
- platform: template
sensors:
firmware_upgrade_switch_storageroom:
friendly_name: Firmware Upgrade Switch Reduit
value_template: >
{{ 'Update available' if state_attr('device_tracker.switch_storageroom', 'upgradable') == true else 'Up-to-date' }}
# USG Router Livingroom
## CPU 1 min
- platform: snmp
name: cpu_load_1m_usg
host: 10.10.0.1
community: 'public'
baseoid: 1.3.6.1.4.1.2021.10.1.3.1
value_template: "{{ ( value | float * 100 )| int }}"
unit_of_measurement: "%"
## CPU 5 mins
- platform: snmp
name: cpu_load_5m_usg
host: 10.10.0.1
community: 'public'
baseoid: 1.3.6.1.4.1.2021.10.1.3.2
value_template: "{{ ( value | float * 100 )| int }}"
unit_of_measurement: "%"
## CPU 15 mins
- platform: snmp
name: cpu_load_15m_usg
host: 10.10.0.1
community: 'public'
baseoid: 1.3.6.1.4.1.2021.10.1.3.3
value_template: "{{ ( value | float * 100 )| int }}"
unit_of_measurement: "%"
## CPU 0 Load
- platform: snmp
name: cpu_0_load_usg
host: 10.10.0.1
community: 'public'
baseoid: 1.3.6.1.2.1.25.3.3.1.2.196608
unit_of_measurement: "%"
## CPU 1 Load
- platform: snmp
name: cpu_1_load_usg
host: 10.10.0.1
community: 'public'
baseoid: 1.3.6.1.2.1.25.3.3.1.2.196609
unit_of_measurement: "%"
### CPU Load average
- platform: min_max
name: cpu_load_usg
type: mean
entity_ids:
- sensor.cpu_0_load_usg
- sensor.cpu_1_load_usg
## Uptime
- platform: snmp
name: Uptime USG
host: 10.10.0.1
community: 'public'
baseoid: 1.3.6.1.2.1.1.3.0
value_template: >
{%- set time = value | int // 100 %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
## Firmware
- platform: snmp
name: Firmware USG
host: 10.10.0.1
community: 'public'
baseoid: 1.3.6.1.2.1.1.1.0
value_template: "{{ '.'.join(value.split('.')[:3]) }}"
## Firmware Upgrade Available
- platform: template
sensors:
firmware_upgrade_usg_router:
friendly_name: Firmware Upgrade USG Router
value_template: >
{{ 'Update available' if state_attr('device_tracker.usg_router', 'upgradable') == true else 'Up-to-date' }}
## WAN In
- platform: snmp
name: WAN In USG
host: 10.10.0.1
baseoid: 1.3.6.1.2.1.31.1.1.1.6.2
community: 'public'
version: '2c'
scan_interval: 10
- platform: derivative
source: sensor.wan_in_usg
unit_time: s
unit: B
name: wan_in_usg_derivative
- platform: template
sensors:
wan_in_usg_mbps:
value_template: "{{ ((states('sensor.wan_in_usg_derivative')|float*8)/1000000)|round(2) }}"
unit_of_measurement: 'Mbps'
friendly_name: WAN In USG Mbps
## WAN Out
- platform: snmp
name: WAN Out USG
host: 10.10.0.1
baseoid: 1.3.6.1.2.1.31.1.1.1.10.2
community: 'public'
version: '2c'
scan_interval: 10
- platform: derivative
source: sensor.wan_out_usg
unit_time: s
unit: B
name: wan_out_usg_derivative
- platform: template
sensors:
wan_out_usg_mbps:
value_template: "{{ ((states('sensor.wan_out_usg_derivative')|float*8)/1000000)|round(2) }}"
unit_of_measurement: 'Mbps'
friendly_name: WAN Out USG Mbps
#####################
# ConBee/DeCONZ
#####################
# ConBee Firmware
- platform: rest
resource: http://10.10.40.50:8080/api/7E79D96650/config
name: current_firmware_conbee
value_template: "{{ value_json.fwversion }}"
scan_interval: 3600
# DeCONZ current
- platform: rest
resource: http://10.10.40.50:8080/api/7E79D96650/config
name: current_version_deconz
value_template: "{{ value_json.swversion }}"
scan_interval: 3600
# DeCONZ latest
- platform: rest
resource: https://api.github.com/repos/dresden-elektronik/deconz-rest-plugin/releases/latest
name: latest_version_deconz
value_template: >
{{ value_json.tag_name.strip('_stable').lstrip('V').replace('_','.').replace('0','') }}
scan_interval: 3600
######################
# Last Boot to Uptime
######################
# Home Assistant VM
- platform: template
sensors:
uptime_home_assistant_vm:
friendly_name: Uptime Home Assistant VM
value_template: >
{%- set last_boot = states('sensor.last_boot_ha_vm') %}
{%- if last_boot in ['unavailable', 'unknown'] or last_boot is none %}
unknown
{%- else %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
{%- endif %}
# Network Pi
- platform: template
sensors:
uptime_pi_network:
friendly_name: Uptime Pi Netzwerk
value_template: >
{%- set last_boot = states('sensor.last_boot_pi_network') %}
{%- if last_boot in ['unavailable', 'unknown'] or last_boot is none %}
unknown
{%- else %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
{%- endif %}
# ZigBee/Z-Wave Pi
- platform: template
sensors:
uptime_pi_zigbee_zwave:
friendly_name: Uptime Pi ZigBee/ZWave
value_template: >
{%- set last_boot = states('sensor.last_boot_pi_zigbee_zwave') %}
{%- if last_boot in ['unavailable', 'unknown'] or last_boot is none %}
unknown
{%- else %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
{%- endif %}
# Office Pi
- platform: template
sensors:
uptime_pi_office:
friendly_name: Uptime Pi Büro
value_template: >
{%- set last_boot = states('sensor.last_boot_pi_office') %}
{%- if last_boot in ['unavailable', 'unknown'] or last_boot is none %}
unknown
{%- else %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
{%- endif %}
# Pi Livingroom
- platform: template
sensors:
uptime_pi_livingroom:
friendly_name: Uptime Pi Wohnzimmer
value_template: >
{%- set last_boot = states('sensor.last_boot_pi_livingroom') %}
{%- if last_boot in ['unavailable', 'unknown'] or last_boot is none %}
unknown
{%- else %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
{%- endif %}
# Dressroom Pi
- platform: template
sensors:
uptime_pi_dressroom:
friendly_name: Uptime Pi Ankleidezimmer
value_template: >
{%- set last_boot = states('sensor.last_boot_pi_dressroom') %}
{%- if last_boot in ['unavailable', 'unknown'] or last_boot is none %}
unknown
{%- else %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
{%- endif %}
# Small Bathroom Pi
- platform: template
sensors:
uptime_pi_bathroomsmall:
friendly_name: Uptime Pi Kleines Bad
value_template: >
{%- set last_boot = states('sensor.last_boot_pi_bathroomsmall') %}
{%- if last_boot in ['unavailable', 'unknown'] or last_boot is none %}
unknown
{%- else %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
{%- endif %}
#####################
# Healthchecks.io
#####################
# Home Assistant Heartbeat
- platform: rest
resource: !secret healthcheck_heartbeat
name: Home Assistant Heartbeat
scan_interval: 300
# Healthcheck.io Status
# Backups
## Home Assistant VM Status
- platform: rest
resource: !secret healthcheck_daily_backup_ha
name: Daily Backup Home Assistant VM
headers:
X-Api-Key: !secret healthcheck_api_key
scan_interval: 1800
value_template: "{{ value_json.status }}"
## Home Assistant VM Last Backup
- platform: rest
resource: !secret healthcheck_daily_backup_ha
name: Last Backup Home Assistant VM
headers:
X-Api-Key: !secret healthcheck_api_key
scan_interval: 1800
value_template: >
{%- set last_boot = value_json.last_ping %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
## Network Pi Status
- platform: rest
resource: !secret healthcheck_monthly_backup_network_pi
name: Monthly Backup Network Pi
headers:
X-Api-Key: !secret healthcheck_api_key
scan_interval: 1800
value_template: "{{ value_json.status }}"
## Network Pi Last Backup
- platform: rest
resource: !secret healthcheck_monthly_backup_network_pi
name: Last Backup Network Pi
headers:
X-Api-Key: !secret healthcheck_api_key
scan_interval: 1800
value_template: >
{%- set last_boot = value_json.last_ping %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
## ZigBee Zwave Pi Status
- platform: rest
resource: !secret healthcheck_monthly_backup_zigbeezwave_pi
name: Monthly Backup ZigBee Zwave Pi
headers:
X-Api-Key: !secret healthcheck_api_key
scan_interval: 1800
value_template: "{{ value_json.status }}"
## ZigBee Zwave Pi Last Backup
- platform: rest
resource: !secret healthcheck_monthly_backup_zigbeezwave_pi
name: Last Backup ZigBee Zwave Pi
headers:
X-Api-Key: !secret healthcheck_api_key
scan_interval: 1800
value_template: >
{%- set last_boot = value_json.last_ping %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
#####################
# Logger integration
#####################
logger:
default: warning
input_select:
####################
# Default Log Level
####################
default_log_level:
name: Log Level
options:
- critical
- fatal
- error
- warning
- warn
- info
- debug
- notset
icon: mdi:math-log
automation:
# Set Default Log Level
- alias: "Set Default Log Level"
initial_state: true
trigger:
platform: state
entity_id: input_select.default_log_level
action:
service: logger.set_default_level
data:
level: "{{ trigger.to_state.state }}"
mode: single
# Notify on update available
- id: notify_on_update_available
alias: "Benachrichtigung wenn ein Update verfügbar ist"
mode: parallel
trigger:
- platform: state
entity_id:
- sensor.update_esphome
- sensor.update_mosquitto
- sensor.update_influxdb
- sensor.update_grafana
- sensor.update_portainer
- sensor.update_unifi_poller
- sensor.update_swag
- sensor.firmware_upgrade_usg_router
- sensor.firmware_upgrade_ap_livingroom
- sensor.firmware_upgrade_switch_livingroom
- sensor.firmware_upgrade_switch_storageroom
to: "Update available"
- platform: numeric_state
entity_id:
- sensor.updates_pi_bathroomsmall
- sensor.updates_pi_livingroom
- sensor.updates_pi_dressroom
- sensor.updates_pi_zigbee_zwave
- sensor.updates_pi_network
- sensor.updates_pi_office
- sensor.hacs
above: 1
- platform: state
entity_id:
- binary_sensor.backup_nas_update_available
- binary_sensor.nas_update_available
to: 'on'
- platform: template
value_template: >
{{ states('sensor.latest_version_deconz') > states('sensor.current_version_deconz') or
states('sensor.latest_version_homeassistant') > states('sensor.current_version_homeassistant') or
states('sensor.latest_version_pihole_core') > states('sensor.current_version_pihole_core') or
states('sensor.latest_version_pihole_ftl') > states('sensor.current_version_pihole_ftl') or
states('sensor.latest_version_pihole_web') > states('sensor.current_version_pihole_web') }}
condition:
- "{{ trigger.from_state.state != trigger.to_state.state }}"
- "{{ trigger.from_state.state not in ['unavailable', 'unknown', 'None'] }}"
- "{{ trigger.to_state.state not in ['unavailable', 'unknown', 'None'] }}"
action:
- variables:
name: "{{ state_attr(trigger.to_state.entity_id, 'friendly_name') }}"
- choose:
# IF desktop is running notify phone
- conditions: "{{ is_state('device_tracker.desktop_dimitri', 'home') }}"
sequence:
- service: notify.mobile_app_phone_dimitri
data:
title: "{{ name }}"
message: "📥 Update verfügbar"
# ELSE create a task in Evernote
default:
- service: notify.evernote
data:
title: "{{ name }} @1 Next #!Heute #@computer"
message: "Update planen"
# Notify on low battery level
- id: notify_on_low_battery_level
alias: "Benachrichtigung wenn Batterien bald leer sind"
mode: parallel
trigger:
- platform: numeric_state
entity_id:
- sensor.battery_level_door_bathroomlarge
- sensor.battery_level_door_bathroomsmall
- sensor.battery_level_door_bedroom
- sensor.battery_level_door_dressroom
- sensor.battery_level_door_kitchen
- sensor.battery_level_door_livingroom
- sensor.battery_level_door_main
- sensor.battery_level_door_office
- sensor.battery_level_door_storageroom
- sensor.battery_level_lux_office
- sensor.battery_level_lux_outside
- sensor.battery_level_motion_livingroom
- sensor.battery_level_multisensor_bathroomsmall
- sensor.battery_level_multisensor_bedroom
- sensor.battery_level_multisensor_dressroom
- sensor.battery_level_remote_dimitri
- sensor.battery_level_remote_light_bedroom
- sensor.battery_level_remote_light_dressroom
- sensor.battery_level_remote_light_livingroom
- sensor.battery_level_remote_light_office
- sensor.battery_level_remote_sabrina
- sensor.battery_level_temperature_bathroomsmall
- sensor.battery_level_temperature_livingroom
- sensor.battery_level_temperature_storageroom
- sensor.battery_level_window_bathroomlarge
- sensor.battery_level_window_bedroom
- sensor.battery_level_window_dressroom
- sensor.battery_level_window_kitchen
- sensor.battery_level_window_livingroom
- sensor.battery_level_window_office
- sensor.battery_level_water_leak_bathroomsmall
- sensor.battery_level_water_leak_bathroomlarge
- sensor.battery_level_water_leak_kitchen
- sensor.battery_level_water_leak_storageroom
below: 20
action:
- service: notify.mobile_app_phone_dimitri
data:
title: "Batterien wechseln"
message: >
🔋 Batterien für {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} fast leer
Batteriestand: {{ trigger.to_state.state }}
data:
channel: System
# Notify on high CPU usage
- id: notify_on_high_cpu_usage
alias: "Benachrichtigung wenn CPU Last hoch ist"
mode: parallel
trigger:
- platform: numeric_state
entity_id:
- sensor.cpu_load_ha
- sensor.cpu_load_nas
- sensor.cpu_load_backup_nas
- sensor.cpu_load_pi_bathroomsmall
- sensor.cpu_load_pi_livingroom
- sensor.cpu_load_pi_office
- sensor.cpu_load_pi_dressroom
- sensor.cpu_load_pi_network
- sensor.cpu_load_pi_zigbee_zwave
above: 60
for:
hours: 2
action:
- service: notify.mobile_app_phone_dimitri
data:
title: "Hohe CPU Last!"
message: >
Die CPU Last für {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} ist seit 2 Stunden über 60%!
data:
channel: System
# Notify on high Disk usage
- id: notify_on_high_disk_usage
alias: "Benachrichtigung wenn Speicher fast voll ist"
mode: parallel
trigger:
- platform: numeric_state
entity_id:
- sensor.disk_use_pct_ha
- sensor.disk_use_pct_nas
- sensor.disk_use_pct_backup_nas
above: 95
action:
- service: notify.mobile_app_phone_dimitri
data:
title: "Speicher fast voll!"
message: >
💽 Der Speicher für {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} ist 95% voll!
data:
channel: System
# Notify on high CPU Temp
- id: notify_on_high_cpu_temp
alias: "Benachrichtigung wenn CPU Temperatur hoch ist"
mode: parallel
trigger:
- platform: numeric_state
entity_id:
- sensor.temperature_backup_nas_drive_1
- sensor.temperature_backup_nas_drive_2
- sensor.temperature_nas_drive_1
- sensor.temperature_nas_drive_2
- sensor.temperature_nas_drive_3
- sensor.temperature_nas_drive_4
above: 70
for:
hours: 2
action:
- service: notify.mobile_app_phone_dimitri
data:
title: "Hohe CPU Temperatur!"
message: >
🌡️Die CPU Temperatur für {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} ist seit 2 Stunden über 70°!
data:
channel: Notfall
priority: high
ttl: 0
color: red
# Notify on undervoltage
- id: notify_on_undervoltage
alias: "Benachrichtigung bei Unterspannung"
mode: parallel
trigger:
- platform: state
entity_id:
- binary_sensor.undervoltage_pi_bathroomsmall
- binary_sensor.undervoltage_pi_livingroom
- binary_sensor.undervoltage_pi_dressroom
- binary_sensor.undervoltage_pi_office
- binary_sensor.undervoltage_pi_network
- binary_sensor.undervoltage_pi_zigbee_zwave
to: 'on'
action:
- service: notify.mobile_app_phone_dimitri
data:
title: "Unterspannung!"
message: >
⚡ Unterspannung für {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} entdeckt!
data:
channel: Notfall
priority: high
ttl: 0
color: red
# Notify on insecure NAS