-
-
Notifications
You must be signed in to change notification settings - Fork 501
Expand file tree
/
Copy pathvacation_mode.yaml
More file actions
1178 lines (1084 loc) · 49.3 KB
/
Copy pathvacation_mode.yaml
File metadata and controls
1178 lines (1084 loc) · 49.3 KB
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
######################################################################
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Vacation Mode - house-sitter arrival, analytics, and security checks.
# Detects long absences, tracks sitter visits, and delivers vacation-specific reminders.
# -------------------------------------------------------------------
# Related Issue: 793
# Related Issue: 1791
# Related Issue: 1792
# Notes: Vacation mode auto-enables from an active Tesla road trip while the family is away, or after the existing 24-hour absence/bed-inactivity checks.
# Notes: Vacation mode restores its prior state after Home Assistant restarts; a 5-minute reconciliation also clears a restored mode when the family is already home.
# Notes: General vacation speech uses Chromecast only; the garage Alexa welcome is the one local-device exception.
# Notes: Visit analytics use recorder-backed visit counts plus arrival/departure helpers for accurate durations.
# Notes: Dorm zones are reported as away locations, not Bear Stone home.
# Notes: Recent-departure lockout and a 3-hour stale-visit timeout prevent missed close edges from creating inflated visit durations.
# Notes: Missed sitter alerts include 2-day and 3-day snooze actions that clear after a visit.
# Notes: 10 AM and 10 PM house digests send lock-screen pushes and dispatch a richer snapshot to Joanna for vacation-mode review.
# Notes: Powerwall/grid status is always included in vacation digests because power events are high signal.
# Video: https://youtu.be/15kRcFaVV2Y
# Blog: https://www.vcloudinfo.com/2026/05/home-assistant-vacation-mode-house-sitter-automation.html
# Snooze video: https://youtu.be/y47KSflS1aw
# Snooze blog: https://www.vcloudinfo.com/2026/06/home-assistant-notification-snooze-buttons.html
######################################################################
input_boolean:
vacation_mode:
name: Vacation Mode
icon: mdi:palm-tree
house_sitter_present:
name: House Sitter Present
icon: mdi:account-key
initial: off
input_datetime:
vacation_house_sitter_last_arrival:
name: Vacation House Sitter Last Arrival
has_date: true
has_time: true
vacation_house_sitter_last_departure:
name: Vacation House Sitter Last Departure
has_date: true
has_time: true
vacation_house_sitter_missed_visit_snooze_until:
name: Vacation House Sitter Missed Visit Snooze Until
has_date: true
has_time: true
vacation_house_status_digest_last_sent:
name: Vacation House Status Digest Last Sent
has_date: true
has_time: true
input_number:
vacation_house_sitter_last_visit_minutes:
name: Vacation House Sitter Last Visit Minutes
min: 0
max: 1440
step: 0.1
mode: box
unit_of_measurement: min
script:
vacation_house_sitter_clear_presence:
alias: Vacation House Sitter Clear Presence
mode: queued
fields:
visit_minutes:
description: Visit duration in minutes.
departure_timestamp:
description: Epoch timestamp to store as the sitter departure time.
clear_reason:
description: Reason this clear action ran.
sequence:
- service: input_number.set_value
target:
entity_id: input_number.vacation_house_sitter_last_visit_minutes
data:
value: "{{ visit_minutes }}"
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.vacation_house_sitter_last_departure
data:
timestamp: "{{ departure_timestamp }}"
- service: homeassistant.turn_off
target:
entity_id: input_boolean.house_sitter_present
vacation_house_status_digest:
alias: Vacation House Status Digest
mode: queued
fields:
digest_mode:
description: Digest window label, usually morning or night.
example: morning
sequence:
- variables:
digest_mode_value: "{{ digest_mode | default('morning', true) | lower }}"
- variables:
digest_label: "{{ 'Night' if digest_mode_value == 'night' else 'Morning' }}"
last_digest_ts: "{{ as_timestamp(states('input_datetime.vacation_house_status_digest_last_sent'), 0) }}"
vacation_started_ts: "{{ as_timestamp(states.input_boolean.vacation_mode.last_changed, 0) }}"
vacation_duration: >-
{% set started = as_timestamp(states.input_boolean.vacation_mode.last_changed, 0) %}
{% if is_state('input_boolean.vacation_mode', 'on') and started > 0 %}
{% set hours = ((as_timestamp(now()) - started) / 3600) | int(0) %}
{% set days = (hours // 24) | int(0) %}
{% set remaining_hours = (hours % 24) | int(0) %}
{{ days ~ 'd ' ~ remaining_hours ~ 'h' if days > 0 else remaining_hours ~ 'h' }}
{% else %}
inactive
{% endif %}
sitter_summary: >-
{% set visit_count = states('sensor.vacation_house_sitter_visit_count') | int(0) %}
{% set hours_since = state_attr('sensor.vacation_house_sitter_analytics', 'hours_since_last_visit') | float(0) %}
{% if is_state('input_boolean.house_sitter_present', 'on') %}
Sitter is currently at the house.
{% elif visit_count > 0 %}
Sitter visits: {{ visit_count }}; last visit {{ hours_since | round(1) }}h ago.
{% else %}
No sitter visit recorded yet this vacation.
{% endif %}
powerwall_grid_label: >-
{% set grid = states('binary_sensor.powerwall_grid_status') %}
{% if grid == 'on' %}
grid up
{% elif grid == 'off' %}
GRID DOWN
{% else %}
grid {{ grid }}
{% endif %}
powerwall_charge_label: >-
{% set charge = states('sensor.powerwall_charge') %}
{% if charge in ['unknown', 'unavailable', 'none', ''] %}
battery unavailable
{% else %}
battery {{ charge | float(0) | round(0) | int(0) }}%
{% endif %}
powerwall_grid_changed_ts: >-
{% set entity = states.binary_sensor.powerwall_grid_status if states.binary_sensor.powerwall_grid_status is defined else none %}
{{ as_timestamp(entity.last_changed, 0) if entity is not none else 0 }}
powerwall_recent_event: >-
{% set changed = powerwall_grid_changed_ts | float(0) %}
{{ last_digest_ts | float(0) > 0 and changed > last_digest_ts | float(0) }}
powerwall_summary: >-
{% set summary = 'Powerwall: ' ~ powerwall_grid_label | trim ~ ', ' ~ powerwall_charge_label | trim ~ '.' %}
{% if powerwall_recent_event | bool(false) %}
{{ summary }} Grid status changed since the last digest at {{ (powerwall_grid_changed_ts | float(0)) | timestamp_custom('%H:%M', true) }}.
{% else %}
{{ summary }}
{% endif %}
powerwall_issues: >-
{% set ns = namespace(items=[]) %}
{% set charge = states('sensor.powerwall_charge') %}
{% if is_state('binary_sensor.powerwall_grid_status', 'off') %}
{% set ns.items = ns.items + ['grid is down'] %}
{% endif %}
{% if charge in ['unknown', 'unavailable', 'none', ''] %}
{% set ns.items = ns.items + ['Powerwall charge unavailable'] %}
{% elif charge | float(100) < 60 %}
{% set ns.items = ns.items + ['Powerwall charge ' ~ (charge | float(0) | round(0) | int(0)) ~ '%'] %}
{% endif %}
{{ ns.items | join('; ') if ns.items | count > 0 else 'none' }}
security_issues: >-
{% set ns = namespace(items=[]) %}
{% if states('lock.front_door') != 'locked' %}
{% set ns.items = ns.items + ['front door ' ~ states('lock.front_door')] %}
{% endif %}
{% if states('group.locks') != 'locked' %}
{% set ns.items = ns.items + ['locks ' ~ states('group.locks')] %}
{% endif %}
{% if states('group.garage_doors') not in ['closed', 'off'] %}
{% set ns.items = ns.items + ['garage ' ~ states('group.garage_doors')] %}
{% endif %}
{% if states('group.entry_points') not in ['off', 'closed'] %}
{% set ns.items = ns.items + ['entry points ' ~ states('group.entry_points')] %}
{% endif %}
{{ ns.items | join('; ') if ns.items | count > 0 else 'none' }}
security_summary: >-
{% if security_issues == 'none' %}
Secure: locks locked, garage closed, entry points closed.
{% else %}
Needs security attention: {{ security_issues }}.
{% endif %}
climate_summary: >-
{% set down_temp = state_attr('climate.downstairs', 'current_temperature') %}
{% set up_temp = state_attr('climate.upstairs', 'current_temperature') %}
Climate: downstairs {{ down_temp if down_temp is not none else states('climate.downstairs') }}, upstairs {{ up_temp if up_temp is not none else states('climate.upstairs') }}.
safety_issues: >-
{% set ns = namespace(items=[]) %}
{% set fridge = states('sensor.refrigerator_fridge_temp') %}
{% set freezer = states('sensor.refrigerator_freezer_temp') %}
{% set flow = states('sensor.phyn_water_flowing') %}
{% if states('valve.phyn_shutoff_valve') != 'open' %}
{% set ns.items = ns.items + ['Phyn valve ' ~ states('valve.phyn_shutoff_valve')] %}
{% endif %}
{% if flow in ['unknown', 'unavailable', 'none', ''] %}
{% set ns.items = ns.items + ['water telemetry ' ~ flow] %}
{% elif flow in ['on', 'true'] or flow | float(0) > 0 %}
{% set ns.items = ns.items + ['water flowing ' ~ flow] %}
{% endif %}
{% if is_state('binary_sensor.refrigerator_door_open', 'on') %}
{% set ns.items = ns.items + ['refrigerator door open'] %}
{% endif %}
{% if fridge in ['unknown', 'unavailable', 'none', ''] and freezer in ['unknown', 'unavailable', 'none', ''] %}
{% set ns.items = ns.items + ['refrigerator telemetry unavailable'] %}
{% endif %}
{% if fridge not in ['unknown', 'unavailable', 'none', ''] and fridge | float(0) > 45 %}
{% set ns.items = ns.items + ['fridge ' ~ (fridge | float(0) | round(1)) ~ 'F'] %}
{% endif %}
{% if freezer not in ['unknown', 'unavailable', 'none', ''] and freezer | float(0) > 15 %}
{% set ns.items = ns.items + ['freezer ' ~ (freezer | float(0) | round(1)) ~ 'F'] %}
{% endif %}
{% if is_state('binary_sensor.front_door_packages_present', 'on') %}
{% set ns.items = ns.items + ['package at front door'] %}
{% endif %}
{{ ns.items | join('; ') if ns.items | count > 0 else 'none' }}
infra_issues: >-
{% set ns = namespace(items=[]) %}
{% if is_state('binary_sensor.mqtt_broker_problem', 'on') %}
{% set ns.items = ns.items + ['MQTT broker problem'] %}
{% endif %}
{% if is_state('binary_sensor.infra_nebula_sync_degraded', 'on') %}
{% set ns.items = ns.items + ['Nebula Sync DNS degraded'] %}
{% endif %}
{% if is_state('binary_sensor.infra_pihole_iot_dns_degraded', 'on') %}
{% set ns.items = ns.items + ['IoT Pi-hole DNS degraded'] %}
{% endif %}
{% if is_state('input_boolean.infra_duplicati_backup_repair_active', 'on') %}
{% set ns.items = ns.items + ['Duplicati backup repair active'] %}
{% endif %}
{{ ns.items | join('; ') if ns.items | count > 0 else 'none' }}
- variables:
action_items: >-
{% set ns = namespace(items=[]) %}
{% if powerwall_issues != 'none' %}
{% set ns.items = ns.items + ['Powerwall: ' ~ powerwall_issues] %}
{% endif %}
{% if security_issues != 'none' %}
{% set ns.items = ns.items + ['Security: ' ~ security_issues] %}
{% endif %}
{% if safety_issues != 'none' %}
{% set ns.items = ns.items + ['Safety: ' ~ safety_issues] %}
{% endif %}
{% if infra_issues != 'none' %}
{% set ns.items = ns.items + ['Infra: ' ~ infra_issues] %}
{% endif %}
{{ ns.items | join(' | ') if ns.items | count > 0 else 'No material issues found.' }}
fallback_message_one: >-
{% set msg = 'Vacation ' ~ digest_label | lower ~ ' (' ~ vacation_duration | trim ~ '): ' ~ powerwall_summary | trim ~ ' ' ~ security_summary | trim ~ ' ' ~ sitter_summary | trim %}
{{ msg[:447] ~ '...' if msg | length > 450 else msg }}
fallback_message_two: >-
{% set msg = 'Actions: ' ~ action_items | trim ~ ' ' ~ climate_summary | trim %}
{{ msg[:447] ~ '...' if msg | length > 450 else msg }}
joanna_diagnostics: >-
vacation_mode={{ states('input_boolean.vacation_mode') }};
digest={{ digest_mode_value }};
vacation_duration={{ vacation_duration | trim }};
last_digest_ts={{ last_digest_ts }};
powerwall_grid={{ states('binary_sensor.powerwall_grid_status') }};
powerwall_charge={{ states('sensor.powerwall_charge') }};
powerwall_recent_event={{ powerwall_recent_event | trim }};
security={{ security_issues }};
safety={{ safety_issues }};
infra={{ infra_issues }};
sitter={{ sitter_summary | trim }};
climate={{ climate_summary | trim }};
entities=binary_sensor.powerwall_grid_status,sensor.powerwall_charge,group.locks,lock.front_door,group.garage_doors,group.entry_points,input_boolean.house_sitter_present,sensor.vacation_house_sitter_analytics,sensor.phyn_water_flowing,valve.phyn_shutoff_valve,binary_sensor.refrigerator_door_open,sensor.refrigerator_fridge_temp,sensor.refrigerator_freezer_temp,binary_sensor.front_door_packages_present,binary_sensor.mqtt_broker_problem,binary_sensor.infra_nebula_sync_degraded,binary_sensor.infra_pihole_iot_dns_degraded,input_boolean.infra_duplicati_backup_repair_active
- service: script.notify_engine
data:
title: "Vacation {{ digest_label }} House Digest"
value1: "{{ fallback_message_one }}"
who: carlo
group: vacation
level: active
- service: script.notify_engine
data:
title: "Vacation {{ digest_label }} Power/Issues"
value1: "{{ fallback_message_two }}"
who: carlo
group: vacation
level: active
- service: rest_command.bearclaw_command
data:
source: home_assistant_automation.vacation_house_status_digest
user: carlo
context: "Vacation Mode {{ digest_label }} House Status Digest"
domain_hint: ops
lane_hint: joanna.ops
priority: high
async_only: true
metadata:
vacationMode: true
digestMode: "{{ digest_mode_value }}"
houseDigest: true
powerwallImportant: true
text: >-
Vacation {{ digest_label | lower }} house digest snapshot.
Fallback push 1: {{ fallback_message_one }}
Fallback push 2: {{ fallback_message_two }}
Diagnostics: {{ joanna_diagnostics }}
Request: Use the vacation-mode heavier reasoning profile. Return one concise Home Assistant push paragraph under 420 characters. Powerwall/grid status is high signal and must always be mentioned. Mention only material issues or actions; avoid Docker/AP recovery noise unless unresolved. Start with "Vacation {{ digest_label }}:".
- service: script.send_to_logbook
data:
topic: VACATION DIGEST
message: "{{ digest_label }} vacation digest sent. {{ action_items }}"
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.vacation_house_status_digest_last_sent
data:
timestamp: "{{ now().timestamp() }}"
sensor:
- platform: history_stats
name: Vacation House Sitter Visit Count
entity_id: input_boolean.house_sitter_present
state: 'on'
type: count
start: >-
{% if is_state('input_boolean.vacation_mode', 'on') %}
{{ states.input_boolean.vacation_mode.last_changed }}
{% else %}
{{ now() }}
{% endif %}
end: "{{ now() }}"
template:
- sensor:
- name: "Vacation House Sitter Analytics"
unique_id: vacation_house_sitter_analytics
icon: mdi:clipboard-text-clock-outline
state: "{{ states('sensor.vacation_house_sitter_visit_count') | int(0) }}"
attributes:
vacation_started_at: >-
{% if is_state('input_boolean.vacation_mode', 'on') %}
{{ as_local(states.input_boolean.vacation_mode.last_changed).isoformat() }}
{% else %}
none
{% endif %}
last_arrival_at: >-
{% set vacation_start = as_timestamp(states.input_boolean.vacation_mode.last_changed, 0) %}
{% set raw = states('input_datetime.vacation_house_sitter_last_arrival') %}
{% set ts = as_timestamp(raw, 0) %}
{% if is_state('input_boolean.vacation_mode', 'on') and ts >= vacation_start and ts > 0 %}
{{ as_local(as_datetime(raw)).isoformat() }}
{% else %}
none
{% endif %}
last_departure_at: >-
{% set vacation_start = as_timestamp(states.input_boolean.vacation_mode.last_changed, 0) %}
{% set raw = states('input_datetime.vacation_house_sitter_last_departure') %}
{% set ts = as_timestamp(raw, 0) %}
{% if is_state('input_boolean.vacation_mode', 'on') and ts >= vacation_start and ts > 0 %}
{{ as_local(as_datetime(raw)).isoformat() }}
{% else %}
none
{% endif %}
last_visit_minutes: >-
{% set vacation_start = as_timestamp(states.input_boolean.vacation_mode.last_changed, 0) %}
{% set departure_ts = as_timestamp(states('input_datetime.vacation_house_sitter_last_departure'), 0) %}
{% if is_state('input_boolean.vacation_mode', 'on') and departure_ts >= vacation_start %}
{{ states('input_number.vacation_house_sitter_last_visit_minutes') | float(0) }}
{% else %}
0
{% endif %}
hours_since_last_visit: >-
{% set vacation_start = as_timestamp(states.input_boolean.vacation_mode.last_changed, 0) %}
{% set departure = states('input_datetime.vacation_house_sitter_last_departure') %}
{% set departure_ts = as_timestamp(departure, 0) %}
{% if is_state('input_boolean.vacation_mode', 'on') and departure_ts >= vacation_start %}
{{ ((as_timestamp(now()) - departure_ts) / 3600) | round(1) }}
{% else %}
0
{% endif %}
active_visit_minutes: >-
{% if is_state('input_boolean.house_sitter_present', 'on') %}
{{ ((as_timestamp(now()) - as_timestamp(states.input_boolean.house_sitter_present.last_changed, 0)) / 60) | round(1) }}
{% else %}
0
{% endif %}
automation:
- alias: 'Vacation Mode Enable'
id: 163f4434-2a2f-4528-a53c-8fc6e1fd8e14
mode: single
trigger:
- platform: state
entity_id: group.family
to: 'not_home'
for: "24:00:00"
- platform: state
entity_id: group.bed
to: 'off'
for: "24:00:00"
- platform: homeassistant
event: start
- platform: time_pattern
hours: "/1"
- platform: event
event_type: tesla_road_trip_active
id: tesla_road_trip
condition:
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
- condition: template
value_template: >-
{% set family_away = is_state('group.family', 'not_home') %}
{% set family_away_seconds = as_timestamp(now()) - as_timestamp(states.group.family.last_changed, 0) %}
{% set bed_unused_seconds = as_timestamp(now()) - as_timestamp(states.group.bed.last_changed, 0) %}
{% set road_trip_signal = trigger.id | default('', true) == 'tesla_road_trip' %}
{{ (family_away and road_trip_signal)
or (family_away and family_away_seconds >= 86400)
or (family_away and is_state('group.bed', 'off') and bed_unused_seconds >= 86400) }}
action:
- variables:
vacation_reason: >-
{% set family_away_seconds = as_timestamp(now()) - as_timestamp(states.group.family.last_changed, 0) %}
{% set bed_unused_seconds = as_timestamp(now()) - as_timestamp(states.group.bed.last_changed, 0) %}
{% if trigger.id | default('', true) == 'tesla_road_trip' %}
Active Tesla road trip while the family remained away
{% elif is_state('group.bed', 'off') and bed_unused_seconds >= 86400 and family_away_seconds < 86400 %}
Bed inactivity while the family remained away
{% elif is_state('group.bed', 'off') and bed_unused_seconds >= 86400 %}
Family absence and no bed use
{% else %}
Family absence
{% endif %}
- service: input_boolean.turn_on
entity_id:
- input_boolean.vacation_mode
- service: input_boolean.turn_off
entity_id:
- input_boolean.house_sitter_present
- service: script.send_to_logbook
data:
topic: VACATION MODE
message: >-
Vacation mode enabled based on {{ vacation_reason | lower }}.
- alias: 'Vacation Mode Reset'
id: d7d33f43-22f6-4db4-8a7d-c38f3c6d0c65
mode: single
trigger:
- platform: state
entity_id: group.family
to: 'home'
for: "00:02:00"
id: family_home
- platform: time_pattern
minutes: "/5"
id: reconcile_home
condition:
- condition: template
value_template: >-
{% set family_home_seconds = as_timestamp(now()) - as_timestamp(states.group.family.last_changed, 0) %}
{{ is_state('input_boolean.vacation_mode', 'on')
and is_state('group.family', 'home')
and (trigger.id == 'family_home' or family_home_seconds >= 120) }}
action:
- service: input_boolean.turn_off
entity_id:
- input_boolean.vacation_mode
- input_boolean.house_sitter_present
- service: script.speech_engine
data:
value1: >-
Vacation Mode has been disabled and normal automations will continue.
call_no_announcement: 1
- alias: 'Vacation Mode Clear Missed Visit Snooze'
id: 88b7ce4b-b7f9-4770-8b1c-2c42b7a98e32
mode: queued
trigger:
- platform: state
entity_id: input_boolean.vacation_mode
to:
- 'on'
- 'off'
- platform: state
entity_id: input_boolean.house_sitter_present
to: 'on'
action:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.vacation_house_sitter_missed_visit_snooze_until
data:
datetime: "{{ (now() - timedelta(minutes=1)).strftime('%Y-%m-%d %H:%M:%S') }}"
- alias: 'Vacation Mode House Digest Schedule'
id: ed48b582-107f-4424-ab47-bb54cbd8ad38
mode: single
trigger:
- platform: time
id: morning
at: "10:00:00"
- platform: time
id: night
at: "22:00:00"
condition:
- condition: template
value_template: "{{ is_state('input_boolean.vacation_mode', 'on') }}"
action:
- service: script.vacation_house_status_digest
data:
digest_mode: "{{ trigger.id }}"
- alias: 'Vacation Mode Garage Welcome'
id: 63ac9268-c895-4a1b-b0df-92b5bb8e9d01
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: group.garage_doors
to: 'open'
for: "00:00:15"
condition:
- condition: template
value_template: >-
{{ is_state('group.family', 'not_home')
and is_state('input_boolean.vacation_mode', 'on')
and is_state('input_boolean.house_sitter_present', 'off')
and trigger.to_state is not none }}
action:
- delay: "00:00:30"
- condition: state
entity_id: group.family
state: 'not_home'
- condition: state
entity_id: input_boolean.vacation_mode
state: 'on'
- condition: state
entity_id: input_boolean.house_sitter_present
state: 'off'
- service: notify.alexa_media_garage
data:
message: >-
Welcome back to Bear Stone. Please check whether any packages are waiting at the front door.
data:
type: announce
- alias: 'Vacation Mode House Sitter Arrival'
id: 8058a1e1-8517-4a07-839b-ef8f30ec24e4
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: group.garage_doors
to: 'open'
for: "00:00:15"
id: garage
- platform: state
entity_id: binary_sensor.mcu1_gpio5
to: 'on'
for: "00:00:02"
id: front_door_sensor
- platform: state
entity_id: lock.front_door
to: 'unlocked'
for: "00:02:00"
id: front_door_unlock
condition:
- condition: template
value_template: >-
{{ is_state('group.family', 'not_home')
and is_state('input_boolean.vacation_mode', 'on')
and is_state('input_boolean.house_sitter_present', 'off') }}
action:
- variables:
entry_label: >-
{{ 'garage door' if trigger.id == 'garage' else 'front door' }}
entry_delay: >-
{{ '00:05:00' if trigger.id == 'garage' else '00:02:00' }}
vacation_start_ts: "{{ as_timestamp(states.input_boolean.vacation_mode.last_changed, 0) }}"
last_departure_raw: "{{ states('input_datetime.vacation_house_sitter_last_departure') }}"
last_departure_ts: "{{ as_timestamp(last_departure_raw, 0) }}"
visit_number: "{{ (states('sensor.vacation_house_sitter_visit_count') | int(0)) + 1 }}"
away_duration: >-
{% set seconds = (as_timestamp(now()) - as_timestamp(states.group.family.last_changed, 0)) | int(0) %}
{% set days = (seconds // 86400) | int(0) %}
{% set hours = ((seconds % 86400) // 3600) | int(0) %}
{% set minutes = ((seconds % 3600) // 60) | int(0) %}
{% if days > 0 %}
{{ days }} day{{ 's' if days != 1 else '' }}{% if hours > 0 %} and {{ hours }} hour{{ 's' if hours != 1 else '' }}{% endif %}
{% elif hours > 0 %}
{{ hours }} hour{{ 's' if hours != 1 else '' }}{% if minutes > 0 %} and {{ minutes }} minute{{ 's' if minutes != 1 else '' }}{% endif %}
{% else %}
{{ minutes }} minute{{ 's' if minutes != 1 else '' }}
{% endif %}
last_visit_gap: >-
{% set gap_seconds = (as_timestamp(now()) - (last_departure_ts | float(0))) | int(0) %}
{% set hours = (gap_seconds // 3600) | int(0) %}
{% set minutes = ((gap_seconds % 3600) // 60) | int(0) %}
{% if hours > 0 %}
{{ hours }} hour{{ 's' if hours != 1 else '' }}{% if minutes > 0 %} and {{ minutes }} minute{{ 's' if minutes != 1 else '' }}{% endif %}
{% else %}
{{ minutes }} minute{{ 's' if minutes != 1 else '' }}
{% endif %}
visit_context: >-
{% if (last_departure_ts | float(0)) >= (vacation_start_ts | float(0)) %}
This is visit number {{ visit_number }} for this vacation. The last visit ended about {{ last_visit_gap }} ago.
{% else %}
This is the first house-sitter visit for this vacation.
{% endif %}
carlo_location: >-
{% set person_state = states('person.carlo') %}
{% set place = states('sensor.carlo_place') %}
{% set label = place if place not in ['unknown', 'unavailable', 'none', ''] else person_state %}
{% if person_state == 'driving' or label.startswith('Driving') %}
driving near {{ label | replace('Driving near ', '') | replace('Driving', '') | trim }}
{% elif person_state == 'home' %}
at Bear Stone home
{% elif 'Dorm' in label %}
away at {{ label }}
{% else %}
at {{ label }}
{% endif %}
stacey_location: >-
{% set person_state = states('person.stacey') %}
{% set place = states('sensor.stacey_place') %}
{% set label = place if place not in ['unknown', 'unavailable', 'none', ''] else person_state %}
{% if person_state == 'driving' or label.startswith('Driving') %}
driving near {{ label | replace('Driving near ', '') | replace('Driving', '') | trim }}
{% elif person_state == 'home' %}
at Bear Stone home
{% elif 'Dorm' in label %}
away at {{ label }}
{% else %}
at {{ label }}
{% endif %}
justin_location: >-
{% set person_state = states('person.justin') %}
{% set place = states('sensor.justin_place') %}
{% set label = place if place not in ['unknown', 'unavailable', 'none', ''] else person_state %}
{% if person_state == 'driving' or label.startswith('Driving') %}
driving near {{ label | replace('Driving near ', '') | replace('Driving', '') | trim }}
{% elif person_state == 'home' %}
at Bear Stone home
{% elif 'Dorm' in label %}
away at {{ label }}
{% else %}
at {{ label }}
{% endif %}
paige_location: >-
{% set person_state = states('person.paige') %}
{% set place = states('sensor.paige_place') %}
{% set label = place if place not in ['unknown', 'unavailable', 'none', ''] else person_state %}
{% if person_state == 'driving' or label.startswith('Driving') %}
driving near {{ label | replace('Driving near ', '') | replace('Driving', '') | trim }}
{% elif person_state == 'home' %}
at Bear Stone home
{% elif 'Dorm' in label %}
away at {{ label }}
{% else %}
at {{ label }}
{% endif %}
garbage_message: >-
{% set day = now().strftime('%a') %}
{% if day in ['Tue', 'Sat'] %}
If you have a chance, please take the garbage cans out tonight.
{% elif day in ['Wed', 'Sun'] %}
If the garbage cans are still outside today, please bring them back in.
{% else %}
{% endif %}
package_message: >-
{% if trigger.id == 'garage' and is_state('binary_sensor.front_door_packages_present', 'on') %}
Please also check whether any packages are waiting at the front door.
{% else %}
{% endif %}
arrival_message: >-
House sitter arrival detected through the {{ entry_label }}.
The family was last home {{ away_duration }} ago.
{{ visit_context }}
Carlo is {{ carlo_location }}. Stacey is {{ stacey_location }}.
Justin is {{ justin_location }}. Paige is {{ paige_location }}.
Please check Molly's food, water, and litter box.
{{ package_message }}
{{ garbage_message }}
push_message: >-
House sitter arrival detected via the {{ entry_label }} after {{ away_duration }} away.
{{ visit_context }}
Carlo={{ carlo_location }}, Stacey={{ stacey_location }}, Justin={{ justin_location }}, Paige={{ paige_location }}.
Molly reminder is included.
{{ package_message }}
{{ garbage_message }}
- delay: "{{ entry_delay }}"
- condition: template
value_template: >-
{{ is_state('group.family', 'not_home')
and is_state('input_boolean.vacation_mode', 'on')
and is_state('input_boolean.house_sitter_present', 'off') }}
- condition: template
value_template: >-
{% set vacation_start = as_timestamp(states.input_boolean.vacation_mode.last_changed, 0) %}
{% set departure_ts = as_timestamp(states('input_datetime.vacation_house_sitter_last_departure'), 0) %}
{{ departure_ts < vacation_start or (as_timestamp(now()) - departure_ts) >= 900 }}
- service: input_boolean.turn_on
entity_id:
- input_boolean.house_sitter_present
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.vacation_house_sitter_last_arrival
data:
timestamp: "{{ now().timestamp() }}"
- service: automation.trigger
target:
entity_id: automation.late_night_helper
data:
skip_condition: false
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.id == 'front_door_unlock' }}"
sequence:
- service: automation.trigger
target:
entity_id: automation.late_night_helper_outside
data:
skip_condition: false
- service: script.send_to_logbook
data:
topic: HOUSE SITTER
message: >-
House sitter arrival inferred from the {{ entry_label }} after {{ away_duration }} of family absence.
{{ visit_context }}
- service: script.notify_engine
data:
title: House sitter arrival
value1: "{{ push_message }}"
who: carlo
group: information
level: active
- service: script.speech_processing
data:
media_player: media_player.livingroomcc
speech_direct: true
speech_message: "{{ arrival_message }}"
- alias: 'Vacation Mode Sitter Checklist Follow-Up'
id: 4bd37a05-e6b6-493f-9ddb-fc8d9781c4df
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: input_boolean.house_sitter_present
to: 'on'
for: "00:10:00"
condition:
- condition: template
value_template: >-
{{ is_state('input_boolean.vacation_mode', 'on')
and is_state('input_boolean.house_sitter_present', 'on') }}
action:
- variables:
garage_status: >-
{% if is_state('group.garage_doors', 'open') %}
If the garage door is still open, please close it before you leave.
{% else %}
The garage doors already look closed.
{% endif %}
checklist_message: >-
Quick reminder. Please check Molly's food, water, and litter box.
{{ garage_status }}
The front door should auto-lock when you leave.
- service: script.speech_processing
data:
media_player: media_player.livingroomcc
speech_direct: true
speech_message: "{{ checklist_message }}"
- alias: 'Vacation Mode House Sitter Visit Timeout'
id: b7c03da2-9017-4524-8202-e93f5a6dd742
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: input_boolean.house_sitter_present
to: 'on'
for: "03:00:00"
condition:
- condition: template
value_template: >-
{{ is_state('group.family', 'not_home')
and is_state('input_boolean.vacation_mode', 'on')
and is_state('input_boolean.house_sitter_present', 'on') }}
action:
- variables:
visit_count: "{{ states('sensor.vacation_house_sitter_visit_count') | int(0) }}"
visit_minutes_numeric: >-
{% set seconds = (as_timestamp(now()) - as_timestamp(states.input_boolean.house_sitter_present.last_changed, 0)) | int(0) %}
{{ (seconds / 60) | round(1) }}
- service: script.vacation_house_sitter_clear_presence
data:
visit_minutes: "{{ visit_minutes_numeric }}"
departure_timestamp: "{{ now().timestamp() }}"
clear_reason: timeout
- service: script.send_to_logbook
data:
topic: HOUSE SITTER
message: >-
House sitter presence timed out after {{ visit_minutes_numeric }} minutes because no departure door or garage close was detected.
Visit count this vacation is now {{ visit_count }}.
- service: script.notify_engine
data:
title: House sitter visit timeout
value1: >-
House sitter presence was still active after {{ visit_minutes_numeric }} minutes, so it was cleared as a stale visit.
who: carlo
group: information
level: active
- alias: 'Vacation Mode House Sitter Departure'
id: 04f5ab9e-65a8-4cd5-a8e9-0f40c82a2f62
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: group.garage_doors
to: 'closed'
for: "00:00:15"
id: garage
- platform: state
entity_id: binary_sensor.mcu1_gpio5
to: 'off'
for: "00:00:02"
id: front_door
condition:
- condition: template
value_template: >-
{% set seconds = as_timestamp(now()) - as_timestamp(states.input_boolean.house_sitter_present.last_changed, 0) %}
{{ is_state('input_boolean.house_sitter_present', 'on')
and seconds >= 60 }}
action:
- variables:
exit_label: >-
{{ 'garage door' if trigger.id == 'garage' else 'front door' }}
visit_count: "{{ states('sensor.vacation_house_sitter_visit_count') | int(0) }}"
visit_minutes_numeric: >-
{% set seconds = (as_timestamp(now()) - as_timestamp(states.input_boolean.house_sitter_present.last_changed, 0)) | int(0) %}
{{ (seconds / 60) | round(1) }}
visit_duration: >-
{% set seconds = (as_timestamp(now()) - as_timestamp(states.input_boolean.house_sitter_present.last_changed, 0)) | int(0) %}
{% set minutes = (seconds // 60) | int(0) %}
{% set remainder = (seconds % 60) | int(0) %}
{{ minutes }} minute{{ 's' if minutes != 1 else '' }}{% if remainder > 0 %} and {{ remainder }} second{{ 's' if remainder != 1 else '' }}{% endif %}
- service: script.vacation_house_sitter_clear_presence
data:
visit_minutes: "{{ visit_minutes_numeric }}"
departure_timestamp: "{{ now().timestamp() }}"
clear_reason: "{{ trigger.id }}"
- service: script.send_to_logbook
data:
topic: HOUSE SITTER
message: >-
House sitter departure inferred when the {{ exit_label }} closed after {{ visit_duration }}.
Visit count this vacation is now {{ visit_count }}.
- service: script.notify_engine
data:
title: House sitter left
value1: >-
House sitter presence was cleared after the {{ exit_label }} closed about {{ visit_duration }} into visit number {{ visit_count }}.
who: carlo
group: information
level: active
- alias: 'Vacation Mode Secure House Check'
id: 5c4f6a2d-d976-4f9f-b204-ab444b24d76f
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: input_boolean.house_sitter_present
from: 'on'
to: 'off'
for: "00:25:00"
condition:
- condition: template
value_template: >-
{{ is_state('input_boolean.vacation_mode', 'on')
and is_state('input_boolean.house_sitter_present', 'off') }}
action:
- variables:
visit_count: "{{ states('sensor.vacation_house_sitter_visit_count') | int(0) }}"
visit_minutes: "{{ state_attr('sensor.vacation_house_sitter_analytics', 'last_visit_minutes') | float(0) }}"
front_door_issue: "{{ '' if is_state('lock.front_door', 'locked') else 'front door is ' ~ states('lock.front_door') }}"
garage_issue: "{{ 'a garage door is open' if is_state('group.garage_doors', 'open') else '' }}"
entry_issue: "{{ 'an entry point is still open' if is_state('group.entry_points', 'on') else '' }}"
issue_count: >-
{{ [front_door_issue, garage_issue, entry_issue] | reject('equalto', '') | list | count }}
unsecured_message: >-
{% set items = [front_door_issue, garage_issue, entry_issue] | reject('equalto', '') | list %}
{% if items | count > 0 %}
{{ items | join(', ') }}
{% else %}
all entry points are secure
{% endif %}
joanna_message: >-
Vacation house check after a sitter visit found: {{ unsecured_message }}.
Visit count this vacation: {{ visit_count }}.
Last visit duration: {{ visit_minutes | round(1) }} minutes.
Front door state: {{ states('lock.front_door') }}.
Garage state: {{ states('group.garage_doors') }}.
Entry points state: {{ states('group.entry_points') }}.
- choose:
- conditions:
- condition: template
value_template: "{{ issue_count | int(0) > 0 }}"
sequence:
- service: script.notify_engine
data:
title: Vacation secure-house alert
value1: >-
After the sitter left, {{ unsecured_message }}. Last visit was {{ visit_minutes | round(1) }} minutes.
who: carlo
group: information
level: critical
- service: script.joanna_send_telegram
data:
message: "{{ joanna_message }}"
- service: script.send_to_logbook
data:
topic: VACATION MODE
message: >-
Secure-house check failed after sitter departure because {{ unsecured_message }}.
default:
- service: script.send_to_logbook
data:
topic: VACATION MODE
message: >-
Secure-house check passed 25 minutes after the sitter left.
- alias: 'Vacation Mode Missed Visit Alert'
id: 9f83b8cf-57ef-45b3-b72b-ea6f6c8446ec
mode: single
max_exceeded: silent
trigger: