Logger
The logger integration decides how much Home Assistant writes to its log. When an integration misbehaves, its integration page has an Enable debug logging button: from then on, it writes down everything it does, until you select Disable debug logging.
That button only helps when you are there to press it. The problem that shows up at three in the morning, once a week, is over by the time you get up. Spook adds an action that does what the button does, so an automation can press it: when the integration fails, for example, with the Integration failed to set up trigger.
Actions
Spook adds one action to the logger integration. You find it wherever you add an action, marked with a 👻.
Set integration log level
Sets how much an integration logs. Debug, unless you pick another level. The same as Enable debug logging on the integration page, so that page shows debug logging is on, and its Disable debug logging button works as always.
The level is set on everything the integration logs through: the integration itself, and the libraries it names as its own. That is what the button does too.
Set the level to Default to stop. The integration then follows the level above it: the default in your logger configuration, or the one of Home Assistant. A level your logger configuration sets for exactly that integration comes back with the next restart.
How long the level stays is up to you:
- Until Home Assistant restarts: gone with the next restart.
- Also through the next restart: kept for one restart, then gone with the one after. This is what the button does: whatever goes wrong while Home Assistant starts is in the log too.
- Until you change it: kept for every restart to come.
This action is for administrators only, like the button. Your automations can always run it. So can your scripts, unless a user who is not an administrator starts one.
How to use it
- Open the automation or script that should turn on debug logging, and select Add action.
- Search for log level, and select Logger: Set integration log level 👻.
- Under Integration, type the domain of the integration, like
hue. - Optionally, pick another Log level, or change how long to Keep it.
- Select Save.
Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.
| Action properties | |
|---|---|
| Action | Logger: Set integration log level 👻 |
| Action name | logger.set_integration_level |
| Action targets | No targets |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | Try this action |
| Action data parameters | |||
|---|---|---|---|
| Attribute | Type | Required | Default / Example |
integration | string | Yes | hue |
level | string | No | debug |
persistence | string | No | once |
The levels, most chatty first: debug, info, warning, error, critical, and notset for Default. How long it stays: none (until Home Assistant restarts), once (also through the next restart) and permanent (until you change it).
An integration Home Assistant cannot find is refused, so a typo gives you an error instead of a level nobody sees. Use the domain, the part after /integration/ in the address of its integration page. Custom integrations work too.
Turn on debug logging for an integration once it has been failing for 15 minutes, and send yourself a note:
triggers:
- trigger: spook.integration_failed
options:
for: "00:15:00"
actions:
- action: logger.set_integration_level
data:
integration: "{{ trigger.domain }}"
- action: notify.persistent_notification
data:
title: Debug logging on
message: >-
{{ trigger.title }} keeps failing, so it now writes everything to the
log.
Stop debug logging for Hue again:
action: logger.set_integration_level
data:
integration: hue
level: notset
Debug logging for the night only, gone with the next restart:
action: logger.set_integration_level
data:
integration: zwave_js
persistence: none
- Debug logging makes the log grow fast, and can slow Home Assistant down. Set it back to Default once you have what you need.
- Default also drops a level your
loggerconfiguration sets for exactly that integration, until the next restart. The Disable debug logging button does the same. - A level your
loggerconfiguration sets for that integration still counts at every start. Home Assistant then takes the chattier of the two, so a quieter level kept here gives way to a chattier one from the configuration after a restart. - A library the integration uses, but does not name as its own, keeps its level. Set that one with the
logger.set_levelaction of Home Assistant.
Missing something here?
An action, an entity or a repair this integration should have? Say so. Stuck, or found a bug? There is help.
File
Spook adds actions that list the files in a folder Home Assistant is allowed to use, and delete them from an automation, to clean up the exports, synced backups and logs that pile up outside your media.
System log
Spook adds an action that lists the errors and warnings of Home Assistant, the ones on the logs page, so an automation can count them, filter them by integration, or send them to your phone.
