How to detect notifier error in HA logs?

This morning Telegram stopped working for a while.
As a result, I didn’t receive any notifications.
Checking HA logs I have seen some entries that could help to detect this failure and notify me with another system (html5, sms, etc)

Here is an entry with an error sending a notification:

Error sending message: Timed out. Args:…

Here is an entry from the security system sending an image:

Error sending file: Flood control exceeded. Retry in 458 seconds. Args:…

How could I detect these errors in the logs with an automation or with node-red?

You could use a file sensor to inspect your config/home-assistant.log file:

Or you could monitor log events with an automation:

automation:
  - alias: Telegram Errors
    trigger:
      platform: event
      event_type: system_log_event
      event_data:
        level: ERROR
    condition:
      condition: template
      value_template: "{{ 'Error sending' in trigger.event.data.message[0] }}"
    action:
      service: notfy.by_another_method_than_telegram
      message: "{{ trigger.event.data.message }}"
1 Like

Thanks, I’ll try to use the event

I’ve been struggling the configuration of my HA setup and finally I have reproduced the errors (blocking access to telegram servers in my firewall), the errors are being written to home-assistant.log and appearing in developer tools / log screen, identified as ERROR.

Nevertheless, I can’t receive any event from the system_log_event, neither with automations nor node-red.

This user had similar issues trying to catch system-log events:

Is there any known issue?

Solved: system_log has an option called “fire_event” and has to be set to true

1 Like