From 55f36c8e57918d94068f29284a19442e52e68f62 Mon Sep 17 00:00:00 2001 From: Florian Brinker Date: Sun, 20 Jan 2019 18:16:56 +0100 Subject: [PATCH] Add Backup Notifications --- automations/backups.yaml | 35 +++++++++++++++++++++++++++++++++++ configuration.yaml | 17 +++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 automations/backups.yaml diff --git a/automations/backups.yaml b/automations/backups.yaml new file mode 100644 index 0000000..6b5614d --- /dev/null +++ b/automations/backups.yaml @@ -0,0 +1,35 @@ +- alias: Backup Error + trigger: + - platform: state + entity_id: binary_sensor.backup_error_occured + to: 'on' + action: + - service: notify.telegram_group + data: + title: '*Backup-Problem:*' + message: 'Es gab Fehler beim *Erstellen* des Backups! Bitte prüfen!' + - service: notify.telegram_group + data: + message: 'Anbei die Log-Datei :)' + data: + document: + file: /backuplogs/run.err.log + caption: Backup Creation Log + +- alias: Backup Sync Error + trigger: + - platform: state + entity_id: binary_sensor.backup_sync_error_occured + to: 'on' + action: + - service: notify.telegram_group + data: + title: '*Backup-Problem:*' + message: 'Es gab Fehler beim *Synchronisieren* des Backups! Bitte prüfen!' + - service: notify.telegram_group + data: + message: 'Anbei die Log-Datei :)' + data: + document: + file: /backuplogs/sync.err.log + caption: Backup Sync Log \ No newline at end of file diff --git a/configuration.yaml b/configuration.yaml index 4eb85b8..4456951 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -6,6 +6,8 @@ homeassistant: unit_system: metric time_zone: Europe/Berlin # customize: !include_dir_merge_named customizations/ + whitelist_external_dirs: + - /backuplogs http: ip_ban_enabled: true @@ -93,6 +95,7 @@ mqtt: telegram_bot: - platform: broadcast api_key: !secret telegram_bot + parse_mode: markdown allowed_chat_ids: - !secret telegram_chat_fb - !secret telegram_chat_group @@ -140,6 +143,20 @@ binary_sensor: name: YiHome1 Alarm payload_on: 1 payload_off: 0 + - platform: command_line + name: backup_error_occured + command: 'if [ `wc -l < /backuplogs/run.err.log` -eq 0 ]; then echo 0; else echo 1; fi' + payload_on: 1 + payload_off: 0 + scan_interval: 1800 + device_class: 'problem' + - platform: command_line + name: backup_sync_error_occured + command: 'if [ `wc -l < /backuplogs/sync.err.log` -eq 0 ]; then echo 0; else echo 1; fi' + payload_on: 1 + payload_off: 0 + scan_interval: 1800 + device_class: 'problem' weather: - platform: openweathermap