mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-08 18:06:54 +00:00
Add write service to system_log (#9214)
This commit is contained in:
parent
6226761fc3
commit
8c9e54a425
@ -43,6 +43,16 @@ fire_event:
|
||||
|
||||
To manually clear the system log, call this service.
|
||||
|
||||
### {% linkable_title Service `write` %}
|
||||
|
||||
Write a log entry
|
||||
|
||||
| Service data attribute | Optional | Description |
|
||||
| ---------------------- | -------- | ------------------------------------------------------------------------------- |
|
||||
| `message` | no | Message to log |
|
||||
| `level` | yes | Log level: debug, info, warning, error, critical. Defaults to 'error'. |
|
||||
| `logger` | yes | Logger name under which to log the message. Defaults to 'system_log.external'. |
|
||||
|
||||
## {% linkable_title Events %}
|
||||
|
||||
Errors and warnings are posted as the event `system_log_event`, so it is possible to write automations that trigger whenever a warning or error occurs. The following information is included in each event:
|
||||
@ -114,3 +124,24 @@ automation:
|
||||
message: '{{ trigger.event.data.message }}'
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
### {% linkable_title Writing to log %}
|
||||
|
||||
This automation will create a new log entry when the door is opened:
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
automation:
|
||||
- alias: Log door opened
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: binary_sensor.door
|
||||
from: 'off'
|
||||
to: 'on'
|
||||
action:
|
||||
service: system_log.write
|
||||
message: 'Door opened!'
|
||||
level: info
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user