- id: asuswrt_cpu_temp alias: 𐃏 Asuswrt CPU Temperature description: '' triggers: - trigger: numeric_state entity_id: sensor.asuswrt_cpu_temperature above: '80' condition: [] actions: - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟡 Asuswrt CPU Temp. = {{ states('sensor.asuswrt_cpu_temperature') }}°C - wait_template: '{{ states( ''sensor.asuswrt_cpu_temperature'' ) | float < 75 }}' - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟢 Asuswrt CPU Temp. = {{ states('sensor.asuswrt_cpu_temperature') }}°C mode: single max_exceeded: silent - id: asuswrt_24ghz_temp alias: 𐃏 Asuswrt 2.4GHz Temperature description: '' triggers: - trigger: numeric_state entity_id: sensor.asuswrt_2_4ghz_temperature above: '60' condition: [] actions: - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟡 Asuswrt 2.4GHz Temp. = {{ states('sensor.asuswrt_2_4ghz_temperature') }}°C - wait_template: '{{ states( ''sensor.asuswrt_2_4ghz_temperature'' ) | float < 55 }}' - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟢 Asuswrt 2.4GHz Temp. = {{ states('sensor.asuswrt_2_4ghz_temperature') }}°C mode: single max_exceeded: silent - id: asuswrt_5ghz_temp alias: 𐃏 Asuswrt 5GHz Temperature description: '' triggers: - trigger: numeric_state entity_id: sensor.asuswrt_5ghz_temperature above: '60' condition: [] actions: - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟡 Asuswrt 5GHz Temp. = {{ states('sensor.asuswrt_5ghz_temperature') }}°C - wait_template: '{{ states( ''sensor.asuswrt_5ghz_temperature'' ) | float < 55 }}' - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟢 Asuswrt 2.4GHz Temp. = {{ states('sensor.asuswrt_5ghz_temperature') }}°C mode: single max_exceeded: silent - id: low_batteries alias: 𐃏 Low Batteries mode: restart trigger: - trigger: state entity_id: sensor.low_batteries to: null - trigger: state entity_id: sensor.low_batteries_offset to: null - trigger: homeassistant event: start condition: - condition: template value_template: '{{ states.sensor.low_batteries.state is defined }}' - condition: template value_template: '{{ states.sensor.low_batteries_offset.state is defined }}' action: - delay: seconds: 1 - choose: - conditions: - condition: numeric_state entity_id: sensor.low_batteries above: '0' below: '2' - condition: template value_template: "{% if states('input_number.low_batteries_last_triggered')\ \ | int \n < states('sensor.low_batteries') | int %}\n true\n{% elif\ \ states('input_number.low_batteries_last_triggered') | int \n > states('sensor.low_batteries')\ \ | int \n and states('sensor.low_batteries') | int \n == states('sensor.low_batteries_offset')\ \ | int %}\n true\n{% else %}\n false\n{% endif %}" sequence: - delay: minutes: "{% if states.input_number.delay_notify_batteries.state is defined\ \ %}\n {% set minutes = states('input_number.delay_notify_batteries')\ \ | int %}\n{% else %}\n {% set minutes = 10 %}\n{% endif %} {{ minutes\ \ }}" - action: "{% if states.input_text.notify_service_batteries.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_batteries')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: '⚠️ Este un dispozitiv cu baterie descărcată: – {{ state_attr(''sensor.low_batteries'',''names'').split('','') | join('' –'') }} ' - action: input_number.set_value target: entity_id: input_number.low_batteries_last_triggered data: value: '{{ states(''sensor.low_batteries'') | int }}' - conditions: - condition: numeric_state entity_id: sensor.low_batteries above: '1' - condition: template value_template: "{% if states('input_number.low_batteries_last_triggered')\ \ | int \n < states('sensor.low_batteries') | int %}\n true\n{% elif\ \ states('input_number.low_batteries_last_triggered') | int \n > states('sensor.low_batteries')\ \ | int \n and states('sensor.low_batteries') | int \n == states('sensor.low_batteries_offset')\ \ | int %}\n true\n{% else %}\n false\n{% endif %}" sequence: - delay: minutes: "{% if states.input_number.delay_notify_batteries.state is defined\ \ %}\n {% set minutes = states('input_number.delay_notify_batteries')\ \ | int %}\n{% else %}\n {% set minutes = 10 %}\n{% endif %} {{ minutes\ \ }}" - action: "{% if states.input_text.notify_service_batteries.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_batteries')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: '⚠️ Sunt {{ states(''sensor.low_batteries'') | int }} dispozitive cu bateria descărcată: – {{ state_attr(''sensor.low_batteries'',''names'').split('','') | join('' –'') }} ' - action: input_number.set_value target: entity_id: input_number.low_batteries_last_triggered data: value: '{{ states(''sensor.low_batteries'') | int }}' - conditions: - condition: numeric_state entity_id: sensor.low_batteries_offset below: '1' - condition: template value_template: '{{ states(''input_number.low_batteries_last_triggered'') | int != states(''sensor.low_batteries'') | int }}' sequence: - action: "{% if states.input_text.notify_service_batteries.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_batteries')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: '🔋 Starea bateriilor este bună! ' - action: input_number.set_value target: entity_id: input_number.low_batteries_last_triggered data: value: '{{ states(''sensor.low_batteries'') | int }}' default: [] - id: restart_nginx_addon alias: 𐃏 Restart NginX Addon description: '' triggers: - trigger: time at: 05:00:00 condition: - condition: time weekday: - fri actions: - if: - condition: template value_template: '{{ states(''update.nginx_home_assistant_ssl_proxy_update'') is defined }}' then: - action: hassio.addon_restart data: addon: core_nginx_proxy mode: restart - id: problems_detected alias: 𐃏 Problems Detected mode: restart trigger: - trigger: state entity_id: sensor.problems_detected - trigger: homeassistant event: start - trigger: state entity_id: - input_boolean.maintenance_mode to: 'off' condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' - condition: template value_template: '{{ states.sensor.problems_detected.state is defined }}' action: - choose: - conditions: - condition: numeric_state entity_id: sensor.problems_detected above: '0' below: '2' - condition: template value_template: '{{ states(''input_number.problems_detected_last_triggered'') | int != states(''sensor.problems_detected'') | int }}' sequence: - delay: minutes: "{% if states.input_number.delay_notify_problems.state is defined\ \ %}\n {% set minutes = states('input_number.delay_notify_problems')\ \ | int %}\n{% else %}\n {% set minutes = 10 %}\n{% endif %} {{ minutes\ \ }}\n" - action: input_number.set_value target: entity_id: input_number.problems_detected_last_triggered data: value: '{{ states(''sensor.problems_detected'') | int }}' - action: "{% if states.input_text.notify_service_problems.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_problems')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}\n" data: message: '⚠️ Este o problema: – {{ state_attr(''sensor.problems_detected'',''names'').split('','') | join('' –'') }} ' - conditions: - condition: numeric_state entity_id: sensor.problems_detected above: '1' - condition: template value_template: '{{ states(''input_number.problems_detected_last_triggered'') | int != states(''sensor.problems_detected'') | int }} ' sequence: - delay: minutes: "{% if states.input_number.delay_notify_problems.state is defined\ \ %}\n {% set minutes = states('input_number.delay_notify_problems')\ \ | int %}\n{% else %}\n {% set minutes = 10 %}\n{% endif %} {{ minutes\ \ }}" - action: input_number.set_value target: entity_id: input_number.problems_detected_last_triggered data: value: '{{ states(''sensor.problems_detected'') | int }}' - action: "{% if states.input_text.notify_service_problems.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_problems')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: '⚠️ Sunt {{ states(''sensor.problems_detected'')|int }} probleme: – {{ state_attr(''sensor.problems_detected'',''names'').split('','') | join('' –'') }} ' - conditions: - condition: numeric_state entity_id: sensor.problems_detected below: '1' - condition: template value_template: '{{ states(''input_number.problems_detected_last_triggered'') | int > 0 }}' sequence: - action: "{% if states.input_text.notify_service_problems.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_problems')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: 👌 Probleme rezolvate! - action: input_number.set_value target: entity_id: input_number.problems_detected_last_triggered data: value: '{{ states(''sensor.problems_detected'') | int }}' default: [] - id: cpu_temp alias: 𐃏 CPU Temperature description: '' triggers: - trigger: numeric_state entity_id: sensor.processor_temperature above: '80' condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' actions: - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟡 CPU Temp. = {{ states('sensor.processor_temperature') }}°C - wait_template: '{{ states( ''sensor.processor_temperature'' ) | float < 70 }}' - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟢 CPU Temp. = {{ states('sensor.processor_temperature') }}°C mode: single max_exceeded: silent - id: update_on_server_stop alias: 𐃏 Update Packages on STOP description: '' triggers: - trigger: homeassistant event: shutdown - trigger: webhook allowed_methods: - PUT local_only: false webhook_id: secret update_packages_webhook condition: [] actions: - action: script.turn_on target: entity_id: script.update_packages - delay: seconds: 10 mode: single - id: server_start alias: 𐃏 Server Start description: '' triggers: - trigger: homeassistant event: start condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' actions: - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %}\n \n{{ notify_service }}" data: message: ▶️ Serverul a pornit mode: single - id: server_stop alias: 𐃏 Server Stop description: '' triggers: - trigger: homeassistant event: shutdown condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' actions: - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %}\n \n{{ notify_service }}" data: message: ⏹️ Serverul s-a oprit mode: single - id: healthchecks_update alias: 𐃏 HealthChecks description: '' triggers: - trigger: time_pattern minutes: /1 condition: [] actions: - action: rest_command.healthchecks mode: restart - id: failed_notification alias: 𐃏 Failed Notification description: Alert when a notification can't be sent. mode: single triggers: - trigger: event event_type: system_log_event event_data: level: ERROR conditions: - condition: template value_template: '{{ "Error sending message" in trigger.event.data.message[0] }}' enabled: true actions: - action: persistent_notification.create data: message: "A apărut o problemă la trimiterea unei notificari. Anunță echipa tehnică\ \ \n\n{{ trigger.event.data.message }}" title: Nu s-a putut trimite notificarea notification_id: failed_notification - id: update_packages alias: 𐃏 Update Packages description: '' triggers: - trigger: state entity_id: script.update_packages from: 'on' to: 'off' condition: [] actions: - delay: seconds: 10 - action: homeassistant.reload_all mode: restart - id: cpu_load_15m alias: 𐃏 CPU Load description: '' triggers: - trigger: numeric_state entity_id: sensor.load_15m above: '10' condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' actions: - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %}\n{{ notify_service }}" data: message: 🟡 CPU Load (15m) = {{ states('sensor.load_15m') }} - wait_template: '{{ states( ''sensor.load_15m'' ) | float < 4 }}' - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %}\n{{ notify_service }}" data: message: 🟢 CPU Load (15m) = {{ states('sensor.load_15m') }} mode: single max_exceeded: silent - id: ram_usage alias: 𐃏 RAM Usage description: '' triggers: - trigger: numeric_state entity_id: sensor.memory_use_percent above: '90' condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' actions: - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %}\n{{ notify_service }}" data: message: 🟡 RAM = {{ states('sensor.memory_use_percent') }}% - wait_template: '{{ states( ''sensor.memory_use_percent'' ) | float < 80 }}' - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟢 RAM = {{ states('sensor.memory_use_percent') }}% mode: single max_exceeded: silent - id: disk_usage alias: 𐃏 Disk Usage description: '' triggers: - trigger: numeric_state entity_id: sensor.disk_use_percent above: '70' condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' actions: - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟡 Disk = {{ states('sensor.disk_use_percent') }}% - wait_template: '{{ states( ''sensor.disk_use_percent'' ) | float < 60 }}' - action: "{% if states.input_text.notify_service_server.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service_server') %}\n{%\ \ elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: 🟢 Disk = {{ states('sensor.disk_use_percent') }}% mode: restart - id: maintenance_on_off alias: 𐃏 Maintenance ON/OFF description: '' triggers: - trigger: state entity_id: - sensor.updates_in_progress condition: - condition: template value_template: '{{ states.sensor.updates_in_progress.state is defined }}' action: - choose: - conditions: - condition: numeric_state entity_id: sensor.updates_in_progress below: 1 sequence: - action: input_boolean.turn_off data: {} target: entity_id: input_boolean.maintenance_mode - conditions: - condition: numeric_state entity_id: sensor.updates_in_progress above: 2 sequence: - action: input_boolean.turn_on data: {} target: entity_id: input_boolean.maintenance_mode mode: single - id: maintenance_notifications alias: 𐃏 Maintenance Notifications description: '' mode: single triggers: - trigger: state entity_id: - input_boolean.maintenance_mode condition: [] actions: - choose: - conditions: - condition: state entity_id: input_boolean.maintenance_mode state: 'on' sequence: - if: - condition: template value_template: '{{ states.sensor.updates_in_progress.state is defined }}' then: - wait_template: '{{ as_timestamp(states.sensor.updates_in_progress.last_updated) | int + 10 < as_timestamp(now()) | int }}' continue_on_timeout: true timeout: 00:01:00 - action: "{% if states.input_text.notify_service_server.state is defined %}\n\ \ {% set notify_service = states('input_text.notify_service_server') %}\n\ {% elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: "⚙️ Mentenanță în curs\n{% if states.sensor.updates_in_progress.state\ \ is defined and states.sensor.updates_in_progress.state | int > 0 %}\n\ \U0001F527 Următoarele actualizări vor fi instalate:\n– {{ state_attr('sensor.updates_in_progress','names').split(',')\ \ | join('\n–') }}\n{% endif %}\nVă informăm că mentenanța ar putea afecta\ \ funcționarea automatizărilor, aplicației și dispozitivelor. Ne cerem\ \ scuze pentru orice neplăceri pe care acestea le-ar putea cauza.\n\n\ ✉️ Vă vom anunța imediat ce mentenanța va fi finalizată și când toate\ \ serviciile noastre vor fi din nou disponibile. \n" - conditions: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' sequence: - action: "{% if states.input_text.notify_service_server.state is defined %}\n\ \ {% set notify_service = states('input_text.notify_service_server') %}\n\ {% elif states.input_text.notify_service.state is defined %}\n {% set notify_service\ \ = states('input_text.notify_service') %}\n{% else %}\n {% set notify_service\ \ = 'notify.notify' %}\n{% endif %} {{ notify_service }}" data: message: '🎉 Mentenanță finalizată Mentenanța a fost finalizată cu succes. Toate serviciile și dispozitivele sunt acum disponibile. Anunță-ne dacă întâmpini probleme sau observi anomalii de funcționare. 🙏 Mulțumim pentru răbdare și pentru alegerea serviciilor noastre. ' - id: unavailable_entities alias: 𐃏 Unavailable Entities mode: restart triggers: - trigger: state entity_id: sensor.unavailable_entities - trigger: homeassistant event: start - trigger: state entity_id: - input_boolean.maintenance_mode to: 'off' condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' - condition: template value_template: '{{ states.sensor.unavailable_entities.state is defined }}' actions: - choose: - conditions: - condition: numeric_state entity_id: sensor.unavailable_entities above: '0' below: '2' - condition: template value_template: '{{ states(''input_number.unavailable_entities_last_triggered'') | int != states(''sensor.unavailable_entities'') | int }}' sequence: - delay: minutes: "{% if states.input_number.delay_notify_unavailable.state is defined\ \ %}\n {% set minutes = states('input_number.delay_notify_unavailable')\ \ | int %}\n{% else %}\n {% set minutes = 10 %}\n{% endif %} {{ minutes\ \ }}" - action: input_number.set_value target: entity_id: input_number.unavailable_entities_last_triggered data: value: '{{ states(''sensor.unavailable_entities'') | int }}' - action: "{% if states.input_text.notify_service_unavailable.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_unavailable')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: '🔴 Este un dispozitiv indisponibil: – {{ state_attr(''sensor.unavailable_entities'',''names'').split('','') | join('' –'') }} ' - conditions: - condition: numeric_state entity_id: sensor.unavailable_entities above: '1' - condition: template value_template: '{{ states(''input_number.unavailable_entities_last_triggered'') | int != states(''sensor.unavailable_entities'') | int }}' sequence: - delay: minutes: "{% if states.input_number.delay_notify_unavailable.state is defined\ \ %}\n {% set minutes = states('input_number.delay_notify_unavailable')\ \ | int %}\n{% else %}\n {% set minutes = 10 %}\n{% endif %} {{ minutes\ \ }}" - action: input_number.set_value target: entity_id: input_number.unavailable_entities_last_triggered data: value: '{{ states(''sensor.unavailable_entities'') | int }}' - action: "{% if states.input_text.notify_service_unavailable.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_unavailable')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: '🔴 Sunt {{ states(''sensor.unavailable_entities'')|int }} dispozitive indisponibile: – {{ state_attr(''sensor.unavailable_entities'',''names'').split('','') | join('' –'') }} ' - conditions: - condition: numeric_state entity_id: sensor.unavailable_entities below: '1' - condition: template value_template: '{{ states(''input_number.unavailable_entities_last_triggered'') | int > 0 }}' sequence: - action: "{% if states.input_text.notify_service_unavailable.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_unavailable')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: 🟢 Toate dispozitivele funcționzează! - action: input_number.set_value target: entity_id: input_number.unavailable_entities_last_triggered data: value: '{{ states(''sensor.unavailable_entities'') | int }}' default: [] - id: unavailable_sensors alias: 𐃏 Unavailable Sensors mode: restart triggers: - trigger: state entity_id: sensor.unavailable_sensors - trigger: homeassistant event: start condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' - condition: template value_template: '{{ states.sensor.unavailable_sensors.state is defined }}' actions: - choose: - conditions: - condition: numeric_state entity_id: sensor.unavailable_sensors above: '0' below: '2' - condition: template value_template: '{{ states(''input_number.unavailable_sensors_last_triggered'') | int != states(''sensor.unavailable_sensors'') | int }}' sequence: - delay: minutes: "{% if states.input_number.delay_notify_unavailable.state is defined\ \ %}\n {% set minutes = states('input_number.delay_notify_unavailable')\ \ | int %}\n{% else %}\n {% set minutes = 10 %}\n{% endif %} {{ minutes\ \ }}" - action: input_number.set_value target: entity_id: input_number.unavailable_sensors_last_triggered data: value: '{{ states(''sensor.unavailable_sensors'') | int }}' - action: "{% if states.input_text.notify_service_unavailable.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_unavailable')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: '🔴 Este un senzor indisponibil: – {{ state_attr(''sensor.unavailable_sensors'',''names'').split('','') | join('' –'') }} ' - conditions: - condition: numeric_state entity_id: sensor.unavailable_sensors above: '1' - condition: template value_template: '{{ states(''input_number.unavailable_sensors_last_triggered'') | int != states(''sensor.unavailable_sensors'') | int }}' sequence: - delay: minutes: "{% if states.input_number.delay_notify_unavailable.state is defined\ \ %}\n {% set minutes = states('input_number.delay_notify_unavailable')\ \ | int %}\n{% else %}\n {% set minutes = 10 %}\n{% endif %} {{ minutes\ \ }}" - action: input_number.set_value target: entity_id: input_number.unavailable_sensors_last_triggered data: value: '{{ states(''sensor.unavailable_sensors'') | int }}' - action: "{% if states.input_text.notify_service_unavailable.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_unavailable')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: '🔴 Sunt {{ states(''sensor.unavailable_sensors'')|int }} senzori indisponibili: – {{ state_attr(''sensor.unavailable_sensors'',''names'').split('','') | join('' –'') }} ' - conditions: - condition: numeric_state entity_id: sensor.unavailable_sensors below: '1' - condition: template value_template: '{{ states(''input_number.unavailable_sensors_last_triggered'') | int > 0 }}' sequence: - action: "{% if states.input_text.notify_service_unavailable.state is defined\ \ %}\n {% set notify_service = states('input_text.notify_service_unavailable')\ \ %}\n{% elif states.input_text.notify_service.state is defined %}\n {%\ \ set notify_service = states('input_text.notify_service') %}\n{% else %}\n\ \ {% set notify_service = 'notify.notify' %}\n{% endif %} {{ notify_service\ \ }}" data: message: 🟢 Toți senzorii funcționzează! - action: input_number.set_value target: entity_id: input_number.unavailable_sensors_last_triggered data: value: '{{ states(''sensor.unavailable_sensors'') | int }}' default: [] - id: updates_available alias: 𐃏 Updates Available description: '' triggers: - trigger: state entity_id: sensor.updates_available - trigger: state entity_id: - input_boolean.maintenance_mode to: 'off' condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' - condition: template value_template: '{{ states.sensor.updates_available.state is defined }}' actions: - choose: - conditions: - condition: numeric_state entity_id: sensor.updates_available above: '0' below: '2' sequence: - action: "{% if states.input_text.notify_service_updates.state is defined %}\n\ \ {% set notify_service = states('input_text.notify_service_updates')\ \ %}\n {% elif states.input_text.notify_service.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service') %}\n {%\ \ else %}\n {% set notify_service = 'notify.notify' %}\n{% endif %} {{\ \ notify_service }}" data: message: '⚙️ Este o actualizare disponibilă: – {{ state_attr(''sensor.updates_available'',''names'').split('','') | join('' –'') }} ' data: disable_notification: true - action: input_boolean.turn_on target: entity_id: input_boolean.update_available_alert data: {} enabled: true - conditions: - condition: numeric_state entity_id: sensor.updates_available above: '1' sequence: - action: "{% if states.input_text.notify_service_updates.state is defined %}\n\ \ {% set notify_service = states('input_text.notify_service_updates')\ \ %}\n {% elif states.input_text.notify_service.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service') %}\n {%\ \ else %}\n {% set notify_service = 'notify.notify' %}\n{% endif %} {{\ \ notify_service }}" data: message: '⚙️ Sunt {{ states(''sensor.updates_available'')|int }} actualizări disponibile: – {{ state_attr(''sensor.updates_available'',''names'').split('','') | join('' –'') }} ' data: disable_notification: true - action: input_boolean.turn_on target: entity_id: input_boolean.update_available_alert data: {} enabled: true - conditions: - condition: numeric_state entity_id: sensor.updates_available below: '1' - condition: state entity_id: input_boolean.update_available_alert state: 'on' enabled: true sequence: - action: "{% if states.input_text.notify_service_updates.state is defined %}\n\ \ {% set notify_service = states('input_text.notify_service_updates')\ \ %}\n {% elif states.input_text.notify_service.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service') %}\n {%\ \ else %}\n {% set notify_service = 'notify.notify' %}\n{% endif %} {{\ \ notify_service }}" data: message: 🎉 Dispozitivele și serviciile sunt actualizate! data: disable_notification: true - action: input_boolean.turn_off target: entity_id: input_boolean.update_available_alert data: {} enabled: true default: [] mode: restart - id: updates_in_progress alias: 𐃏 Updates in Progress mode: restart triggers: - trigger: state entity_id: sensor.updates_in_progress - trigger: homeassistant event: start condition: - condition: state entity_id: input_boolean.maintenance_mode state: 'off' - condition: template value_template: '{{ states.sensor.updates_in_progress.state is defined }}' actions: - delay: seconds: 10 - choose: - conditions: - condition: numeric_state entity_id: sensor.updates_in_progress above: '0' below: '2' sequence: - action: "{% if states.input_text.notify_service_updates.state is defined %}\n\ \ {% set notify_service = states('input_text.notify_service_updates')\ \ %}\n {% elif states.input_text.notify_service.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service') %}\n {%\ \ else %}\n {% set notify_service = 'notify.notify' %}\n{% endif %} {{\ \ notify_service }}" data: message: '🔧 Este o actualizare în progress: – {{ state_attr(''sensor.updates_in_progress'',''names'').split('','') | join('' –'') }} ' data: disable_notification: true - action: input_boolean.turn_on target: entity_id: input_boolean.update_in_progress_alert - conditions: - condition: numeric_state entity_id: sensor.updates_in_progress above: '1' sequence: - action: "{% if states.input_text.notify_service_updates.state is defined %}\n\ \ {% set notify_service = states('input_text.notify_service_updates')\ \ %}\n {% elif states.input_text.notify_service.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service') %}\n {%\ \ else %}\n {% set notify_service = 'notify.notify' %}\n{% endif %} {{\ \ notify_service }}" data: message: '🔧 Sunt {{ states(''sensor.updates_in_progress'')|int }} actualizări în progress: – {{ state_attr(''sensor.updates_in_progress'',''names'').split('','') | join('' –'') }} ' data: disable_notification: true - action: input_boolean.turn_on target: entity_id: input_boolean.update_in_progress_alert - conditions: - condition: numeric_state entity_id: sensor.updates_in_progress below: '1' - condition: state entity_id: input_boolean.update_in_progress_alert state: 'on' sequence: - action: "{% if states.input_text.notify_service_updates.state is defined %}\n\ \ {% set notify_service = states('input_text.notify_service_updates')\ \ %}\n {% elif states.input_text.notify_service.state is defined %}\n \ \ {% set notify_service = states('input_text.notify_service') %}\n {%\ \ else %}\n {% set notify_service = 'notify.notify' %}\n{% endif %} {{\ \ notify_service }}" data: message: 🎉 Actualizare finalizată! data: disable_notification: true - action: input_boolean.turn_off target: entity_id: input_boolean.update_in_progress_alert default: [] - id: auto_update alias: 𐃏 Auto Update description: '' triggers: - trigger: template value_template: "{% set current_day = now().weekday() %}\n{% if states.input_datetime.auto_update_time.state\ \ is defined %}\n {% set time = states('input_datetime.auto_update_time')\ \ %}\n {% set allow_update = true %}\n{% elif current_day in [0, 1, 2, 3]\ \ %}\n {% set time = \"03:30:00\" %}\n {% set allow_update = true %}\n\ {% else %}\n {% set allow_update = false %}\n{% endif %}\n{{ allow_update\ \ and time == now().timestamp() | timestamp_custom('%H:%M:%S') }}" condition: [] action: - if: - condition: template value_template: "{% set ignored = label_entities('ignore') %}\n{% set result\ \ = namespace(updates=[]) %}\n{% set hours_map = {0: 24, 1: 120} %}\n\n{%\ \ for state in states.update \n |selectattr('state', '==', 'on')\n |selectattr('attributes.supported_features',\ \ '==', 25)\n |rejectattr('attributes.device_class', '==', 'firmware')\n\ \ |rejectattr('entity_id','in', ignored ) \n |rejectattr('entity_id', 'in',\ \ \n [\n 'update.home_assistant_operating_system_update',\n 'update.home_assistant_core_update',\n\ \ 'update.esphome_device_builder_update',\n 'update.esphome_update'\n\ \ ])\n%}\n {% set current = state_attr(state.entity_id, 'installed_version')\ \ %}\n {% set latest = state_attr(state.entity_id, 'latest_version') %}\n\ \ {% if current and latest %}\n {% set cp = current.split('.') %}\n \ \ {% set lp = latest.split('.') %}\n {# If only the patch differs then\ \ it's a minor update (update_status = 0), otherwise it's major (update_status\ \ = 1) #}\n {% set update_status = 0 if cp[0] == lp[0] and cp[1] == lp[1]\ \ and cp[2] != lp[2] else 1 %}\n {# For minor update use delay_update_minor,\ \ for major update use delay_update #}\n {% set hours = (states('input_number.delay_update_minor')|int)\n\ \ if update_status == 0 and states('input_number.delay_update_minor')\ \ not in ['unknown', None]\n else ((states('input_number.delay_update')|int)\n\ \ if update_status == 1 and states('input_number.delay_update') not\ \ in ['unknown', None]\n else hours_map[update_status])\n %}\n \ \ {% if as_timestamp(state.last_changed) + 3600 * hours < as_timestamp(now())\ \ %}\n {% set result.updates = result.updates + [state.entity_id] %}\n\ \ {% endif %}\n {% endif %}\n{% endfor %}\n{{ result.updates|count > 0\ \ }}" then: - action: update.install target: entity_id: "{% set ignored = label_entities('ignore') %}\n{% set result =\ \ namespace(updates=[]) %}\n{% set hours_map = {0: 24, 1: 120} %}\n\n{%\ \ for state in states.update \n |selectattr('state', '==', 'on')\n |selectattr('attributes.supported_features',\ \ '==', 25)\n |rejectattr('attributes.device_class', '==', 'firmware')\n\ \ |rejectattr('entity_id','in', ignored ) \n |rejectattr('entity_id',\ \ 'in', \n [\n 'update.home_assistant_operating_system_update',\n\ \ 'update.home_assistant_core_update',\n 'update.esphome_device_builder_update',\n\ \ 'update.esphome_update'\n ])\n%}\n {% set current = state_attr(state.entity_id,\ \ 'installed_version') %}\n {% set latest = state_attr(state.entity_id,\ \ 'latest_version') %}\n {% if current and latest %}\n {% set cp = current.split('.')\ \ %}\n {% set lp = latest.split('.') %}\n {# If only the patch differs\ \ then it's a minor update (update_status = 0), otherwise it's major (update_status\ \ = 1) #}\n {% set update_status = 0 if cp[0] == lp[0] and cp[1] == lp[1]\ \ and cp[2] != lp[2] else 1 %}\n {# For minor update use delay_update_minor,\ \ for major update use delay_update #}\n {% set hours = (states('input_number.delay_update_minor')|int)\n\ \ if update_status == 0 and states('input_number.delay_update_minor')\ \ not in ['unknown', None]\n else ((states('input_number.delay_update')|int)\n\ \ if update_status == 1 and states('input_number.delay_update') not\ \ in ['unknown', None]\n else hours_map[update_status])\n %}\n\ \ {% if as_timestamp(state.last_changed) + 3600 * hours < as_timestamp(now())\ \ %}\n {% set result.updates = result.updates + [state.entity_id] %}\n\ \ {% endif %}\n {% endif %}\n{% endfor %}\n{{ result.updates|list }}" - if: - condition: template value_template: "{% set ignored = label_entities('ignore') %}\n{% set result\ \ = namespace(updates=[]) %}\n{% set hours_map = {0: 24, 1: 120} %}\n\n{%\ \ for state in states.update \n |selectattr('state', '==', 'on')\n |selectattr('attributes.supported_features',\ \ '==', 23)\n |rejectattr('attributes.device_class', '==', 'firmware')\n\ \ |rejectattr('entity_id','in', ignored ) \n |rejectattr('entity_id', 'in',\ \ \n [\n 'update.home_assistant_operating_system_update',\n 'update.home_assistant_core_update',\n\ \ 'update.esphome_device_builder_update',\n 'update.esphome_update'\n\ \ ])\n%}\n {% set current = state_attr(state.entity_id, 'installed_version')\ \ %}\n {% set latest = state_attr(state.entity_id, 'latest_version') %}\n\ \ {% if current and latest %}\n {% set cp = current.split('.') %}\n \ \ {% set lp = latest.split('.') %}\n {# If only the patch differs then\ \ it's a minor update (update_status = 0), otherwise it's major (update_status\ \ = 1) #}\n {% set update_status = 0 if cp[0] == lp[0] and cp[1] == lp[1]\ \ and cp[2] != lp[2] else 1 %}\n {# For minor update use delay_update_minor,\ \ for major update use delay_update #}\n {% set hours = (states('input_number.delay_update_minor')|int)\n\ \ if update_status == 0 and states('input_number.delay_update_minor')\ \ not in ['unknown', None]\n else ((states('input_number.delay_update')|int)\n\ \ if update_status == 1 and states('input_number.delay_update') not\ \ in ['unknown', None]\n else hours_map[update_status])\n %}\n \ \ {% if as_timestamp(state.last_changed) + 3600 * hours < as_timestamp(now())\ \ %}\n {% set result.updates = result.updates + [state.entity_id] %}\n\ \ {% endif %}\n {% endif %}\n{% endfor %}\n{{ result.updates|count > 0\ \ }}" then: - action: update.install continue_on_error: true target: entity_id: "{% set ignored = label_entities('ignore') %}\n{% set result =\ \ namespace(updates=[]) %}\n{% set hours_map = {0: 24, 1: 120} %}\n\n{%\ \ for state in states.update \n |selectattr('state', '==', 'on')\n |selectattr('attributes.supported_features',\ \ '==', 23)\n |rejectattr('attributes.device_class', '==', 'firmware')\n\ \ |rejectattr('entity_id','in', ignored ) \n |rejectattr('entity_id',\ \ 'in', \n [\n 'update.home_assistant_operating_system_update',\n\ \ 'update.home_assistant_core_update',\n 'update.esphome_device_builder_update',\n\ \ 'update.esphome_update'\n ])\n%}\n {% set current = state_attr(state.entity_id,\ \ 'installed_version') %}\n {% set latest = state_attr(state.entity_id,\ \ 'latest_version') %}\n {% if current and latest %}\n {% set cp = current.split('.')\ \ %}\n {% set lp = latest.split('.') %}\n {# If only the patch differs\ \ then it's a minor update (update_status = 0), otherwise it's major (update_status\ \ = 1) #}\n {% set update_status = 0 if cp[0] == lp[0] and cp[1] == lp[1]\ \ and cp[2] != lp[2] else 1 %}\n {# For minor update use delay_update_minor,\ \ for major update use delay_update #}\n {% set hours = (states('input_number.delay_update_minor')|int)\n\ \ if update_status == 0 and states('input_number.delay_update_minor')\ \ not in ['unknown', None]\n else ((states('input_number.delay_update')|int)\n\ \ if update_status == 1 and states('input_number.delay_update') not\ \ in ['unknown', None]\n else hours_map[update_status])\n %}\n\ \ {% if as_timestamp(state.last_changed) + 3600 * hours < as_timestamp(now())\ \ %}\n {% set result.updates = result.updates + [state.entity_id] %}\n\ \ {% endif %}\n {% endif %}\n{% endfor %}\n{{ result.updates|list }}" - if: - condition: template value_template: "{% set ignored = label_entities('ignore') %}\n\n{% set result\ \ = namespace(updates=[]) %}\n {% if states.input_number.delay_update.state\ \ is defined %}\n {% set hours = states('input_number.delay_update') |\ \ int %}\n {% else %}\n {% set hours = 96 %}\n {% endif %}\n \n{% for\ \ state in states.update \n |selectattr('state', '==', 'on')\n |selectattr('attributes.device_class',\ \ '==', 'firmware')\n |rejectattr('entity_id','in', ignored )\n%}\n {% if\ \ as_timestamp(state.last_changed) | int + 60*60*hours < as_timestamp(now())\ \ | int %}\n {% set result.updates = result.updates + [state.entity_id]\ \ %}\n {% endif %}\n{% endfor %}\n\n{{ result.updates|count > 0 }}" then: - action: update.install continue_on_error: true target: entity_id: "{% set ignored = label_entities('ignore') %}\n\n{% set result\ \ = namespace(updates=[]) %}\n {% if states.input_number.delay_update.state\ \ is defined %}\n {% set hours = states('input_number.delay_update')\ \ | int %}\n {% else %}\n {% set hours = 96 %}\n {% endif %}\n \n\ {% for state in states.update \n |selectattr('state', '==', 'on')\n |selectattr('attributes.device_class',\ \ '==', 'firmware')\n |rejectattr('entity_id','in', ignored )\n%}\n {%\ \ if as_timestamp(state.last_changed) | int + 60*60*hours < as_timestamp(now())\ \ | int %}\n {% set result.updates = result.updates + [state.entity_id]\ \ %}\n {% endif %}\n{% endfor %}\n{{ result.updates | list }}" - if: - condition: template value_template: "{% set ignored = label_entities('ignore') %}\n{% set result\ \ = namespace(updates=[]) %}\n{% set hours_map = {0: 24, 1: 120} %}\n\n{%\ \ for state in states.update \n |selectattr('state', 'eq', 'on')\n |selectattr('entity_id',\ \ 'in', ['update.esphome_device_builder_update', 'update.esphome_update' ])\n\ \ |rejectattr('entity_id','in', ignored ) \n%}\n {% set current = state_attr(state.entity_id,\ \ 'installed_version') %}\n {% set latest = state_attr(state.entity_id, 'latest_version')\ \ %}\n {% if current and latest %}\n {% set cp = current.split('.') %}\n\ \ {% set lp = latest.split('.') %}\n {# If only the patch differs then\ \ it's a minor update (update_status = 0), otherwise it's major (update_status\ \ = 1) #}\n {% set update_status = 0 if cp[0] == lp[0] and cp[1] == lp[1]\ \ and cp[2] != lp[2] else 1 %}\n {# For minor update use delay_update_minor,\ \ for major update use delay_update #}\n {% set hours = (states('input_number.delay_update_minor')|int)\n\ \ if update_status == 0 and states('input_number.delay_update_minor')\ \ not in ['unknown', None]\n else ((states('input_number.delay_update')|int)\n\ \ if update_status == 1 and states('input_number.delay_update') not\ \ in ['unknown', None]\n else hours_map[update_status])\n %}\n \ \ {% if as_timestamp(state.last_changed) + 3600 * hours < as_timestamp(now())\ \ %}\n {% set result.updates = result.updates + [state.entity_id] %}\n\ \ {% endif %}\n {% endif %}\n{% endfor %}\n{{ result.updates | count >\ \ 0 }}" then: - action: update.install continue_on_error: true target: entity_id: "{% set ignored = label_entities('ignore') %}\n{% set result =\ \ namespace(updates=[]) %}\n{% set hours_map = {0: 24, 1: 120} %}\n\n{%\ \ for state in states.update \n |selectattr('state', 'eq', 'on')\n |selectattr('entity_id',\ \ 'in', ['update.esphome_device_builder_update', 'update.esphome_update'\ \ ])\n |rejectattr('entity_id','in', ignored ) \n%}\n {% set current\ \ = state_attr(state.entity_id, 'installed_version') %}\n {% set latest\ \ = state_attr(state.entity_id, 'latest_version') %}\n {% if current and\ \ latest %}\n {% set cp = current.split('.') %}\n {% set lp = latest.split('.')\ \ %}\n {# If only the patch differs then it's a minor update (update_status\ \ = 0), otherwise it's major (update_status = 1) #}\n {% set update_status\ \ = 0 if cp[0] == lp[0] and cp[1] == lp[1] and cp[2] != lp[2] else 1 %}\n\ \ {# For minor update use delay_update_minor, for major update use delay_update\ \ #}\n {% set hours = (states('input_number.delay_update_minor')|int)\n\ \ if update_status == 0 and states('input_number.delay_update_minor')\ \ not in ['unknown', None]\n else ((states('input_number.delay_update')|int)\n\ \ if update_status == 1 and states('input_number.delay_update') not\ \ in ['unknown', None]\n else hours_map[update_status])\n %}\n\ \ {% if as_timestamp(state.last_changed) + 3600 * hours < as_timestamp(now())\ \ %}\n {% set result.updates = result.updates + [state.entity_id] %}\n\ \ {% endif %}\n {% endif %}\n{% endfor %}\n{{ result.updates | list\ \ }}" - wait_template: "{% set ignored = label_entities('ignore') %}\n\n{% set result\ \ = namespace(updates=[]) %}\n{% for state in states.update \n |selectattr('state',\ \ '==', 'on')\n |selectattr('attributes.title', '==', 'ESPHome')\n |rejectattr('entity_id',\ \ 'in', ['update.esphome_device_builder_update', 'update.esphome_update' ])\n\ \ |rejectattr('entity_id','in', ignored ) \n%}\n {% set result.updates\ \ = result.updates + [state.entity_id] %}\n{% endfor %}\n{{ result.updates\ \ | count > 0 }}" continue_on_timeout: true timeout: 00:30:00 - if: - condition: template value_template: "{% set ignored = label_entities('ignore') %}\n\n{% set result\ \ = namespace(updates=[]) %}\n{% for state in states.update \n |selectattr('state',\ \ '==', 'on')\n |selectattr('attributes.title', '==', 'ESPHome')\n |rejectattr('entity_id',\ \ 'in', ['update.esphome_device_builder_update', 'update.esphome_update'])\n\ \ |rejectattr('entity_id','in', ignored ) \n%}\n {% set result.updates\ \ = result.updates + [state.entity_id] %}\n{% endfor %}\n\n{{ result.updates|count\ \ > 0 }}" then: - action: update.install continue_on_error: true target: entity_id: "{% set ignored = label_entities('ignore') %}\n\n{% set result\ \ = namespace(updates=[]) %}\n{% for state in states.update \n |selectattr('state',\ \ '==', 'on')\n |selectattr('attributes.title', '==', 'ESPHome')\n |rejectattr('entity_id',\ \ 'in', ['update.esphome_device_builder_update', 'update.esphome_update'])\n\ \ |rejectattr('entity_id','in', ignored ) \n%}\n {% set result.updates\ \ = result.updates + [state.entity_id] %}\n{% endfor %}\n\n{{ result.updates|list\ \ }}" - wait_template: '{{ states(''sensor.updates_in_progress'') | int == 0 }}' - if: - condition: template value_template: "{% set ignored = label_entities('ignore') %}\n{% set result\ \ = namespace(updates=[]) %}\n{% set hours_map = {0: 24, 1: 120} %}\n\n{%\ \ for state in states.update \n |selectattr('state', 'eq', 'on')\n |selectattr('entity_id',\ \ 'in', ['update.home_assistant_core_update' ])\n |rejectattr('entity_id','in',\ \ ignored ) \n%}\n {% set current = state_attr(state.entity_id, 'installed_version')\ \ %}\n {% set latest = state_attr(state.entity_id, 'latest_version') %}\n\ \ {% if current and latest %}\n {% set cp = current.split('.') %}\n \ \ {% set lp = latest.split('.') %}\n {# If only the patch differs then\ \ it's a minor update (update_status = 0), otherwise it's major (update_status\ \ = 1) #}\n {% set update_status = 0 if cp[0] == lp[0] and cp[1] == lp[1]\ \ and cp[2] != lp[2] else 1 %}\n {# For minor update use delay_update_minor,\ \ for major update use delay_update #}\n {% set hours = (states('input_number.delay_update_minor')|int)\n\ \ if update_status == 0 and states('input_number.delay_update_minor')\ \ not in ['unknown', None]\n else ((states('input_number.delay_update')|int)\n\ \ if update_status == 1 and states('input_number.delay_update') not\ \ in ['unknown', None]\n else hours_map[update_status])\n %}\n \ \ {% if as_timestamp(state.last_changed) + 3600 * hours < as_timestamp(now())\ \ %}\n {% set result.updates = result.updates + [state.entity_id] %}\n\ \ {% endif %}\n {% endif %}\n{% endfor %}\n{{ result.updates | count >\ \ 0 }}" then: - action: update.install continue_on_error: true target: entity_id: update.home_assistant_core_update - wait_template: '{{ states(''sensor.updates_in_progress'') | int == 0 }}' - if: - condition: template value_template: "{% set ignored = label_entities('ignore') %}\n\n{% set result\ \ = namespace(updates=[]) %}\n{% if states.input_number.delay_update.state\ \ is defined %}\n {% set hours = states('input_number.delay_update') | int\ \ %}\n{% else %}\n {% set hours = 120 %}\n{% endif %}\n\n{% for state in\ \ states.update \n |selectattr('state', 'eq', 'on')\n |selectattr('entity_id',\ \ 'in', ['update.home_assistant_operating_system_update' ])\n |rejectattr('entity_id','in',\ \ ignored ) \n%}\n {% if as_timestamp(state.last_changed) | int + 60*60*hours\ \ < as_timestamp(now()) | int %}\n {% set result.updates = result.updates\ \ + [state.entity_id] %}\n {% endif %}\n{% endfor %}\n\n{{ result.updates\ \ | count > 0 }}" then: - action: update.install continue_on_error: true target: entity_id: update.home_assistant_operating_system_update