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.
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
system_log:
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
trigger:
- platform: event
event_type: system_log_event
event_data:
level: ERROR
condition: []
It’s up to you what you want to do in the action section.
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.