AutomationDataset/topaniot/description-ready.json

858 lines
82 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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