Monitoring HA components/services/integrations

Hello all,
I run HA on my RPi using Docker. It is working beautifully. I am also running a db on MariaDB for HA recorder. I had an issue that was preventing the recorder service from writing to the database and HA was logging this in its logs.

The question I have is, is there a way for HA to send me notification if this happens again? i.e. it is unable to store data in the DB.

Thank you in advance

Sure, you can trigger on the error log write event and send a notification.

Many thanks @tom_l

You pointed me in the right direction. For anyone who comes across this thread, this is what I’ve done:

Enabled the system logging integration by adding the following lines to my configurations.yaml file

  max_entries: 10
  fire_event: true

The above enables the feature, sets the entries to store to 10 and, more crucially, enables events to be generated for automations to be triggered.

Once enabled (I restarted my HASS), I created an automation:

In the main part of the automation:

alias: Send notification on system error
description: Sends notification when an error occurs in the HASS event logs
  - platform: event
    event_type: system_log_event
      level: ERROR
condition: []

It’s up to you what you want to do in the action section.

I hope this helps someone

1 Like

Be very careful. If your automation generates errors you will get into a very fast loop that will crash your server. I know this because it happened to me.

So either put a rate limit in your actions (delay or last triggered condition) or filter the type of errors you get notified about with a condition.

1 Like

Thank you so much. That’s an excellent idea. I definitely missed that :slight_smile:

Any ideas how one would go about filtering the errors by the source?

In the meantime, I’ve implemented a 10sec delay just in case

Go to Developer Tools → Events and listen to the system_log_event event. You should then be able to see the data you can filter on.

1 Like