Repository navigation
Expand file tree
/
Copy pathautomations.yaml
More file actions
2011 lines (1940 loc) · 66.9 KB
/
Copy pathautomations.yaml
File metadata and controls
2011 lines (1940 loc) · 66.9 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
- id: ida_knapp_rullgardin
alias: Ida knapp - Rullgardin
description: Styr Idas rullgardin med knapp
use_blueprint:
path: custom/blind_button_control.yaml
input:
mqtt_topic: zigbee2mqtt/Ida tryckknapp/action
cover_entity: cover.idas_rullgardin
down_position: 0
up_position: 100
- id: moa_knapp_rullgardin
alias: Moa knapp - Rullgardin
description: Styr Moas rullgardin med knapp
use_blueprint:
path: custom/blind_button_control.yaml
input:
mqtt_topic: zigbee2mqtt/Moa tryckknapp/action
cover_entity: cover.moas_rullgardin
down_position: 0
up_position: 100
- id: gastrum_knapp_gardiner
alias: Gästrum knapp - Gardiner
description: Styr Gästrums gardiner med knapp
use_blueprint:
path: custom/blind_button_control.yaml
input:
mqtt_topic: zigbee2mqtt/Gästrum tryckknapp/action
cover_entity: cover.gastrum_gardiner_ha
down_position: 0
up_position: 100
- id: git_pull_on_webhook
alias: Git - Pull vid GitHub push
description: Hämtar config från GitHub när webhook triggas, varnar om lokala ändringar
finns
trigger:
- platform: webhook
webhook_id: 60f082f2d2ff6fcb26bd51d7a79e3d22fb233ebbbf18b29d2ce7ce0cc2e588cc
allowed_methods:
- POST
local_only: false
action:
- service: shell_command.git_has_local_changes
response_variable: local_status
- variables:
has_local_changes: '{{ local_status.stdout | default('''') | length > 0 }}'
- if:
- condition: template
value_template: '{{ has_local_changes }}'
then:
- service: persistent_notification.create
data:
title: 'Git: Lokala ändringar upptäckta!'
message: 'Det finns lokala ändringar som inte pushats: {{ local_status.stdout
}}
Använd knappen "Git Push" för att pusha ändringarna innan pull.
'
notification_id: git_local_changes_warning
- service: shell_command.git_pull
response_variable: pull_result
- if:
- condition: template
value_template: '{{ pull_result.returncode != 0 }}'
then:
- service: persistent_notification.create
data:
title: Git Pull MISSLYCKADES
message: 'Git pull misslyckades: {{ now().strftime(''%Y-%m-%d %H:%M'') }}
Felkod: {{ pull_result.returncode }} {{ pull_result.stderr | default(pull_result.stdout)
| default(''Okänt fel'') }}
'
notification_id: git_pull_error
- stop: Git pull failed
- delay:
seconds: 2
- service: shell_command.git_diff_files
response_variable: git_diff
- variables:
changed_files: '{{ git_diff.stdout | default('''') }}'
z2m_changed: '{{ ''zigbee2mqtt/'' in changed_files }}'
automations_changed: '{{ ''automations.yaml'' in changed_files }}'
scripts_changed: '{{ ''scripts.yaml'' in changed_files }}'
scenes_changed: '{{ ''scenes.yaml'' in changed_files }}'
- if:
- condition: template
value_template: '{{ automations_changed }}'
then:
- service: automation.reload
- if:
- condition: template
value_template: '{{ scripts_changed }}'
then:
- service: script.reload
- if:
- condition: template
value_template: '{{ scenes_changed }}'
then:
- service: scene.reload
- if:
- condition: template
value_template: '{{ z2m_changed }}'
then:
- service: hassio.addon_restart
data:
addon: 45df7312_zigbee2mqtt
- service: persistent_notification.create
data:
title: Git Pull
message: 'Config uppdaterad: {{ now().strftime(''%Y-%m-%d %H:%M'') }} {% if
automations_changed %}✓ Automations{% endif %} {% if scripts_changed %}✓ Scripts{%
endif %} {% if scenes_changed %}✓ Scenes{% endif %} {% if z2m_changed %}✓
Zigbee2MQTT{% endif %} {% if not (automations_changed or scripts_changed or
scenes_changed or z2m_changed) %}(inga reloads behövdes){% endif %}
'
notification_id: git_pull_status
mode: single
- id: git_pull_on_startup
alias: Git - Pull vid uppstart
description: Hämtar senaste config från GitHub när HA startar
trigger:
- platform: homeassistant
event: start
action:
- delay:
seconds: 30
- service: shell_command.git_pull
response_variable: pull_result
- if:
- condition: template
value_template: '{{ pull_result.returncode != 0 }}'
then:
- service: persistent_notification.create
data:
title: Uppstart Git Pull MISSLYCKADES
message: 'Git pull vid uppstart misslyckades: {{ now().strftime(''%Y-%m-%d
%H:%M'') }}
Felkod: {{ pull_result.returncode }} {{ pull_result.stderr | default(pull_result.stdout)
| default(''Okänt fel'') }}
'
notification_id: git_pull_startup_error
else:
- service: persistent_notification.create
data:
title: Uppstart Git Pull
message: 'Config synkad från GitHub vid uppstart: {{ now().strftime(''%Y-%m-%d
%H:%M'') }}'
notification_id: git_pull_startup
mode: single
- id: git_pull_scheduled
alias: Git - Schemalagd pull
description: 'Backup: hämtar config från GitHub var 6:e timme'
trigger:
- platform: time_pattern
hours: /6
action:
- service: shell_command.git_pull
response_variable: pull_result
- if:
- condition: template
value_template: '{{ pull_result.returncode != 0 }}'
then:
- service: persistent_notification.create
data:
title: Schemalagd Git Pull MISSLYCKADES
message: 'Git pull misslyckades: {{ now().strftime(''%Y-%m-%d %H:%M'') }}
Felkod: {{ pull_result.returncode }} {{ pull_result.stderr | default(pull_result.stdout)
| default(''Okänt fel'') }}
'
notification_id: git_pull_scheduled_error
mode: single
- id: claude_snapshot_on_demand
alias: Claude - Generate Snapshot
description: Generates a live HA snapshot for Claude Desktop when button is pressed
trigger:
- platform: event
event_type: call_service
event_data:
domain: input_button
service: press
service_data:
entity_id: input_button.generate_claude_snapshot
action:
- service: script.generate_claude_snapshot
mode: single
- id: effekt_peak_varning
alias: Effekt - Varning vid ny topp
description: Varnar när nuvarande effekt närmar sig eller överskrider 5:e högsta
toppen
trigger:
- platform: numeric_state
entity_id: sensor.smart_meter_ts_65a_3_aktiv_effekt
above: 1
id: check_peak
condition:
- condition: template
value_template: '{% set current_w = states(''sensor.smart_meter_ts_65a_3_aktiv_effekt'')
| float(0) %} {% set current_kw = current_w / 1000 %} {% set fifth_peak_kw =
states(''sensor.peak_power_5th_highest'') | float(0) %} {% set threshold_kw
= fifth_peak_kw * 0.9 %} {{ current_kw >= threshold_kw and fifth_peak_kw > 0
}}
'
action:
- variables:
current_w: '{{ states(''sensor.smart_meter_ts_65a_3_aktiv_effekt'') | float(0)
}}'
current_kw: '{{ (current_w / 1000) | round(2) }}'
fifth_peak_kw: '{{ states(''sensor.peak_power_5th_highest'') | float(0) }}'
avg_peak_kw: '{{ states(''sensor.peak_power_top_5_average'') | float(0) }}'
is_new_peak: '{{ (current_w / 1000) > fifth_peak_kw | float(0) }}'
month: '{{ now().month }}'
rate: '{{ 22 if month >= 4 and month <= 10 else 43 }}'
extra_cost: '{{ (((current_w / 1000) - avg_peak_kw) * rate) | round(2) if is_new_peak
else 0 }}'
- service: persistent_notification.create
data:
title: '{% if is_new_peak %}NY EFFEKTTOPP!{% else %}Varning: Hög effekt{% endif
%}
'
message: 'Nuvarande effekt: {{ current_kw }} kW 5:e högsta topp: {{ fifth_peak_kw
}} kW Snitt topp 5: {{ avg_peak_kw }} kW {% if is_new_peak %} Uppskattad extra
månadskostnad: {{ extra_cost }} kr {% endif %} Minska förbrukningen genom
att stänga av tunga laster!
'
notification_id: effekt_peak_warning
- service: notify.mobile_app_petter_iphone
data:
title: '{% if is_new_peak %}NY EFFEKTTOPP!{% else %}Hög effekt{% endif %}
'
message: '{{ current_kw }} kW {% if is_new_peak %}(+{{ extra_cost }} kr/mån){%
endif %} Minska förbrukningen!
'
data:
push:
sound:
name: default
critical: 1
volume: 0.5
tag: effekt_peak_warning
mode: single
- id: git_push_on_button
alias: Git - Push lokala ändringar
description: Pushar lokala config-ändringar till GitHub vid knapptryck (kräver att
ospårade filer hanteras först)
trigger:
- platform: state
entity_id: input_button.git_push
action:
- service: shell_command.git_untracked_files
response_variable: untracked_result
- variables:
has_untracked: '{{ untracked_result.stdout | default('''') | length > 0 }}'
untracked_files: '{{ untracked_result.stdout | default('''') }}'
- if:
- condition: template
value_template: '{{ has_untracked }}'
then:
- service: persistent_notification.create
data:
title: 'Git: Ospårade filer!'
message: 'Det finns ospårade filer som måste hanteras innan push:
{{ untracked_files }}
Lägg till dem i git eller .gitignore först.
'
notification_id: git_push_status
- stop: Untracked files exist
- service: shell_command.git_has_local_changes
response_variable: local_status
- variables:
has_local_changes: '{{ local_status.stdout | default('''') | length > 0 }}'
changed_files: '{{ local_status.stdout | default('''') }}'
- if:
- condition: template
value_template: '{{ not has_local_changes }}'
then:
- service: persistent_notification.create
data:
title: Git Push
message: Inga lokala ändringar att pusha.
notification_id: git_push_status
- stop: No local changes
- service: shell_command.git_smart_commit_push
response_variable: push_result
- service: persistent_notification.create
data:
title: Git Push
message: '{% if push_result.returncode == 0 %} {{ push_result.stdout }}
Filer: {{ changed_files }} {% else %} Push misslyckades: {{ push_result.stderr
| default(push_result.stdout) }} {% endif %}
'
notification_id: git_push_status
mode: single
- id: git_untracked_files_notification
alias: Git - Notifiera om ospårade filer
description: Kontrollerar efter nya filer som inte spåras av git och frågar vad
som ska göras
trigger:
- platform: time_pattern
hours: /6
- platform: homeassistant
event: start
action:
- delay:
seconds: 60
- service: shell_command.git_untracked_files
response_variable: untracked_result
- variables:
has_untracked: '{{ untracked_result.stdout | default('''') | length > 0 }}'
untracked_files: '{{ untracked_result.stdout | default('''') }}'
file_count: '{{ untracked_result.stdout.strip().split(''
'') | length if untracked_result.stdout else 0 }}'
- if:
- condition: template
value_template: '{{ has_untracked }}'
then:
- service: notify.mobile_app_petter_iphone
data:
title: 'Git: {{ file_count }} ospårade filer'
message: 'Nya filer upptäckta: {{ untracked_files }}
Lägg till i git eller .gitignore?
'
data:
actions:
- action: GIT_ADD_FILES
title: Lägg till i git
- action: GIT_IGNORE_FILES
title: Lägg till i .gitignore
- action: GIT_IGNORE_NOTIFICATION
title: Ignorera
tag: git_untracked_files
mode: single
- id: git_untracked_files_response
alias: Git - Hantera svar om ospårade filer
description: Hanterar användarens val för ospårade filer
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: GIT_ADD_FILES
- platform: event
event_type: mobile_app_notification_action
event_data:
action: GIT_IGNORE_FILES
action:
- service: shell_command.git_untracked_files
response_variable: untracked_result
- variables:
files: '{{ untracked_result.stdout | default('''') }}'
action: '{{ trigger.event.data.action }}'
- if:
- condition: template
value_template: '{{ action == ''GIT_ADD_FILES'' }}'
then:
- service: shell_command.git_add_file
data:
file: '{{ files.replace(''
'', '' '') }}'
- service: persistent_notification.create
data:
title: Git
message: 'Filer tillagda i git: {{ files }}'
notification_id: git_untracked_response
- if:
- condition: template
value_template: '{{ action == ''GIT_IGNORE_FILES'' }}'
then:
- repeat:
for_each: '{{ files.strip().split(''
'') }}'
sequence:
- service: shell_command.git_ignore_file
data:
file: '{{ repeat.item }}'
- service: persistent_notification.create
data:
title: Git
message: 'Filer tillagda i .gitignore: {{ files }}'
notification_id: git_untracked_response
mode: single
- id: hoger_kyl_dorr_blueprint
alias: Kök kyl höger - Dörr öppen (blueprint)
description: Varnar om höger kyldörr varit öppen för länge
use_blueprint:
path: custom/appliance_door_warning.yaml
input:
door_sensor: binary_sensor.hoger_kyl_door_open
appliance_name: Höger kyl
door_open_minutes: 11
notify_service: notify.vitvaror_varningar
critical_sound: true
- id: vanster_kyl_dorr_blueprint
alias: Kök kyl vänster - Dörr öppen (blueprint)
description: Varnar om vänster kyldörr varit öppen för länge
use_blueprint:
path: custom/appliance_door_warning.yaml
input:
door_sensor: binary_sensor.vanster_kyl_door_open
appliance_name: Vänster kyl
door_open_minutes: 11
notify_service: notify.vitvaror_varningar
critical_sound: true
- id: hoger_kyl_fridge_temp_blueprint
alias: Kök kyl höger - Kylskåp temp (blueprint)
description: Varnar om höger kylskåp är för varmt
use_blueprint:
path: custom/appliance_temp_warning.yaml
input:
temp_sensor: sensor.hoger_kyl_fridge_temp
climate_entity: climate.hoger_kyl_fridge
appliance_name: Höger kylskåp
temp_threshold: 5
default_target_temp: 4
duration_minutes: 10
notify_service: notify.vitvaror_varningar
- id: hoger_kyl_freezer_temp_blueprint
alias: Kök kyl höger - Frys temp (blueprint)
description: Varnar om höger frys är för varm
use_blueprint:
path: custom/appliance_temp_warning.yaml
input:
temp_sensor: sensor.hoger_kyl_freezer_temp
climate_entity: climate.hoger_kyl_freezer
appliance_name: Höger frys
temp_threshold: 5
default_target_temp: -18
duration_minutes: 10
notify_service: notify.vitvaror_varningar
- id: vanster_kyl_fridge_temp_blueprint
alias: Kök kyl vänster - Kylskåp temp (blueprint)
description: Varnar om vänster kylskåp är för varmt
use_blueprint:
path: custom/appliance_temp_warning.yaml
input:
temp_sensor: sensor.vanster_kyl_fridge_temp
climate_entity: climate.vanster_kyl_fridge
appliance_name: Vänster kylskåp
temp_threshold: 5
default_target_temp: 4
duration_minutes: 10
notify_service: notify.vitvaror_varningar
- id: vanster_kyl_freezer_temp_blueprint
alias: Kök kyl vänster - Frys temp (blueprint)
description: Varnar om vänster frys är för varm
use_blueprint:
path: custom/appliance_temp_warning.yaml
input:
temp_sensor: sensor.vanster_kyl_freezer_temp
climate_entity: climate.vanster_kyl_freezer
appliance_name: Vänster frys
temp_threshold: 5
default_target_temp: -18
duration_minutes: 10
notify_service: notify.vitvaror_varningar
- id: solceller_stoppa_export_lagt_pris
alias: Solceller - Stoppa export vid lågt pris
description: Begränsar solcellsexport till 0% när elpriset understiger prisgränsen
trigger:
- platform: state
entity_id: binary_sensor.export_pris_for_lagt
to: 'on'
- platform: state
entity_id: input_boolean.export_begransning_aktiv
to: 'on'
condition:
- condition: state
entity_id: input_boolean.export_begransning_aktiv
state: 'on'
- condition: state
entity_id: input_boolean.solceller_export_begransad
state: 'off'
- condition: state
entity_id: binary_sensor.export_pris_for_lagt
state: 'on'
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.solceller_export_begransad
- service: modbus.write_register
data:
hub: fronius
address: 40236
unit: 1
value: 0
- service: modbus.write_register
data:
hub: fronius
address: 40246
unit: 1
value: 1
- service: notify.mobile_app_petter_iphone
data:
title: Solceller begränsade
message: 'Elpris {{ states(''sensor.nordpool_kwh_se3_sek_3_10_025'') }} SEK/kWh
(gräns: {{ states(''input_number.export_begransning_pris'') }} SEK/kWh)
'
mode: single
- id: solceller_aterstall_export
alias: Solceller - Återställ export
description: Återställer normal export när priset är över gränsen eller funktionen
stängs av
trigger:
- platform: state
entity_id: binary_sensor.export_pris_for_lagt
to: 'off'
- platform: state
entity_id: input_boolean.export_begransning_aktiv
to: 'off'
condition:
- condition: state
entity_id: input_boolean.solceller_export_begransad
state: 'on'
- condition: or
conditions:
- condition: state
entity_id: input_boolean.export_begransning_aktiv
state: 'off'
- condition: state
entity_id: binary_sensor.export_pris_for_lagt
state: 'off'
action:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.solceller_export_begransad
- service: modbus.write_register
data:
hub: fronius
address: 40246
unit: 1
value: 0
- service: notify.mobile_app_petter_iphone
data:
title: Solceller återställda
message: 'Elpris {{ states(''sensor.nordpool_kwh_se3_sek_3_10_025'') }} SEK/kWh
- normal produktion
'
mode: single
- id: solceller_startup_sync
alias: Solceller - Synka vid uppstart
description: Säkerställer att Modbus-register matchar input_boolean vid HA-start
trigger:
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: input_boolean.export_begransning_aktiv
state: 'on'
action:
- delay:
seconds: 60
- if:
- condition: state
entity_id: input_boolean.solceller_export_begransad
state: 'on'
then:
- service: modbus.write_register
data:
hub: fronius
address: 40236
unit: 1
value: 0
- service: modbus.write_register
data:
hub: fronius
address: 40246
unit: 1
value: 1
else:
- service: modbus.write_register
data:
hub: fronius
address: 40246
unit: 1
value: 0
mode: single
- id: vatten_lackage_natt
alias: Vatten - Läckagevarning natt
description: Varnar om vatten rinner kontinuerligt under natten (01-05) i mer än
30 minuter
trigger:
- platform: state
entity_id: binary_sensor.vatten_rinner
to: 'on'
for:
minutes: 30
condition:
- condition: time
after: 01:00:00
before: 05:00:00
action:
- service: notify.mobile_app_petter_iphone
data:
title: Vattenläckage?
message: 'Vatten har runnit i över 30 minuter ({{ states(''sensor.water_meter_t_display_current_water_flow'')
}} L/h). Kontrollera toaletter, kranar och varmvattenberedare!
'
data:
push:
sound:
name: default
critical: 1
volume: 1.0
tag: vatten_lackage
- service: persistent_notification.create
data:
title: Vattenläckage?
message: 'Vatten har runnit kontinuerligt sedan {{ (now() - timedelta(minutes=30)).strftime(''%H:%M'')
}}. Flöde: {{ states(''sensor.water_meter_t_display_current_water_flow'')
}} L/h Daglig förbrukning: {{ states(''sensor.vattenforbrukning_dag'') }}
L
'
notification_id: vatten_lackage
mode: single
- id: vatten_lackage_dag
alias: Vatten - Läckagevarning dag
description: Varnar om vatten rinner kontinuerligt under dagen (05-01) i mer än
60 minuter
triggers:
- entity_id:
- binary_sensor.vatten_rinner
to:
- 'on'
for:
hours: 1
minutes: 0
seconds: 0
trigger: state
conditions:
- condition: time
after: 05:00:00
before: 01:00:00
actions:
- data:
title: Möjligt vattenläckage
message: 'Vatten har runnit i över 60 minuter ({{ states(''sensor.water_meter_t_display_current_water_flow'')
}} L/h). Kontrollera kranar, toaletter och varmvattenberedare.
'
data:
tag: vatten_lackage_dag
action: notify.mobile_app_petter_iphone
- data:
title: Möjligt vattenläckage
message: 'Vatten har runnit kontinuerligt sedan {{ (now() - timedelta(minutes=60)).strftime(''%H:%M'')
}}. Flöde: {{ states(''sensor.water_meter_t_display_current_water_flow'')
}} L/h Daglig förbrukning: {{ states(''sensor.vattenforbrukning_dag'') }}
L
'
notification_id: vatten_lackage_dag
action: persistent_notification.create
mode: single
- id: smartplug_child_lock_startup
alias: Smartplugs - Lås fysisk knapp vid uppstart
description: Sätter child_lock på smartplugs som endast används för mätning
trigger:
- platform: homeassistant
event: start
action:
- delay:
seconds: 60
- service: mqtt.publish
data:
topic: zigbee2mqtt/Frys/set
payload: '{"child_lock": "LOCK"}'
- service: mqtt.publish
data:
topic: zigbee2mqtt/Network/set
payload: '{"child_lock": "LOCK"}'
mode: single
- id: dorrklocka_spela_ljud
alias: Dörrklocka - Spela ljud i alla högtalare
description: Spelar dörrklocksljud via Music Assistant när någon ringer på dörren
triggers:
- entity_id: event.ringklocka_dorrklocka
trigger: state
not_from:
- unavailable
- unknown
conditions:
- condition: state
entity_id: event.ringklocka_dorrklocka
attribute: event_type
state: ring
actions:
- target:
entity_id:
- media_player.koket
- media_player.vardagsrum_ljud
- media_player.garage
- media_player.partyrummet
data:
media_content_id: http://192.168.1.60:8123/local/media/doorbell.mp3
media_content_type: music
action: media_player.play_media
mode: single
- id: dammsugare_schema_vardagar
alias: Dammsugare - Städa vardagar
description: Startar dammsugaren vardagar kl 10 när ingen är hemma
trigger:
- platform: time
at: '10:00:00'
condition:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: state
entity_id: person.petter_sandholdt
state: not_home
- condition: state
entity_id: person.nora_sandholdt
state: not_home
- condition: numeric_state
entity_id: sensor.roborock_de_118057288_s5_battery_level_p_3_1
above: 50
action:
- service: vacuum.start
target:
entity_id: vacuum.roborock_de_118057288_s5
mode: single
- id: dammsugare_klar_notis
alias: Dammsugare - Notis när städning klar
description: Skickar notis när dammsugaren är klar och åkt tillbaka till dockan
trigger:
- platform: state
entity_id: vacuum.roborock_de_118057288_s5
from: returning
to: docked
action:
- service: notify.mobile_app_petter_iphone
data:
title: Gun Gun klar
message: Dammsugaren har städat klart och är tillbaka i dockan.
mode: single
- id: dammsugare_fel_notis
alias: Dammsugare - Notis vid fel
description: Skickar notis om dammsugaren fastnat eller har ett fel
trigger:
- platform: state
entity_id: vacuum.roborock_de_118057288_s5
to: error
- platform: state
entity_id: vacuum.roborock_de_118057288_s5
to: idle
for:
minutes: 5
condition:
- condition: not
conditions:
- condition: state
entity_id: vacuum.roborock_de_118057288_s5
state: docked
action:
- service: notify.mobile_app_petter_iphone
data:
title: Gun Gun behöver hjälp
message: 'Dammsugaren har stannat ({{ states(''vacuum.roborock_de_118057288_s5'')
}}). Batteri: {{ states(''sensor.roborock_de_118057288_s5_battery_level_p_3_1'')
}}%'
mode: single
- id: dammsugare_lagt_batteri_notis
alias: Dammsugare - Notis vid lågt batteri
description: Varnar om dammsugaren har lågt batteri och inte laddar
trigger:
- platform: numeric_state
entity_id: sensor.roborock_de_118057288_s5_battery_level_p_3_1
below: 20
for:
minutes: 10
condition:
- condition: not
conditions:
- condition: state
entity_id: sensor.roborock_de_118057288_s5_charging_state_p_3_2
state: Charging
action:
- service: notify.mobile_app_petter_iphone
data:
title: Gun Gun lågt batteri
message: Dammsugaren har bara {{ states('sensor.roborock_de_118057288_s5_battery_level_p_3_1')
}}% batteri kvar och laddar inte.
mode: single
- id: swedish_calendar_morning_notification
alias: Kalender - Morgonnotis speciella dagar
description: Skickar notis på morgonen med temadagar och namnsdagar
trigger:
- platform: time
at: 07:00:00
condition:
- condition: template
value_template: "{% set theme_day = states('sensor.swedish_calendar_theme_day')
%} {% set name_day = states('sensor.swedish_calendar_name_day') %} {{ theme_day
not in ['unknown', 'unavailable', '']\n or name_day not in ['unknown', 'unavailable',
''] }}\n"
action:
- service: notify.mobile_app_petter_iphone
data:
title: "\U0001F4C5 {{ now().strftime('%d/%m') }}"
message: '{% set theme_day = states(''sensor.swedish_calendar_theme_day'') %}
{% set name_day = states(''sensor.swedish_calendar_name_day'') %} {% set themes
= theme_day.split('','') | map(''trim'') | list if theme_day not in [''unknown'',
''unavailable'', ''''] else [] %} {% set names = [''Namnsdag: '' ~ name_day]
if name_day not in [''unknown'', ''unavailable'', ''''] else [] %} {{ (themes
+ names) | join(''\n'') }}
'
data:
url: /calendar
mode: single
- id: igrill_maltemperatur_nadd
alias: iGrill - Måltemperatur nådd
description: Notifierar när någon iGrill-prob når måltemperaturen
trigger:
- platform: template
value_template: "{% set target = states('input_number.igrill_maltemperatur') |
float(0) %} {% set probes = [\n states('sensor.bluetooth_proxy_igrill_prob_1')
| float(0),\n states('sensor.bluetooth_proxy_igrill_prob_2') | float(0),\n
\ states('sensor.bluetooth_proxy_igrill_prob_3') | float(0),\n states('sensor.bluetooth_proxy_igrill_prob_4')
| float(0)\n] %} {{ probes | select('gt', 0) | select('ge', target) | list |
count > 0 }}\n"
condition:
- condition: numeric_state
entity_id: input_number.igrill_maltemperatur
above: 0
action:
- service: notify.mobile_app_petter_iphone
data:
title: iGrill - Måltemperatur nådd!
message: "{% set target = states('input_number.igrill_maltemperatur') | float(0)
%} {% set probes = {\n 'Prob 1': states('sensor.bluetooth_proxy_igrill_prob_1')
| float(0),\n 'Prob 2': states('sensor.bluetooth_proxy_igrill_prob_2') |
float(0),\n 'Prob 3': states('sensor.bluetooth_proxy_igrill_prob_3') | float(0),\n
\ 'Prob 4': states('sensor.bluetooth_proxy_igrill_prob_4') | float(0)\n} %}
{% for name, temp in probes.items() if temp >= target %} {{ name }}: {{ temp
}}°C (mål: {{ target | int }}°C) {% endfor %}\n"
data:
push:
sound:
name: default
critical: 1
volume: 1.0
mode: single
- id: rullgardiner_keepalive
alias: Rullgardiner - Keepalive varannan dag
description: Rör alla rullgardiner varannan dag för att hålla Zigbee-kontakten vid
liv
trigger:
- platform: time
at: '14:00:00'
condition:
- condition: template
value_template: '{{ now().timetuple().tm_yday % 2 == 0 }}'
action:
- service: cover.set_cover_position
target:
entity_id:
- cover.idas_rullgardin
- cover.moas_rullgardin
- cover.gastrum_hoger_gardin
- cover.gastrum_vanster_gardin
data:
position: 98
- delay:
seconds: 30
- service: cover.set_cover_position
target:
entity_id:
- cover.idas_rullgardin
- cover.moas_rullgardin
- cover.gastrum_hoger_gardin
- cover.gastrum_vanster_gardin
data:
position: 100
mode: single
- id: las_garage_nar_bada_dorrar_lasta
alias: Garage - Lås när entre och groventre låsta
description: Lås garagedörren automatiskt när både entredörr och groventre är låsta
triggers:
- entity_id:
- lock.entre
- lock.groventre
to: locked
trigger: state
conditions:
- condition: state
entity_id: lock.entre
state:
- locked
- condition: state
entity_id: lock.groventre
state: locked
- condition: state
entity_id: lock.garagedorr
state:
- unlocked
actions:
- target:
entity_id: lock.garagedorr
action: lock.lock
data: {}
mode: single
- id: gordon_gps_tracker
alias: Gordon - uppdatera GPS-tracker
description: Uppdaterar device_tracker.gordon (kartmarkör) OCH sparar senast kända
position i persistenta helpers. Gordon syns alltid på kartan — klipper, dockad,
fastnat. Status-filter borttaget; håll bara koll på giltiga koordinater + jitter.
triggers:
- trigger: state
entity_id: sensor.gordon_latitude
id: moved
- trigger: state
entity_id: sensor.gordon_longitude
id: moved
- trigger: time_pattern
minutes: /15
id: keepalive
conditions:
- condition: template
value_template: "{{ states('sensor.gordon_latitude') not in ['unavailable','unknown','none']\n
\ and states('sensor.gordon_longitude') not in ['unavailable','unknown','none']\n
\ and states('sensor.gordon_latitude') | float(0) | abs > 1\n and states('sensor.gordon_longitude')
| float(0) | abs > 1 }}\n"
- condition: template
value_template: "{% if trigger.id == 'keepalive' %}\n true\n{% else %}\n {%
set pla = state_attr('device_tracker.gordon', 'latitude') %}\n {% set plo =
state_attr('device_tracker.gordon', 'longitude') %}\n {{ pla is none or plo
is none\n or distance(states('sensor.gordon_latitude') | float,\n states('sensor.gordon_longitude')
| float,\n pla, plo) | float(0) * 1000 > 3 }}\n{% endif %}\n"
actions:
- action: input_number.set_value
target:
entity_id: input_number.gordon_last_lat
data:
value: '{{ states(''sensor.gordon_latitude'') | float }}'
- action: input_number.set_value
target:
entity_id: input_number.gordon_last_lon
data:
value: '{{ states(''sensor.gordon_longitude'') | float }}'
- action: mqtt.publish
data:
topic: ha/gordon/gps/attributes
retain: true
payload: "{{ {'latitude': states('sensor.gordon_latitude') | float,\n 'longitude':
states('sensor.gordon_longitude') | float,\n 'gps_accuracy': 5,\n 'battery_level':
states('sensor.automower_battery_0') | int(0),\n 'satellites': states('sensor.gordon_gps')
| int(0)} | to_json }}\n"
mode: queued
max: 10
- id: gordon_fel_notis
alias: Gordon - Notis vid fel
description: Notifierar när Gordon fastnat, hamnat utanför området eller annars
behöver hjälp
triggers:
- trigger: state
entity_id: sensor.automower_mower_status
to: '7'
for:
seconds: 30
- trigger: state
entity_id: sensor.automower_mower_status
to: '8'
for:
seconds: 30
actions:
- action: notify.mobile_app_petter_iphone
data:
title: Gordon behöver hjälp
message: '{% set msg = states(''sensor.automower_mower_error_message'') %} {%
set code = states(''sensor.automower_mower_error_code'') %} {% if msg not
in [''unknown'', ''unavailable'', ''''] %}{{ msg }}{% else %}Fel{% endif %}