Add Backup reminder and notification on failure

This commit is contained in:
Burningstone91
2021-02-21 16:32:47 +01:00
parent dbf2f1c75c
commit daff0ff26c

View File

@@ -665,7 +665,7 @@ sensor:
# Healthcheck.io Status
# Backups
## Home Assistant VM Status
## Home Assistant VM Backup Status
- platform: rest
resource: !secret healthcheck_daily_backup_ha
name: Daily Backup Home Assistant VM
@@ -691,7 +691,59 @@ sensor:
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
## Network Pi Status
## Cloud VM Backup Status
- platform: rest
resource: !secret healthcheck_daily_backup_cloud
name: Daily Backup Cloud VM
headers:
X-Api-Key: !secret healthcheck_api_key
scan_interval: 1800
value_template: "{{ value_json.status }}"
## Cloud VM Last Backup
- platform: rest
resource: !secret healthcheck_daily_backup_cloud
name: Last Backup Cloud VM
headers:
X-Api-Key: !secret healthcheck_api_key
scan_interval: 1800
value_template: >
{%- set last_boot = value_json.last_ping %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
## NAS to NAS Backup Status
- platform: rest
resource: !secret healthcheck_weekly_backup_nas_to_nas
name: Weekly Backup NAS to NAS
headers:
X-Api-Key: !secret healthcheck_api_key
scan_interval: 1800
value_template: "{{ value_json.status }}"
## NAS to NAS Last Backup
- platform: rest
resource: !secret healthcheck_weekly_backup_nas_to_nas
name: Last Backup NAS to NAS
headers:
X-Api-Key: !secret healthcheck_api_key
scan_interval: 1800
value_template: >
{%- set last_boot = value_json.last_ping %}
{%- set uptime = now().timestamp() - as_timestamp(last_boot) %}
{%- set time = uptime | int %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
## Network Pi Backup Status
- platform: rest
resource: !secret healthcheck_monthly_backup_network_pi
name: Monthly Backup Network Pi
@@ -717,7 +769,7 @@ sensor:
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
## ZigBee Zwave Pi Status
## ZigBee Zwave Pi Backup Status
- platform: rest
resource: !secret healthcheck_monthly_backup_zigbeezwave_pi
name: Monthly Backup ZigBee Zwave Pi
@@ -826,22 +878,10 @@ automation:
- "{{ trigger.from_state.state not in ['unavailable', 'unknown', 'None'] }}"
- "{{ trigger.to_state.state not in ['unavailable', 'unknown', 'None'] }}"
action:
- variables:
name: "{{ state_attr(trigger.to_state.entity_id, 'friendly_name') }}"
- choose:
# IF desktop is running notify phone
- conditions: "{{ is_state('device_tracker.desktop_dimitri', 'home') }}"
sequence:
- service: notify.mobile_app_phone_dimitri
data:
title: "{{ name }}"
message: "📥 Update verfügbar"
# ELSE create a task in Evernote
default:
- service: notify.evernote
data:
title: "{{ name }} @1 Next #!Heute #@computer"
message: "Update planen"
- service: notify.mobile_app_phone_dimitri
data:
title: "{{ trigger.to_state.name }}"
message: "📥 Update verfügbar"
# Notify on low battery level
- id: notify_on_low_battery_level
@@ -890,7 +930,7 @@ automation:
data:
title: "Batterien wechseln"
message: >
🔋 Batterien für {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} fast leer
🔋 Batterien für {{ trigger.to_state.name }} sind fast leer.
Batteriestand: {{ trigger.to_state.state }}
data:
channel: System
@@ -942,7 +982,25 @@ automation:
💽 Der Speicher für {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} ist 95% voll!
data:
channel: System
# Reminder for Workstation Backups
- id: remind_workstation_backups
alias: "Workstation Backup Erinnerung"
mode: single
trigger:
- platform: time
at: "20:00:00"
condition:
- "{{ now().day == 1 and now().month in [3, 6, 9, 12] }}"
action:
- service: notify.mobile_app_phone_dimitri
data:
title: "Backup Workstations"
message: >
💽 Es ist Zeit ein Backup aller PCs durchzuführen.
data:
channel: System
# Notify on high CPU Temp
- id: notify_on_high_cpu_temp
alias: "Benachrichtigung wenn CPU Temperatur hoch ist"
@@ -992,13 +1050,35 @@ automation:
data:
title: "Unterspannung!"
message: >
⚡ Unterspannung für {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} entdeckt!
⚡ Unterspannung für {{ trigger.to_state.name }} entdeckt!
data:
channel: Notfall
priority: high
ttl: 0
color: red
# Notify on failed Backup
- id: notify_on_failed_backup
alias: "Benachrichtigung bei Backup Fehler"
mode: parallel
trigger:
- platform: state
entity_id:
- sensor.daily_backup_home_assistant_vm
- sensor.daily_backup_cloud_vm
- sensor.weekly_backup_nas_to_nas
- sensor.monthly_backup_network_pi
- sensor.monthly_backup_zigbee_zwave_pi
to: 'down'
action:
- service: notify.mobile_app_phone_dimitri
data:
title: "Backup fehlgeschlagen!"
message: >
❌ {{ trigger.to_state.name }} ist fehlgeschlagen!
data:
channel: System
# Notify on insecure NAS
- id: notify_on_insecure_nas
alias: "Benachrichtigung bei unsicherem NAS"
@@ -1014,7 +1094,7 @@ automation:
data:
title: "NAS unsicher!"
message: >
Das {{ 'Backup-' if 'backup' in trigger.to_state.entity_id else ''}}NAS ist unsicher!
👮 Das {{ 'Backup-' if 'backup' in trigger.to_state.entity_id else ''}}NAS ist unsicher!
data:
channel: Notfall
priority: high