From 64c2c5f8887a259a0446e3ea1ed153e4cbb9065a Mon Sep 17 00:00:00 2001 From: Bearded Tinker Date: Thu, 13 Jan 2022 20:14:27 +0100 Subject: [PATCH] Counting warnings and erros in HA system #80 --- automations/system/ha_log_event_trigger.yaml | 34 ++++++++++++++++++++ entities/counter/ha_error_counter.yaml | 9 ++++++ entities/counter/ha_warning_counter.yaml | 9 ++++++ integrations/system_log.yaml | 7 ++++ 4 files changed, 59 insertions(+) create mode 100644 automations/system/ha_log_event_trigger.yaml create mode 100644 entities/counter/ha_error_counter.yaml create mode 100644 entities/counter/ha_warning_counter.yaml create mode 100644 integrations/system_log.yaml diff --git a/automations/system/ha_log_event_trigger.yaml b/automations/system/ha_log_event_trigger.yaml new file mode 100644 index 00000000..9f68b8d6 --- /dev/null +++ b/automations/system/ha_log_event_trigger.yaml @@ -0,0 +1,34 @@ +##### +# Triggers when there is new warning or error +# https://community.home-assistant.io/t/counter-warning-error-issue/85490/11 +##### + +alias: Count Home Assistant errors +id: 'c057ca2c-ab20-4fe0-a32b-5980c0990fb2' + +trigger: + - platform: event + event_type: system_log_event + event_data: + level: ERROR + id: error + - platform: event + event_type: system_log_event + event_data: + level: WARNING + id: warning + +action: + - choose: + - conditions: + - condition: trigger + id: warning + sequence: + - service: counter.increment + entity_id: counter.homeassistant_warnings + - conditions: + - condition: trigger + id: error + sequence: + - service: counter.increment + entity_id: counter.homeassistant_errors diff --git a/entities/counter/ha_error_counter.yaml b/entities/counter/ha_error_counter.yaml new file mode 100644 index 00000000..f4d0fbf1 --- /dev/null +++ b/entities/counter/ha_error_counter.yaml @@ -0,0 +1,9 @@ +##### +# Counting number of errors in HA +# +##### + +homeassistant_errors: + name: Errors + icon: mdi:alert-octagram + restore: false diff --git a/entities/counter/ha_warning_counter.yaml b/entities/counter/ha_warning_counter.yaml new file mode 100644 index 00000000..ec14449b --- /dev/null +++ b/entities/counter/ha_warning_counter.yaml @@ -0,0 +1,9 @@ +##### +# Counting number of warnings in HA +# +##### + +homeassistant_warnings: + name: Warnings + icon: mdi:alert + restore: false diff --git a/integrations/system_log.yaml b/integrations/system_log.yaml new file mode 100644 index 00000000..c3cd2664 --- /dev/null +++ b/integrations/system_log.yaml @@ -0,0 +1,7 @@ +##### +# Using this integration to trigger events for log entries +# https://www.home-assistant.io/integrations/system_log/ +##### + +system_log: + fire_event: true \ No newline at end of file