I am trying to write my first 2 automations - first to turn a light on and then to turn it off, both at specified times. I will use a Shelly switch for that. However, just to get started all I want to do is to generate a log message in each automation. I think that I have setup the logger properly in the configuration.yaml using the file-editor add-on. I have created the first automation with specific time as a trigger. Where can I find doc on adding the log message to my automation? Some simple sample automations with logging would be great.
Here is my current automation yaml:
alias: GH seedling lights on
description: Turn on GH grow lights
triggers:
trigger: time
at: “07:00:00”
conditions:
actions:
action: logger.set_level
metadata: {}
data:
level: debug
mode: single
TIA!
I executed the automation and got 4 lines in the log viewer. Initialized trigger, running automation actions and 2 executing step call. But my message isn’t there.
All I want to do at the moment is to display a message in the log viewer. However, I get the following error message that I don’t understand.
Error: value must be one of [‘CRITICAL’, ‘DEBUG’, ‘ERROR’, ‘FATAL’, ‘INFO’, ‘NOTSET’, ‘WARN’, ‘WARNING’] for dictionary value @ data[‘title’]
Result:
params:
domain: logger
service: set_level
service_data:
level: DEBUG
title: Message Title
message: GH seedling lights on
target: {}
running_script: false
To me this states that my ‘title’ must have the same values as the level, which doesn’t make sense. I obviously misunderstand what is needed. Would someone please explain what this means and how to correct it?
If you’re having difficulties with writing to syslog (a.k.a. “Logs”), I suggest you consider writing to the Logbook (using the logbook.log action). For example, this worked for me.
action: logbook.log
data:
name: Test
message: This is a test
On the other hand, if you absolutely want to write to syslog, I will need to see the action you used (in properly formatted YAML).
NOTE
Be advised that the Logs view defaults to displaying INFO level messages and higher.
According to Log Levels, DEBUG is lower than INFO so messages tagged with DEBUG won’t be displayed in the Logs view (they exist in syslog but Logs view doesn’t display them).