-
Notifications
You must be signed in to change notification settings - Fork 0
/
sensor.yaml
1137 lines (1080 loc) · 40.8 KB
/
sensor.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
# PMS Statistics
# Seems to be a perfomance hit
# - platform: plex
# host: !secret pms_host
# port: !secret pms_port
# name: !secret pms_name
# username: !secret plex_username
# password: !secret plex_password
# server: !secret pms_server
# Time & Date
- platform: time_date
display_options:
- time
- date
- platform: integration
source: sensor.energy_usage
name: Energy Usage kWh
unit_prefix: k
round: 2
- platform: template
sensors:
bedroom_presence:
friendly_name: 'Bedroom Presence'
value_template: >
{% if is_state('device_tracker.beacon_bedroom', 'bedroom') %}
occupied
{% else %}
unoccupied
{% endif %}
august_front_door:
friendly_name: 'Front Door'
value_template: >
{{ states.lock.august_web_front_door.state }}
icon_template: >
{% if is_state('lock.august_web_front_door', 'locked') %}
mdi:lock
{% elif is_state('lock.august_web_front_door', 'unlocked') %}
mdi:lock-open
{% else %}
mdi:timer-sand
{% endif %}
august_garage_door:
friendly_name: 'Garage Door'
value_template: >
{{ states.lock.august_web_garage_door.state }}
icon_template: >
{% if is_state('lock.august_web_garage_door', 'locked') %}
mdi:lock
{% elif is_state('lock.august_web_garage_door', 'unlocked') %}
mdi:lock-open
{% else %}
mdi:timer-sand
{% endif %}
garage_actual:
friendly_name: 'Garage Actual'
value_template: >
{% if is_state('binary_sensor.garage_actual', 'off') %}
closed
{% elif is_state('binary_sensor.garage_actual', 'on') %}
open
{% else %}
unknown
{% endif %}
icon_template: >
{% if is_state('binary_sensor.garage_actual', 'off') %}
mdi:garage
{% elif is_state('binary_sensor.garage_actual', 'on') %}
mdi:garage-open
{% else %}
mdi:timer-sand
{% endif %}
# Custom sensors for mode monitoring
- platform: template
sensors:
mode_morning:
friendly_name: 'Morning Mode'
value_template: >
{{ states('input_boolean.mode_morning') }}
icon_template: 'mdi:weather-hazy'
mode_day:
friendly_name: 'Day Mode'
value_template: >
{{ states('input_boolean.mode_day') }}
icon_template: 'mdi:weather-sunny'
mode_sunset:
friendly_name: 'Sunset Mode'
value_template: >
{{ states('input_boolean.mode_sunset') }}
icon_template: 'mdi:weather-sunset'
mode_night:
friendly_name: 'Night Mode'
value_template: >
{{ states('input_boolean.mode_night') }}
icon_template: 'mdi:weather-night'
mode_guest:
friendly_name: 'Guest Mode'
value_template: >
{{ states('input_boolean.mode_guest') }}
icon_template: 'mdi:human-greeting'
mode_home_theater:
friendly_name: 'Home Theater Mode'
value_template: >
{{ states('input_boolean.mode_home_theater') }}
icon_template: 'mdi:theater'
mode_sleep:
friendly_name: 'Sleep Mode'
value_template: >
{{ states('input_boolean.mode_sleep') }}
icon_template: 'mdi:sleep'
mode_simulate_presence:
friendly_name: 'Simulate Presence Mode'
value_template: >
{% if is_state('input_boolean.mode_simulate_presence', 'on') %}
{% if is_state("group.inside_lights", "on") %}
Lights On
{% else %}
Lights Off
{% endif %}
{% else %}
off
{% endif %}
# Custom sensors for dashboard views
- platform: template
sensors:
dashboard_outside_temperature:
friendly_name: 'Temperature'
value_template: '{{ states.sensor.dark_sky_temperature.state | round() }}'
unit_of_measurement: 'ºF'
dashboard_outside_high_temperature:
friendly_name: 'High'
value_template: '{{ states.sensor.dark_sky_daytime_high_temperature_0d.state | round() }}'
unit_of_measurement: 'ºF'
dashboard_outside_low_temperature:
friendly_name: 'Low'
value_template: '{{ states.sensor.dark_sky_overnight_low_temperature_0d.state | round() }}'
unit_of_measurement: 'ºF'
dashboard_outside_humidity:
friendly_name: 'Humidity'
value_template: '{{ states.sensor.dark_sky_humidity_0d.state | round() }}'
unit_of_measurement: '%'
dashboard_current_home_mode:
friendly_name: 'Current Home Mode'
value_template: >-
{% if is_state('input_boolean.mode_morning', 'on') %}
Morning
{% elif is_state('input_boolean.mode_day', 'on') %}
Day
{% elif is_state('input_boolean.mode_sunset', 'on') %}
Sunset
{% elif is_state('input_boolean.mode_night', 'on') %}
Night
{% else %}
Unknown
{% endif %}
icon_template: >-
{% if is_state('input_boolean.mode_morning', 'on') %}
mdi:weather-hazy
{% elif is_state('input_boolean.mode_day', 'on') %}
mdi:weather-sunny
{% elif is_state('input_boolean.mode_sunset', 'on') %}
mdi:weather-sunset
{% elif is_state('input_boolean.mode_night', 'on') %}
mdi:weather-night
{% else %}
mdi:weather-cloudy-alert
{% endif %}
dashboard_current_mode:
friendly_name: 'Current Mode'
value_template: >-
{% if is_state('input_boolean.mode_sleep', 'on') %}
Sleep
{% elif is_state('input_boolean.mode_home_theater', 'on') %}
Theater
{% elif is_state('input_boolean.mode_guest', 'on') %}
Guest
{% elif is_state('input_boolean.mode_morning', 'on') %}
Morning
{% elif is_state('input_boolean.mode_day', 'on') %}
Day
{% elif is_state('input_boolean.mode_sunset', 'on') %}
Sunset
{% elif is_state('input_boolean.mode_night', 'on') %}
Night
{% else %}
Unknown
{% endif %}
icon_template: >-
{% if is_state('input_boolean.mode_sleep', 'on') %}
mdi:sleep
{% elif is_state('input_boolean.mode_home_theater', 'on') %}
mdi:theater
{% elif is_state('input_boolean.mode_guest', 'on') %}
mdi:human-greeting
{% elif is_state('input_boolean.mode_morning', 'on') %}
mdi:weather-hazy
{% elif is_state('input_boolean.mode_day', 'on') %}
mdi:weather-sunny
{% elif is_state('input_boolean.mode_sunset', 'on') %}
mdi:weather-sunset
{% elif is_state('input_boolean.mode_night', 'on') %}
mdi:weather-night
{% else %}
mdi:weather-cloudy-alert
{% endif %}
dashboard_home_state:
friendly_name: Home State
value_template: >-
{% if states.binary_sensor.garage_actual.state == 'off' and states.lock.august_web_front_door.state == 'locked' and states.lock.august_web_garage_door.state == 'locked' and states.group.all_doors.state == 'off' %}
Secure
{% else %}
Insecure
{% endif %}
icon_template: >-
{% if states.binary_sensor.garage_actual.state == 'off' and states.lock.august_web_front_door.state == 'locked' and states.lock.august_web_garage_door.state == 'locked' and states.group.all_doors.state == 'off' %}
mdi:shield-home
{% else %}
mdi:shield-off
{% endif %}
dashboard_occupancy_state:
friendly_name: Occupancy State
value_template: >-
{% if is_state("group.residents", "home") %}
Resident
{% elif is_state("sensor.mode_guest", "on") %}
Guest
{% else %}
Cats
{% endif %}
icon_template: >-
{% if is_state("group.residents", "home") %}
mdi:account-multiple
{% elif is_state("sensor.mode_guest", "on") %}
mdi:human-greeting
{% else %}
mdi:cat
{% endif %}
dashboard_simulate_presence_status:
friendly_name: Simulate Presence Status
value_template: >
{% if is_state('input_boolean.mode_simulate_presence', 'on') %}
Simulating presence.
{% else %}
off
{% endif %}
dashboard_garage_actual_status:
friendly_name: Garage Actual Status
value_template: >-
{{ 'off' if is_state("cover.garage_actual", "closed") else "Garage Actual is open." }}
dashboard_open_window_status:
friendly_name: Open Window Status
value_template: >-
{% set num_windows = states.binary_sensor
| selectattr('entity_id', 'in', states.group.all_windows.attributes.entity_id)
| selectattr('state', 'eq', 'on')
| list
| length
%}
{% set num_downstairs = states.binary_sensor
| selectattr('entity_id', 'in', states.group.downstairs_windows.attributes.entity_id)
| selectattr('state', 'eq', 'on')
| list
| length
%}
{% set num_upstairs = states.binary_sensor
| selectattr('entity_id', 'in', states.group.upstairs_windows.attributes.entity_id)
| selectattr('state', 'eq', 'on')
| list
| length
%}
{% if num_windows > 1 %}
{% if num_downstairs == 0 %}
{{ num_windows}} upstairs windows are open.
{% elif num_upstairs == 0 %}
{{ num_windows}} downstairs windows are open.
{% else %}
{{ num_windows}} windows are open.
{% endif %}
{% elif num_windows == 1 %}
{% set open_window = states.binary_sensor
| selectattr('entity_id', 'in', states.group.all_windows.attributes.entity_id)
| selectattr('state', 'eq', 'on')
| first
%}
{{ open_window.attributes.friendly_name }} are open.
{% else %}
off
{% endif %}
dashboard_open_door_status:
friendly_name: Open Door Status
value_template: >-
{% set num_doors = states.binary_sensor
| selectattr('entity_id', 'in', states.group.all_doors.attributes.entity_id)
| selectattr('state', 'eq', 'on')
| list
| length
%}
{% if num_doors > 1 %}
{{ num_doors}} doors are open.
{% elif num_doors == 1 %}
{% set open_door = states.binary_sensor
| selectattr('entity_id', 'in', states.group.all_doors.attributes.entity_id)
| selectattr('state', 'eq', 'on')
| first
%}
{{ open_door.attributes.friendly_name }} is open.
{% else %}
off
{% endif %}
dashboard_unlocked_door_status:
friendly_name: Unlocked Door Status
value_template: >-
{% set num = states.lock
| selectattr('entity_id', 'in', states.group.all_locks.attributes.entity_id)
| selectattr('state', 'eq', 'unlocked')
| list
| length
%}
{% if num == 2 %}
Front Door and Garage Door are unlocked.
{% elif num ==1 and is_state("lock.august_web_front_door", "unlocked") %}
Front Door is unlocked.
{% elif num ==1 and is_state("lock.august_web_garage_door", "unlocked") %}
Garage Door is unlocked.
{% else %}
off
{% endif %}
dashboard_lights_on_status:
friendly_name: Lights On Status
value_template: >-
{% set num_lights = states.light
| selectattr('entity_id', 'in', states.group.all_lights.attributes.entity_id)
| selectattr('state', 'eq', 'on')
| list
| length
%}
{% if num_lights > 1 %}
{{ num_lights}} lights are on.
{% elif num_lights == 1 %}
{% set lights_on = states.light
| selectattr('entity_id', 'in', states.group.all_lights.attributes.entity_id)
| selectattr('state', 'eq', 'on')
| first
%}
{{ lights_on.attributes.friendly_name }} are on.
{% else %}
off
{% endif %}
dashboard_sonos_song_status:
friendly_name: Sonos Song Status
value_template: >-
{% set group_master = states("sensor.sonos_group_master") %}
{% if group_master != none %}
{% if is_state("sensor.sonos_group_master_state", "playing") %}
{{ state_attr(group_master, "media_artist") }} – {{ state_attr(group_master, "media_title") }}
{% else %}
Nothing is playing.
{% endif %}
{% else %}
off
{% endif %}
dashboard_sonos_speaker_status:
friendly_name: Sonos Speaker Status
value_template: >-
{% if group_master != none %}
{{ state_attr(states("sensor.sonos_group_master"), "friendly_name") }} + {{ states("sensor.sonos_speakers_join").split(',') | length }}
{% else %}
off
{% endif %}
dashboard_bedroom_fan_filter:
friendly_name: Bedroom Fan Filter
value_template: >-
{% if states("sensor.bedroom_hepa_filter_remaining_life") | int(0) <= 33 %}
on
{% else %}
off
{% endif %}
icon_template: 'mdi:air-filter'
dashboard_kitchen_fan_filter:
friendly_name: Kitchen Fan Filter
value_template: >-
{% if states("sensor.kitchen_combi_filter_remaining_life") | int(0) <= 33 %}
on
{% else %}
off
{% endif %}
icon_template: 'mdi:air-filter'
# dashboard_octavia_fuel_remaining:
# friendly_name: Octavia Fuel Remaining
# value_template: >-
# {% if states.device_tracker.octavia.attributes["fuel_level"] <= 33 %}
# on
# {% else %}
# off
# {% endif %}
# icon_template: 'mdi:gas-station'
# dashboard_neato_rory_status:
# friendly_name: Rory
# value_template: >-
# {% if states("vacuum.rory") != 'docked' %}
# on
# {% else %}
# off
# {% endif %}
# icon_template: 'mdi:robot-vacuum-variant'
# dashboard_neato_rory_last_cleaned:
# friendly_name: Rory - Last Cleaned
# value_template: >-
# {% set lastcleaned = as_timestamp(state_attr("vacuum.rory", "clean_stop")) %}
# {% set fivedaysbefore = (as_timestamp(now()) - (24*60*60*5)) < lastcleaned and as_timestamp(now()) > lastcleaned %}
# {% set daybefore = (as_timestamp(now()) - (24*60*60))|timestamp_custom('%Y-%m-%d') == lastcleaned|timestamp_custom('%Y-%m-%d') %}
# {% set dayof = states("sensor.date") == lastcleaned|timestamp_custom('%Y-%m-%d') %}
# {% if daybefore %}
# Yesterday
# {% elif dayof %}
# Today
# {% elif fivedaysbefore %}
# {{ lastcleaned|timestamp_custom('%A') }}
# {% else %}
# {{ lastcleaned|timestamp_custom('%B %-d') }}
# {% endif %}
# dashboard_neato_amelia_status:
# friendly_name: Amelia
# value_template: >-
# {% if states("vacuum.amelia") != 'docked' %}
# on
# {% else %}
# off
# {% endif %}
# icon_template: 'mdi:robot-vacuum-variant'
# dashboard_neato_amelia_last_cleaned:
# friendly_name: Amelia - Last Cleaned
# value_template: >-
# {% set lastcleaned = as_timestamp(state_attr("vacuum.amelia", "clean_stop")) %}
# {% set fivedaysbefore = (as_timestamp(now()) - (24*60*60*5)) < lastcleaned and as_timestamp(now()) > lastcleaned %}
# {% set daybefore = (as_timestamp(now()) - (24*60*60))|timestamp_custom('%Y-%m-%d') == lastcleaned|timestamp_custom('%Y-%m-%d') %}
# {% set dayof = states("sensor.date") == lastcleaned|timestamp_custom('%Y-%m-%d') %}
# {% if daybefore %}
# Yesterday
# {% elif dayof %}
# Today
# {% elif fivedaysbefore %}
# {{ lastcleaned|timestamp_custom('%A') }}
# {% else %}
# {{ lastcleaned|timestamp_custom('%B %-d') }}
# {% endif %}
# Sonos Grouping Sensors
- platform: template
sensors:
sonos_group_master:
friendly_name: Sonos Group Master
value_template: >-
{%- set players = expand('group.sonos_players') -%}
{%- for player in players if player.state == 'playing' and player.attributes.source is not defined and player.attributes.group_members[0] == player.entity_id %}
{% if loop.last %}
{{ player.entity_id }}
{% endif %}
{% else %}
{{ 'media_player.sonos_'+ states('input_select.master_sonos') | lower | replace(" ", "_") }}
{% endfor -%}
sonos_group_master_state:
friendly_name: Sonos Group Master - State
value_template: >-
{%- set master = states('sensor.sonos_group_master') -%}
{{- 'playing' if is_state(master, 'playing') else 'paused' -}}
sonos_group_master_shuffle:
friendly_name: Sonos Group Master - Shuffle
value_template: >-
{%- set master = states('sensor.sonos_group_master') -%}
{{- 'on' if is_state_attr(master, 'shuffle', true) else 'off' -}}
sonos_group_master_repeat:
friendly_name: Sonos Group Master - Shuffle
value_template: >-
{%- set master = states('sensor.sonos_group_master') -%}
{{- 'on' if is_state_attr(master, 'repeat', 'all') else 'off' -}}
sonos_speakers_join:
friendly_name: Sonos Join Speakers
value_template: >-
{% set master = states('sensor.sonos_group_master') %}
{% for switch in states.input_boolean if "sonos" in switch.entity_id and switch.state == "on" and switch.entity_id|replace("input_boolean", "media_player") != master -%}
{{ switch.entity_id|replace("input_boolean", "media_player") }}
{%- if not loop.last -%}
,
{%- endif %}
{%- endfor %}
sonos_speakers_unjoin:
friendly_name: Sonos Unjoin Speakers
value_template: >-
{% set master = states('sensor.sonos_group_master') %}
{% for switch in states.input_boolean if "sonos" in switch.entity_id and switch.state == "off" and switch.entity_id|replace("input_boolean", "media_player") != master -%}
{{ switch.entity_id|replace("input_boolean", "media_player") }}
{%- if not loop.last -%}
,
{%- endif %}
{%- endfor %}
sonos_switches_on:
friendly_name: Sonos Switches On
value_template: >-
{%- set master = 'media_player.sonos_'+ states('input_select.master_sonos') | lower | replace(" ", "_") -%}
{%- set players = expand('group.sonos_players') -%}
{%- for player in players if player.attributes.group_members | length > 0 and player.entity_id == master %}
{%- set slaves = player.attributes.group_members %}
{{ slaves|join(",")|replace("media_player", "input_boolean") }}
{%- endfor %}
sonos_switches_off:
friendly_name: Sonos Switches Off
value_template: >-
{%- set master = 'media_player.sonos_'+ states('input_select.master_sonos') | lower | replace(" ", "_") -%}
{%- set players = expand('group.sonos_players') -%}
{%- for player in players if player.attributes.group_members | length == 1 and player.entity_id != master -%}
{{ player.entity_id|replace("media_player", "input_boolean") }}
{%- if not loop.last -%}
,
{%- endif -%}
{%- endfor %}
# Sonos Volume Sensors
- platform: template
sensors:
sonos_kitchen_volume:
friendly_name: Sonos Kitchen Volume
value_template: >-
{%- if state_attr('media_player.sonos_kitchen', 'volume_level') is defined and state_attr('media_player.sonos_kitchen', 'volume_level') is number -%}
{{ (state_attr('media_player.sonos_kitchen', 'volume_level') * 100) | int(0) ~ '%' }}
{%- else -%}
Unavailable
{%- endif %}
sonos_living_room_volume:
friendly_name: Sonos Living Room Volume
value_template: >-
{%- if state_attr('media_player.sonos_living_room', 'volume_level') is defined and state_attr('media_player.sonos_living_room', 'volume_level') is number -%}
{{ (state_attr('media_player.sonos_living_room', 'volume_level') * 100) | int(0) ~ '%' }}
{%- else -%}
Unavailable
{%- endif %}
sonos_rec_room_volume:
friendly_name: Sonos Rec Room Volume
value_template: >-
{%- if state_attr('media_player.sonos_rec_room', 'volume_level') is defined and state_attr('media_player.sonos_rec_room', 'volume_level') is number -%}
{{ (state_attr('media_player.sonos_rec_room', 'volume_level') * 100) | int(0) ~ '%' }}
{%- else -%}
Unavailable
{%- endif %}
sonos_bedroom_volume:
friendly_name: Sonos Bedroom Volume
value_template: >-
{%- if state_attr('media_player.sonos_bedroom', 'volume_level') is defined and state_attr('media_player.sonos_bedroom', 'volume_level') is number -%}
{{ (state_attr('media_player.sonos_bedroom', 'volume_level') * 100) | int(0) ~ '%' }}
{%- else -%}
Unavailable
{%- endif %}
sonos_bathroom_volume:
friendly_name: Sonos Bathroom Volume
value_template: >-
{%- if state_attr('media_player.sonos_bathroom', 'volume_level') is defined and state_attr('media_player.sonos_bathroom', 'volume_level') is number -%}
{{ (state_attr('media_player.sonos_bathroom', 'volume_level') * 100) | int(0) ~ '%' }}
{%- else -%}
Unavailable
{%- endif %}
sonos_den_volume:
friendly_name: Sonos Den Volume
value_template: >-
{%- if state_attr('media_player.sonos_den', 'volume_level') is defined and state_attr('media_player.sonos_den', 'volume_level') is number -%}
{{ (state_attr('media_player.sonos_den', 'volume_level') * 100) | int(0) ~ '%' }}
{%- else -%}
Unavailable
{%- endif %}
sonos_move_volume:
friendly_name: Sonos Move Volume
value_template: >-
{%- if state_attr('media_player.sonos_move', 'volume_level') is defined and state_attr('media_player.sonos_move', 'volume_level') is number -%}
{{ (state_attr('media_player.sonos_move', 'volume_level') * 100) | int(0) ~ '%' }}
{%- else -%}
Unavailable
{%- endif %}
# Preferred Lighting Time Sensors
- platform: template
sensors:
prefer_lighting_low:
friendly_name: Prefer Lighting Low Time
# 8:00pm on weekdays, 9:00pm on weekends
value_template: >-
{% set forcerefresh = states("sensor.date") %}
{{ '20:00' if now().strftime('%A')|lower in ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday'] else '21:00' }}
prefer_lighting_mid:
friendly_name: Prefer Lighting Mid Time
# Half way between Night Mode and Prefer Low
value_template: >-
{% set forcerefresh = states("sensor.date") %}
{%- set today = as_timestamp(now()) | timestamp_custom('%Y-%m-%d') -%}
{%- set sunset = as_timestamp(today ~ " " ~ states('sensor.suncalc_sunsetstart')) -%}
{%- set prefer_low = states('sensor.prefer_lighting_low') -%}
{{- (((as_timestamp(today ~ " " ~ prefer_low) - sunset) / 2) + sunset) | timestamp_custom("%H:%M") }}
prefer_lighting_high:
friendly_name: Prefer Lighting High Time
# Same as Day Mode
value_template: "{{ states('sensor.suncalc_goldenhourend') }}"
# Preferred Lighting Time Sensors - Display
- platform: template
sensors:
dashboard_prefer_lighting_low:
friendly_name: Prefer Lighting Low Time
value_template: "{{ as_timestamp(states('sensor.date') + ' ' + states('sensor.prefer_lighting_low')) | timestamp_custom('%-I:%M %p') }}"
dashboard_prefer_lighting_mid:
friendly_name: Prefer Lighting Mid Time
value_template: "{{ as_timestamp(states('sensor.date') + ' ' + states('sensor.prefer_lighting_mid')) | timestamp_custom('%-I:%M %p') }}"
dashboard_prefer_lighting_high:
friendly_name: Prefer Lighting High Time
value_template: "{{ as_timestamp(states('sensor.date') + ' ' + states('sensor.prefer_lighting_high')) | timestamp_custom('%-I:%M %p') }}"
# Nest Sleep Mode Temperatures
- platform: template
sensors:
climate_downstairs_sleep_mode_cool:
friendly_name: Downstairs Nest Sleep Mode - Cool
value_template: 80
unit_of_measurement: "ºF"
climate_downstairs_sleep_mode_heat:
friendly_name: Downstairs Nest Sleep Mode - Heat
value_template: 76
unit_of_measurement: "ºF"
climate_upstairs_sleep_mode_cool:
friendly_name: Upstairs Nest Sleep Mode - Cool
value_template: 74
unit_of_measurement: "ºF"
climate_upstairs_sleep_mode_heat:
friendly_name: Upstairs Nest Sleep Mode - Heat
value_template: 74
unit_of_measurement: "ºF"
# Tautulli Sensors
# - platform: template
# sensors:
# Tautulli User 1
# tautulli_user1:
# friendly_name: !secret tautulli_user1_friendly_name
# value_template: '{{ "off" if state_attr("sensor.tautulli", states("input_text.tautulli_user1")).Activity == none else state_attr("sensor.tautulli", states("input_text.tautulli_user1")).Activity | title }}'
# entity_picture_template: '{{ state_attr("sensor.tautulli", states("input_text.tautulli_user1")).user_thumb | default("/local/none.png") }}'
- platform: rest
name: Tautulli Plex Update Available
resource: !secret tautulli_plex_update
json_attributes_path: "$.response.data"
json_attributes:
- version
value_template: '{{ "on" if value_json.response.data.update_available else "off" }}'
scan_interval: 3600
# InfluxDB Sensors
- platform: influxdb
host: !secret influxdb_host
port: !secret influxdb_port
queries:
# Overwatch Server
- name: Overwatch CPU Load 1
unit_of_measurement: '1 min'
group_function: last
where: '"host" = ''overwatch'' and time > now() - 5m'
value_template: '{{ value | round(2) }}'
measurement: '"system"'
field: '"load1"'
database: telegraf
- name: Overwatch CPU Load 5
unit_of_measurement: '5 min'
group_function: last
where: '"host" = ''overwatch'' and time > now() - 5m'
value_template: '{{ value | round(2) }}'
measurement: '"system"'
field: '"load5"'
database: telegraf
- name: Overwatch CPU Load 15
unit_of_measurement: '15 min'
group_function: last
where: '"host" = ''overwatch'' and time > now() - 5m'
value_template: '{{ value | round(2) }}'
measurement: '"system"'
field: '"load15"'
database: telegraf
- name: Overwatch CPU Temp
unit_of_measurement: 'ºC'
group_function: last
where: '"host" = ''overwatch'' and "chip" = ''coretemp-isa-0000'' and time > now() - 5m'
value_template: '{{ value | round() }}'
measurement: '"sensors"'
field: '"temp_input"'
database: telegraf
- name: Overwatch RAM Used
unit_of_measurement: '%'
group_function: last
where: '"host" = ''overwatch'' and time > now() - 5m'
value_template: '{{ value | round() }}'
measurement: '"mem"'
field: '"used_percent"'
database: telegraf
# Woodhouse Server
- name: Woodhouse CPU Load 1
unit_of_measurement: '1 min'
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ value | round(2) }}'
measurement: '"system"'
field: '"load1"'
database: telegraf
- name: Woodhouse CPU Load 5
unit_of_measurement: '5 min'
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ value | round(2) }}'
measurement: '"system"'
field: '"load5"'
database: telegraf
- name: Woodhouse CPU Load 15
unit_of_measurement: '15 min'
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ value | round(2) }}'
measurement: '"system"'
field: '"load15"'
database: telegraf
- name: Woodhouse CPU1 Temp
unit_of_measurement: 'ºC'
group_function: last
where: '"host" = ''woodhouse'' and "chip" = ''coretemp-isa-0000'' and time > now() - 5m'
value_template: '{{ value | round() }}'
measurement: '"sensors"'
field: '"temp_input"'
database: telegraf
- name: Woodhouse CPU2 Temp
unit_of_measurement: 'ºC'
group_function: last
where: '"host" = ''woodhouse'' and "chip" = ''coretemp-isa-0001'' and time > now() - 5m'
value_template: '{{ value | round() }}'
measurement: '"sensors"'
field: '"temp_input"'
database: telegraf
- name: Woodhouse RAM Used
unit_of_measurement: '%'
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ value | round() }}'
measurement: '"mem"'
field: '"used_percent"'
database: telegraf
# Overwatch Services
- name: Service Status Home Assistant
group_function: last
where: !secret influxdb_service_status_home_assistant
value_template: '{{ "Up" if value == "200" else "Down" }}'
measurement: '"http_response"'
field: '"http_response_code"'
database: telegraf
# Woodhouse Services
- name: Service Status Plex
group_function: last
where: !secret influxdb_service_status_plex
value_template: '{{ "Up" if value == "200" else "Down" }}'
measurement: '"http_response"'
field: '"http_response_code"'
database: telegraf
- name: Service Status Sonarr
group_function: last
where: !secret influxdb_service_status_sonarr
value_template: '{{ "Up" if value == "200" else "Down" }}'
measurement: '"http_response"'
field: '"http_response_code"'
database: telegraf
- name: Service Status SABnzbd
group_function: last
where: !secret influxdb_service_status_sabnzbd
value_template: '{{ "Up" if value == "200" else "Down" }}'
measurement: '"http_response"'
field: '"http_response_code"'
database: telegraf
- name: Service Status Tautulli
group_function: last
where: !secret influxdb_service_status_tautulli
value_template: '{{ "Up" if value == "200" else "Down" }}'
measurement: '"http_response"'
field: '"http_response_code"'
database: telegraf
- name: Service Status Grafana
group_function: last
where: !secret influxdb_service_status_grafana
value_template: '{{ "Up" if value == "200" else "Down" }}'
measurement: '"http_response"'
field: '"http_response_code"'
database: telegraf
#UniFi
- name: Service Status UniFi Network
group_function: last
where: !secret influxdb_service_status_unifi_network
value_template: '{{ "Up" if value == "200" else "Down" }}'
measurement: '"http_response"'
field: '"http_response_code"'
database: telegraf
- name: Service Status UniFi Protect
group_function: last
where: !secret influxdb_service_status_unifi_protect
value_template: '{{ "Up" if value == "200" else "Down" }}'
measurement: '"http_response"'
field: '"http_response_code"'
database: telegraf
#Network
- name: Network Status Cox WAN
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ "Up" if value == "1" else "Down" }}'
measurement: '"wan"'
field: '"cox_wan"'
database: telegraf
- name: Network Status VPN WAN
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ "Up" if value == "1" else "Down" }}'
measurement: '"wan"'
field: '"vpn_wan"'
database: telegraf
- name: Network Status VPN2 WAN
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ "Up" if value == "1" else "Down" }}'
measurement: '"wan"'
field: '"vpn2_wan"'
database: telegraf
- name: Network Status VPN3 WAN
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ "Up" if value == "1" else "Down" }}'
measurement: '"wan"'
field: '"vpn3_wan"'
database: telegraf
- name: Network Status LAN
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ "Up" if value == "1" else "Down" }}'
measurement: '"wan"'
field: '"lan"'
database: telegraf
- name: Network Status VL40 IoT
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ "Up" if value == "1" else "Down" }}'
measurement: '"wan"'
field: '"vl40_iot"'
database: telegraf
- name: Network Status VL50 Guest
group_function: last
where: '"host" = ''woodhouse'' and time > now() - 5m'
value_template: '{{ "Up" if value == "1" else "Down" }}'
measurement: '"wan"'
field: '"vl50_guest"'
database: telegraf
# States for Conditionals
- platform: template
sensors:
state_all_services_up:
friendly_name: State - All Services Up
value_template: >-
{% set services = [
"sensor.service_status_home_assistant",
"sensor.service_status_plex",
"sensor.service_status_sonarr",
"sensor.service_status_sabnzbd",
"sensor.service_status_tautulli",
"sensor.service_status_grafana",
"sensor.service_status_unifi_network",
"sensor.service_status_unifi_protect"
] %}
{{ 'on' if states.sensor
| selectattr('entity_id', 'in', services)
| selectattr('state', 'eq', 'Down')
| list
| count == 0
else 'off'
}}
state_all_vpn_wan_down:
friendly_name: State - All VPN WANs Down
value_template: >-
{% set networks = [
"sensor.network_status_vpn_wan",
"sensor.network_status_vpn2_wan",
"sensor.network_status_vpn3_wan",
] %}
{{ 'on' if states.sensor
| selectattr('entity_id', 'in', networks)
| selectattr('state', 'eq', 'Down')
| list
| count == 3
else 'off'
}}
state_ha_new_major_version:
friendly_name: State - HA New Major Version
value_template: >-
{%- if states.sensor.current_version.state is defined and states.sensor.latest_version.state is defined -%}
{{- "on" if states("sensor.latest_version").rsplit(".", 1)[0] > states("sensor.current_version").rsplit(".", 1)[0] else "off" -}}
{%- else -%}
unknown
{%- endif %}
# Cox Data Usage
# - platform: file
# name: Cox Data Plan
# file_path: /config/json/cox_usage.json
# value_template: >
# {% if value_json is defined %}
# {% if value_json.visitorLoginStatus == 'loggedin' %}
# {{ value_json.lpInternetSubscribed }}
# {% else %}
# Update Error
# {% endif %}
# {% else %}
# undefined
# {% endif %}
# - platform: file
# name: Cox Data Usage
# file_path: /config/json/cox_usage.json
# value_template: >
# {% if value_json is defined %}
# {% if value_json.visitorLoginStatus == 'loggedin' %}
# {% if value_json.dumUsage | int(0) == 0 and value_json.dumLimit | int(0) == 0 and value_json.dumUtilization | int(0) == 0 %}
# {{ sensor.cox_data_usage }}
# {% else %}
# {{ value_json.dumUtilization | int(0) }}
# {% endif %}
# {% else %}
# unknown
# {% endif %}
# {% else %}
# undefined
# {% endif %}
# unit_of_measurement: '%'
# - platform: file
# name: Cox Data Usage - Long
# file_path: /config/json/cox_usage.json
# value_template: >
# {% if value_json is defined %}
# {% if value_json.dumUsage | int(0) == 0 and value_json.dumLimit | int(0) == 0 and value_json.dumUtilization | int(0) == 0 %}
# stats unavailable
# {% else %}
# {{ value_json.dumUsage | int(0) }} / {{ value_json.dumLimit | int(0) }} GB ({{ value_json.dumUtilization | int(0) }} %)
# {% endif %}
# {% else %}
# undefined
# {% endif %}
# - platform: file
# name: Cox Data Resets
# file_path: /config/json/cox_usage.json
# value_template: >
# {% if value_json is defined %}
# {% if value_json.visitorLoginStatus == 'loggedin' %}
# {% if value_json.dumDaysLeft is defined %}
# {{ value_json.dumDaysLeft | int(0) }}
# {% else %}
# {{ sensor.cox_data_resets }}
# {% endif %}
# {% else %}
# unknown
# {% endif %}
# {% else %}
# undefined
# {% endif %}
# unit_of_measurement: 'days'