-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_update_scheduled.yaml
More file actions
1815 lines (1660 loc) · 70 KB
/
auto_update_scheduled.yaml
File metadata and controls
1815 lines (1660 loc) · 70 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
####################################################################################################
##### Home Assistant Auto-update on Schedule #####
##### Repository: https://github.com/edwardtfn/ha_auto_update_scheduled #####
####################################################################################################
##### Purpose: YAML blueprint to automatically update Home Assistant and its components when #####
##### updates are available, following a schedule and with configurable options. #####
####################################################################################################
##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo #####
####################################################################################################
##### NOTE: #####
##### - Home Assistant may restart automatically as part of the update process. #####
##### - Use under your own risk! Please review Home Assistant community discussions about #####
##### the risks involved in auto-updating the system. #####
##### - SECURITY WARNING: #####
##### - Ensure you have reliable backups before enabling automatic updates #####
##### - Auto-updates in production environments may lead to system instability #####
##### - Updates may affect connected devices and integrations #####
##### - For discussions: #####
##### https://community.home-assistant.io/t/459281 #####
##### - For support, bug reports and new ideas: #####
##### https://github.com/edwardtfn/ha_auto_update_scheduled/issues #####
####################################################################################################
---
blueprint:
name: Home Assistant Auto-update on a schedule base
author: Edward Firmo (https://github.com/edwardtfn)
homeassistant:
min_version: 2026.2.0
description: >
# JV Auto-update
Update Home Assistant automatically when a new update is available.
## v2026.2.1
## Attention:
- Home Assistant may restart automatically as part of the update process.
- **Use under your own risk!** Please see the discussions on Home Assistant community around the risks involved on auto-updating the system.
- Ensure you have reliable backups before enabling automatic updates.
- Auto-updates in production environments may lead to system instability.
- Updates may affect connected devices and integrations.
## For discussions:
- [Home Assistant Community portal](https://community.home-assistant.io/t/459281)
## For support, bug reports and new ideas:
- [GitHub Issues](https://github.com/edwardtfn/ha_auto_update_scheduled/issues)
domain: automation
source_url: https://raw.githubusercontent.com/edwardtfn/ha_auto_update_scheduled/main/auto_update_scheduled.yaml
input:
when_section:
name: When (Schedule, etc.)
icon: mdi:calendar
description: Select when the updates should happen and when it should be skipped.
collapsed: false
input:
schedule_entity:
name: Schedule entity
description: >
You can create a [Schedule](https://www.home-assistant.io/integrations/schedule) under
[Settings > Devices & Services > Helpers](https://my.home-assistant.io/redirect/config_flow_start/?domain=schedule).
Note => The schedule windows will define when an update will start.
It is possible that a backup, an update or a restart process finishes after the schedule window,
but new updates won't start outside the schedule windows.
default: []
selector:
entity:
multiple: false
domain: schedule
schedule_monthday_earliest:
name: Earliest day in the month to run the update process
description: >
Usually a new major version of Home Assistant is available on the begining of every month.
Some people consider those releases as not stable enough and prefer to avoid those versions,
not updating the system until the mid of the month (day 15).
Notes:
- If you select a day higher than 28 the updates won't run every month.
- Selecting `0` will disable the check.
default: 0
selector:
number:
min: 1
max: 31
step: 1
mode: slider
schedule_monthday_last:
name: Latest day in the month to run the update process
description: >
Specify the latest day in month, on which this update can run.
Note:
- Selecting `0` or a date lower than the "Earliest Day" will disable the check.
default: 0
selector:
number:
min: 0
max: 31
step: 1
mode: slider
update_out_of_schedule:
name: Out of schedule entities
description: |
`Optional`
You can select update entities which will be updated as soon an update is detected,
even if outside the schedule windows.
Notes:
- Pause entities will be respected and prevent the update of the out of schedule entities.
- The out of schedule update can trigger a restart at an unexpected time outside the normal schedule.
Please use it with caution.
default: []
selector:
entity:
multiple: true
domain:
- update
pause_entities:
name: Pause update entities
description: |
`Optional`
You can select one or more entities to pause the updates.
If any of the selected entities is "On" or "True" the system won't be updated on the schedule time.
You can use this to hold your updates when you have a party at home,
or when you are on vacations and don't want to be concerned about updates on Home Assistant.
default: []
selector:
entity:
multiple: true
domain:
- input_boolean
- binary_sensor
- switch
what_section:
name: What (optional)
icon: mdi:update
description: Select what should be updated and what shouldn't be updated.
collapsed: true
input:
core_os_update_mode:
name: Update mode for Home Assistant core and OS updates
description: >
Please select the update mode for Home Assistant core and Home Assistan OS updates.
* All: All updates will be installed.
* Patches only:
✅ From 2022.11.0 to 2022.11.3 will be updated (patches).
❌ From 2022.11.x to 2022.12.x will be ignored (minor update).
❌ From 2022.12.x to 2023.1.x will be ignored (major update).
* Don't update: Ignore any update.
default: "all"
selector: &update_mode-selector
select:
multiple: false
options:
- label: All
value: "all"
- label: Patches only
value: "patches"
- label: Don't update
value: "ignore"
firmware_update_mode:
name: Update mode for device's firmware
description: >
Please select the update mode for firmware in the devices connected to Home Assistant (when supported as an HA update).
* All: All updates will be installed.
* Patches only:
✅ From 2022.11.0 to 2022.11.3 will be updated (patches).
❌ From 2022.11.x to 2022.12.x will be ignored (minor update).
❌ From 2022.12.x to 2023.1.x will be ignored (major update).
* Don't update: Ignore any update.
default: "all"
selector: *update_mode-selector
general_update_mode:
name: Update mode for general updates
description: >
Please select the update mode for everything that is not a device's firmware or a core component of Home Assistant.
This includes add-ons, HACS componentes, custom cards, etc.
* All: All updates will be installed.
* Patches only:
✅ From 2022.11.0 to 2022.11.3 will be updated (patches).
❌ From 2022.11.x to 2022.12.x will be ignored (minor update).
❌ From 2022.12.x to 2023.1.x will be ignored (major update).
* Don't update: Ignore any update.
default: "all"
selector: *update_mode-selector
update_inclusion_mode:
name: Entity Inclusion Mode
description: >-
Please select the entity inclusion mode.
* All:
Just build the update entity list from all available update.* entities, which are in state 'on'.
* Specified/Specified-Single:
Build the update entity list from the specified entity list, filtering for entities in 'on' state.
- Specified: Updates all matching entities
- Specified-Single: Updates only the first matching entity
* Searchfilter:
This works as a wildcard filter.
Examples:
'update.zigbee2mqtt_' => all update entities from zigbee2mqtt addon
'update.esphome_' => all update entities from esphome devices if their names start with 'esphome_'
* Searchfilter-Single:
Just like the searchfilter, but only the first entity. (Sorted alphabetically)
default: "all"
selector:
select:
multiple: false
options:
- label: All
value: "all"
- label: Specified
value: "specified"
- label: Specified-Single
value: "specified-single"
- label: Searchfilter
value: "searchfilter"
- label: Searchfilter-Single
value: "searchfilter-single"
update_inclusion_entity_list:
name: Entity Inclusion List
description: >-
=> Important: This entity list will only be used when the Update Inclusion mode is set to "Specified" or "Specified-Single".
Select the items which should be updated.
default: []
selector:
entity:
multiple: true
domain: update
update_inclusion_entity_searchfilter:
name: Entity Inclusion Searchfilter
description: >-
=> Important: This searchfilter will only be used when the Update Inclusion mode is set to "Searchfilter" or "Searchfilter-Single".
This defines the Searchfilter for finding the right update entities.
This enables wildcard-like searching for a group of entities, aka "all zigbee entities" or "everything from Sonoff" etc.
default: ""
selector:
text:
multiline: false
update_exclusions:
name: Exclusions
description: |
`Optional`
Select the items that should NOT be included on the automated updates.
=> Use this if you want to keep some add-on on an specific version and avoid auto-updates to it.
default: []
selector:
entity:
multiple: true
domain: update
backup_section:
name: Backup (optional)
icon: mdi:backup-restore
description: Select the back-up options
collapsed: true
input:
run_during_backup:
name: Backup state sensor
description: |
`Optional`
Is a sensor is selected, this automation will run only when that sensor reports backup state as `idle`.
No update will be executed while the backup state sensor is in any other state or "unavailable".
If no sensor is selected, this automation won't pause due to a backup in progress.
default: []
selector:
entity:
multiple: false
filter:
domain: sensor
device_class: enum
integration: backup
backup_bool:
name: Create a full backup before start the updates?
default: true
selector:
boolean:
last_backup_timestamp_entity:
name: Last successful automatic backup sensor
description: |
`Optional`
default: []
selector:
entity:
multiple: false
filter:
domain: sensor
device_class: timestamp
integration: backup
backup_timeout:
name: Backup Timeout
description: >-
Specify how much time the automation waits for the backup process.
We can't check whether the backup was successful.
Per default we wait 1 hour to finish the backup.
default: 60
selector:
number:
mode: box
min: 1
max: 180
unit_of_measurement: minutes
max_backup_age:
name: Maximum backup age (or zero, to disable)
description: |
`Optional`
This requires the [Google Drive Backup](https://github.com/sabeechen/hassio-google-drive-backup)
addon to be installed and configured to automatically backup, and provide
a sensor with the backup states. The setting only checks for the age of
the automatic backups from that addon, not the backups created internally
by this blueprint.
default:
days: 0
hours: 0
minutes: 0
seconds: 0
selector:
duration:
enable_day: true
backup_location:
name: Backup Location
description: |
You can create a new backup location under [Settings > System > Storage](https://my.home-assistant.io/redirect/storage/).
Specify where to store the backup for this autoupdate process.
default: "/backup"
selector:
backup_location:
actions_section:
name: Actions (optional)
icon: mdi:shoe-print
description: Select actions to run at diferent moments on the update process
collapsed: true
input:
actions_pre_update:
name: Pre-update actions
description: |
`Optional`
Actions to execute before the backup or any update starts.
You can use this to send notifications, turn on/off devices or activate scenes before starting the updates.
Note => Please be aware that all actions will run right before the update process,
which can happens over-night. Take this in account when selecting your actions.
Note => Some usefull variables available for your actions:
- "`\{\{ updates_list \}\}`" - contains the list of updates when the automation started.
- "`\{\{ updates_pending \}\}`" - contains the list of updates remaining to be updated.
default: []
selector:
action: {}
actions_pre_restart:
name: Pre-restart actions
description: |
`Optional`
Actions to execute before the automation requests a restart.
You can use this to send notifications,
turn on/off devices or stopping automations before restarting Home Assistant.
Note => Please be aware that all actions will run right before the restart process,
which can happens over-night. Take this in account when selecting your actions.
Note => Note all the restarts will be controlled by this automation,
like when a Core update is installed. These actions might not be executed in those cases.
Note => Some usefull variables available for your actions:
- "`\{\{ updates_list \}\}`" - contains the list of updates when the automation started.
- "`\{\{ updates_pending \}\}`" - contains the list of updates remaining to be updated.
default: []
selector:
action: {}
actions_pos_update:
name: Post-update actions
description: |
`Optional`
Actions to execute AFTER the update process finishes.
You can use this to send notifications, turn on/off devices or activate scenes after applying the updates.
Note => Please be aware that all actions will run right after the update process,
which can happens over-night.
Take this in account when selecting your actions.
Note => Some usefull variables available for your actions:
- "`\{\{ updates_list \}\}`" - contains the list of updates when the automation started.
- "`\{\{ updates_pending \}\}`" - contains the list of updates remaining to be updated.
**IMPORTANT** => Some updates will automatically restart Home Assistant,
causing the automation to interrupt before finishing, preventing the pos-updates actions to be executed.
If you have critical actions to run after an update,
consider including also in another automation based on Home Assistant start.
default: []
selector:
action: {}
notification_section:
name: Notifications (optional)
icon: mdi:bell
description: Here you can setup optional notifications. Enter a notify service to enable notifications.
collapsed: true
input:
notification_entity:
name: Notify service
description: >
Enter a notify service to send messages to (for example:
notify.mobile_app_my_phone, notify.telegram).
Leave empty to disable notifications.
default: ""
selector:
text:
multiline: false
notification_message_title:
name: Notification title
description: |
`Optional`
Please select a title to be used on each notification message.
You can type a custom text.
default: friendly_name
selector:
select:
custom_value: true
multiple: false
options:
- label: Automation's friendly name
value: friendly_name
- label: Automation's entity Id
value: entity_id
- label: Blank (no title)
value: blank
notification_select_notifications:
name: Select what to notify
description: |
Select which steps should trigger notifications.
default:
- starting
- list_of_updates
- pre_update_actions
- backup
- update_progress
- remaining_updates
- restart
- post_update_actions
- done
selector:
select:
multiple: true
options:
- label: (Re-)Starting message
value: starting
- label: List of updates
value: list_of_updates
- label: Pre-update actions
value: pre_update_actions
- label: Backup
value: backup
- label: Update progress
value: update_progress
- label: Remaining updates
value: remaining_updates
- label: Restart
value: restart
- label: Post-update actions
value: post_update_actions
- label: Done message
value: done
general_settings:
name: General settings (optional)
icon: mdi:cog
description: Select additional settings to the update process
collapsed: true
input:
restart_type:
name: Force Home Assistant to restart if required by any update?
description: >
This won't affect updates where a restart is automatic,
but for updates requiring a manual restart (quite common on HACS)
this blueprint can automatically force a restart by the end of the updates.
default: "no-restart"
selector:
select:
multiple: false
options:
- label: "Don't force a restart"
value: "no-restart"
- label: "Restart Home Assistant core"
value: "core"
- label: "Restart Home Assistant host"
value: "host"
verbose_logging_bool:
name: Log addon progress with verbosity to the logbook?
description: |
`Optional`
When enabled, this automation will register each step on the logbook.
This can be usefull for troubleshooting, but at normal conditions, it won't add much value.
default: false
selector:
boolean: {}
update_process_started_entity:
name: '"Update Process Started" Toggle Entity'
description: |
`Optional`
You can create a [Toggle Helper](https://www.home-assistant.io/integrations/input_boolean) under
[Settings > Devices & Services > Helpers](https://my.home-assistant.io/redirect/config_flow_start/?domain=input_boolean).
This entity will be used to determine if we still have to do a backup
on automation start - so it is for inner workings of this automation.
This saves you from getting multiple backups in the same update window.
default: []
selector:
entity:
multiple: false
domain: input_boolean
update_timeout:
name: Update Timeout
description: |
Maximum time to wait for each update to complete.
This protects the automation of waiting forever for an update that fails.
Usually updates don't take that very long,
so feel free to ajust this time to something that fits better your environment.
The default is 1200 seconds (20 minutes).
You can select any value between 10 seconds and 7200 seconds (2 hours).
If an update times out:
- The automation will log an error message
- The automation will continue with the next update
- The timed-out update may still complete in the background
default: 1200
selector:
number:
min: 10
max: 7200
step: 10
unit_of_measurement: seconds
mode: box
mode: single
max_exceeded: warning
trigger_variables:
input_pause_entities: !input pause_entities
input_update_exclusions: !input update_exclusions
schedule_monthday_earliest: !input schedule_monthday_earliest
schedule_monthday_last: !input schedule_monthday_last
input_schedule_monthday_earliest: '{{ schedule_monthday_earliest | int(0) }}'
input_schedule_monthday_last: '{{ schedule_monthday_last | int(0) }}'
input_update_inclusion_entity_list: !input update_inclusion_entity_list
input_update_inclusion_entity_searchfilter: !input update_inclusion_entity_searchfilter
input_update_process_started_entity: !input update_process_started_entity
update_out_of_schedule: !input update_out_of_schedule
trigger:
- id: HA Schedule based
platform: state
entity_id: !input schedule_entity
- id: HA Start
platform: homeassistant
event: start
- id: New update
platform: template
value_template: >-
{{
states.update
| default([])
| selectattr("state", "eq", "on")
| rejectattr("entity_id", "in", input_update_exclusions)
| rejectattr("entity_id", "in", update_out_of_schedule)
| list | count | int(0) > 0
}}
- id: New day
platform: template
value_template: >
{{
(now().day >= input_schedule_monthday_earliest or input_schedule_monthday_earliest == 0) and
(
now().day <= input_schedule_monthday_last or
input_schedule_monthday_last == 0 or
input_schedule_monthday_last < input_schedule_monthday_earliest
)
}}
- id: Automations reloaded
platform: event
event_type: automation_reloaded
- id: Pause entities changed
platform: state
entity_id: !input pause_entities
- id: Out of schedule
platform: state
entity_id: !input update_out_of_schedule
from: "off"
to: "on"
condition:
- condition: or
conditions:
- condition: trigger
id: "Out of schedule"
- condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: "HA Start"
- condition: trigger
id: "Automations reloaded"
- condition: template
value_template: >-
{{
states.update
| default([])
| selectattr("state", "eq", "on")
| selectattr("entity_id", "in", update_out_of_schedule)
| rejectattr("entity_id", "in", input_update_exclusions)
| list | count | int(0) > 0
}}
- condition: and
conditions:
- condition: state
entity_id: !input schedule_entity
state: 'on'
- condition: template
value_template: >-
{{
states.update
| default([])
| selectattr("state", "eq", "on")
| rejectattr("entity_id", "in", input_update_exclusions)
| list | count | int(0) > 0
}}
- condition: and
conditions:
- condition: trigger
id: "HA Start"
- '{{ input_update_process_started_entity | default([]) | count == 1 }}'
- condition: state
entity_id: !input update_process_started_entity
state: "on"
- condition: or
conditions:
- condition: trigger
id: "Out of schedule"
- condition: template
value_template: >
{{
(now().day >= input_schedule_monthday_earliest or input_schedule_monthday_earliest == 0) and
(now().day <= input_schedule_monthday_last or input_schedule_monthday_last == 0)
}}
- condition: or
conditions:
- "{{ input_pause_entities | default([]) | list | count | int(0) < 1 }}"
- condition: state
entity_id: !input pause_entities
state: 'off'
variables:
temp_input_update_exclusions: !input update_exclusions
input_verbose_logging_bool: !input verbose_logging_bool
input_core_os_update_mode: !input core_os_update_mode
input_firmware_update_mode: !input firmware_update_mode
input_general_update_mode: !input general_update_mode
input_update_inclusion_mode: !input update_inclusion_mode
input_notification_entity_raw: !input notification_entity
input_notification_entity: >-
{% if input_notification_entity_raw is string %}
{{ input_notification_entity_raw }}
{% else %}
{{ input_notification_entity_raw | first | default('') }}
{% endif %} input_notification_select_notifications: !input notification_select_notifications
input_notification_message_title: !input notification_message_title
core_update_entity: >
{% for u in integration_entities('hassio') | select('search', '^update[.]')
if (device_attr(u, 'identifiers') | first | default(""))[1] == 'core' %}
{{ u }}
{% endfor %}
os_update_entity: >
{% for u in integration_entities('hassio') | select('search', '^update[.]')
if (device_attr(u, 'identifiers') | first | default(""))[1] == 'OS' %}
{{ u }}
{% endfor %}
supervisor_update_entity: >
{% for u in integration_entities('hassio') | select('search', '^update[.]')
if (device_attr(u, 'identifiers') | first | default(""))[1] == 'supervisor' %}
{{ u }}
{% endfor %}
is_resume_after_restart: >
{{
input_update_process_started_entity | default([]) | count == 1 and
is_state(input_update_process_started_entity | first | default(""), "on")
}}
is_out_of_schedule_mode: >
{{
trigger.id == "Out of schedule" or
(
(trigger.id == "HA Start" or trigger.id == "Automations reloaded") and
(
states.update
| default([])
| selectattr("state", "eq", "on")
| selectattr("entity_id", "in", update_out_of_schedule)
| rejectattr("entity_id", "in", input_update_exclusions)
| list | count | int(0) > 0
)
)
}}
friendly_name: |
{% set friendly_name_tmp = state_attr(this.entity_id, "friendly_name") | default("") %}
{{
friendly_name_tmp
if friendly_name_tmp is string and friendly_name_tmp | length > 0
else "Auto-update"
}}
is_telegram_notify: >
{{
input_notification_entity is string and
input_notification_entity | length > 0 and
'telegram' in input_notification_entity.lower()
}}
notification_title: |
{% if (input_notification_message_title == "friendly_name") %}
{{ friendly_name }}
{% elif (input_notification_message_title == "entity_id") %}
{{ this.entity_id }}
{% elif (input_notification_message_title != "blank" and
input_notification_message_title is string and
input_notification_message_title | length > 0) %}
{{ input_notification_message_title }}
{% else %}
{{ "" }}
{% endif %}
action:
- alias: Refresh update entities
action: homeassistant.update_entity
data:
entity_id: |
{{
states.update
| default([])
| rejectattr('entity_id', 'in', input_update_exclusions)
| map(attribute='entity_id')
| list
}}
continue_on_error: true
- &recalc_update_list
variables:
firmware_update_entities: >
{% if is_out_of_schedule_mode %}
{# For out-of-schedule triggers, return empty list #}
{# The update_out_of_schedule list will be added to combined_list directly #}
[]
{% else %}
{{
states.update
| default([])
| selectattr("state", "eq", "on")
| selectattr('attributes.device_class', 'defined')
| selectattr('attributes.device_class', 'eq', 'firmware')
| rejectattr('entity_id', 'in', input_update_exclusions)
| map(attribute='entity_id')
| list
}}
{% endif %}
general_update_entities: >
{% if is_out_of_schedule_mode %}
{# For out-of-schedule triggers, return empty list #}
{# The update_out_of_schedule list will be added to combined_list directly #}
[]
{% elif input_update_inclusion_mode == "all" %}
{{
states.update
| default([])
| selectattr('state', 'eq', 'on')
| rejectattr('entity_id', 'in', core_update_entity)
| rejectattr('entity_id', 'in', os_update_entity)
| rejectattr('entity_id', 'in', supervisor_update_entity)
| rejectattr('entity_id', 'in', firmware_update_entities)
| rejectattr('entity_id', 'in', input_update_exclusions)
| map(attribute='entity_id')
| list
}}
{% elif input_update_inclusion_mode == "specified" %}
{{
states.update
| default([])
| selectattr('state', 'eq', 'on')
| selectattr('entity_id', 'in', input_update_inclusion_entity_list)
| rejectattr('entity_id', 'in', core_update_entity)
| rejectattr('entity_id', 'in', os_update_entity)
| rejectattr('entity_id', 'in', supervisor_update_entity)
| rejectattr('entity_id', 'in', firmware_update_entities)
| rejectattr('entity_id', 'in', input_update_exclusions)
| map(attribute='entity_id')
| list
}}
{% elif input_update_inclusion_mode == "specified-single" %}
{{
states.update
| default([])
| selectattr('state', 'eq', 'on')
| selectattr('entity_id', 'in', input_update_inclusion_entity_list)
| rejectattr('entity_id', 'in', core_update_entity)
| rejectattr('entity_id', 'in', os_update_entity)
| rejectattr('entity_id', 'in', supervisor_update_entity)
| rejectattr('entity_id', 'in', firmware_update_entities)
| rejectattr('entity_id', 'in', input_update_exclusions)
| map(attribute='entity_id')
| list
| first
| default("")
}}
{% elif input_update_inclusion_mode == "searchfilter" %}
{{
states.update
| default([])
| selectattr('state', 'eq', 'on')
| selectattr('entity_id', 'match', input_update_inclusion_entity_searchfilter)
| rejectattr('entity_id', 'in', core_update_entity)
| rejectattr('entity_id', 'in', os_update_entity)
| rejectattr('entity_id', 'in', supervisor_update_entity)
| rejectattr('entity_id', 'in', firmware_update_entities)
| rejectattr('entity_id', 'in', input_update_exclusions)
| map(attribute='entity_id')
| list
}}
{% elif input_update_inclusion_mode == "searchfilter-single" %}
{{
states.update
| default([])
| selectattr('state', 'eq', 'on')
| selectattr('entity_id', 'match', input_update_inclusion_entity_searchfilter)
| rejectattr('entity_id', 'in', core_update_entity)
| rejectattr('entity_id', 'in', os_update_entity)
| rejectattr('entity_id', 'in', supervisor_update_entity)
| rejectattr('entity_id', 'in', firmware_update_entities)
| rejectattr('entity_id', 'in', input_update_exclusions)
| map(attribute='entity_id')
| list
| first
| default("")
}}
{% endif %}
input_update_exclusions: >
{% set exclusions = temp_input_update_exclusions | default([]) %}
{% if input_core_os_update_mode == 'ignore' %}
{% set exclusions = exclusions + [core_update_entity | default(""), os_update_entity | default("")] %}
{% else %}
{% set core_installed_version = states.update
| default([])
| selectattr('entity_id', 'in', core_update_entity | default(""))
| map(attribute='attributes.installed_version')
| list
| first
| default('') %}
{% set core_latest_version = states.update
| default([])
| selectattr('entity_id', 'in', core_update_entity | default(""))
| map(attribute='attributes.latest_version')
| list
| first
| default('') %}
{% set core_version_change = version(core_latest_version) - version(core_installed_version) %}
{% set os_installed_version = states.update
| default([])
| selectattr('entity_id', 'in', os_update_entity | default(""))
| map(attribute='attributes.installed_version')
| list
| first
| default('') %}
{% set os_latest_version = states.update
| default([])
| selectattr('entity_id', 'in', os_update_entity | default(""))
| map(attribute='attributes.latest_version')
| list
| first
| default('') %}
{% set os_version_change = version(os_latest_version) - version(os_installed_version) %}
{% if input_core_os_update_mode == 'patches' %}
{% if core_version_change.major or
core_version_change.minor or
(not core_version_change.patch) %}
{% set exclusions = exclusions + [core_update_entity | default("")] %}
{% endif %}
{% if os_version_change.major or
os_version_change.minor or
(not os_version_change.patch) %}
{% set exclusions = exclusions + [os_update_entity | default("")] %}
{% endif %}
{% elif input_core_os_update_mode == 'major_and_minor' %}
{% if (not core_version_change.major) and (not core_version_change.minor) %}
{% set exclusions = exclusions + [core_update_entity | default("")] %}
{% endif %}
{% if (not os_version_change.major) and (not os_version_change.minor) %}
{% set exclusions = exclusions + [os_update_entity | default("")] %}
{% endif %}
{% endif %}
{% endif %}
{% if input_firmware_update_mode == 'ignore' %}
{% set exclusions = exclusions + [ firmware_update_entities ] %}
{% else %}
{% set ns = namespace(entities = []) %}
{% for entity in expand(firmware_update_entities)
| rejectattr('entity_id', 'in', exclusions)
| selectattr('state', 'eq', 'on') %}
{% set entity_version_change = version(entity.attributes.latest_version | default(''))
- version(entity.attributes.installed_version | default('')) %}
{% if input_firmware_update_mode == 'patches' %}
{% if entity_version_change.major or
entity_version_change.minor or
(not entity_version_change.patch) %}
{% set ns.entities = ns.entities + [ entity.entity_id ] %}
{% endif %}
{% elif input_firmware_update_mode == 'major_and_minor' %}
{% if (not entity_version_change.major) and (not entity_version_change.minor) %}
{% set ns.entities = ns.entities + [ entity.entity_id ] %}
{% endif %}
{% endif %}
{% endfor %}
{% set exclusions = exclusions + [ ns.entities ] %}
{% endif %}
{% if input_general_update_mode == 'ignore' %}
{% set exclusions = exclusions + [ general_update_entities ] %}
{% else %}
{% set ns = namespace(entities = []) %}
{% for entity in expand(general_update_entities)
| rejectattr('entity_id', 'in', exclusions)
| selectattr('state', 'eq', 'on') %}
{% set entity_version_change = version(entity.attributes.latest_version | default(''))
- version(entity.attributes.installed_version | default('')) %}
{% if input_general_update_mode == 'patches' %}
{% if entity_version_change.major or
entity_version_change.minor or