I’m trying to get Home Assistant 2022.5.4 to email me event logs, including the contents of the log message. I can get it to send me an email when a log entry with this automation, but so far I can’t get the actual log message sent to me.
This sends me an email, but just tells me to check the log manually rather then emailing me the log message.
alias: Notifications System Log All
description: ''
trigger:
- platform: event
event_type: system_log_event
condition: []
action:
- service: notify.email
data:
title: HA log entry made
message: 'Check the log'
mode: single
When I use the format for the log message on the system log documentation page as below I get a message in my logs as follows.
ERROR (MainThread) [homeassistant.components.automation.2_system_log_message_test] Error while executing automation automation.2_system_log_message_test: template value should be a string for dictionary value @ data[‘message’]
alias: Notifications System Log All
description: ''
trigger:
- platform: event
event_type: system_log_event
condition: []
action:
- service: notify.email
data:
title: HA log entry made
message: '{{ trigger.event.data.message }}'
mode: single
I can see the event format as follows below, but I don’t know enough about HA yet to know how to get the message into the email. Can anyone help?
{
"event_type": "system_log_event",
"data": {
"name": "homeassistant.components.automation.a2_generate_error",
"message": [
"A2 Generate Error: Error executing script. Invalid data for call_service at pos 1: must contain at least one of temperature, target_temp_high, target_temp_low."
],
"level": "ERROR",
"source": [
"helpers/script.py",
1718
],
"timestamp": 1652691090.1839242,
"exception": "",
"count": 1,
"first_occurred": 1652691090.1839242
},
"origin": "LOCAL",
"time_fired": "2022-05-16T08:51:30.192725+00:00",
"context": {
"id": "0180cc10bb10bf1c491cfc649fbe6431",
"parent_id": null,
"user_id": null
}
}