Logbook

The logbook integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] provides a different perspective on the history of your
house by showing all the changes that happened to your house in reverse
chronological order. It depends on
the recorder
integration for storing the data. This means that if the
recorder
integration is set up to use e.g., MySQL or
PostgreSQL as data store, the logbook
integration does not use the default
SQLite database to store data.
This integration is by default enabled, unless you’ve disabled or removed the default_config:
line from your configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file. If that is the case, the following example shows you how to enable this integration manually, by adding it to your configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file:
# Example configuration.yaml entry
logbook:
Configuration Variables
Configure which integrations should not create logbook entries. (Configure Filter)
Exclude all entities matching a listed pattern from creating logbook entries (e.g., sensor.weather_*
).
Configure which integrations should create logbook entries. (Configure Filter)
Include all entities matching a listed pattern when creating logbook entries (e.g., sensor.weather_*
).
Configure filter
By default, the logbook will use the same filter as the recorder. To limit which entities are being exposed to Logbook
, you can use the include
and exclude
parameters.
# Example filter to include specified domains and exclude specified entities
logbook:
include:
domains:
- alarm_control_panel
- light
entity_globs:
- binary_sensor.*_occupancy
exclude:
entities:
- light.kitchen_light
Filters are applied as follows:
- 不使用过滤器
- 包含所有实体
- 仅包含
- 实体列表中的实体包含:include
- 否则,实体匹配域包含:include
- 否则,实体匹配通配符包含:include
- 否则:排除
- 仅排除
- 实体列表中的实体排除:exclude
- 否则,实体匹配域排除:exclude
- 否则,实体匹配通配符排除:exclude
- 否则:包含
- 域和/或通配符包含(还可能有排除)
- 实体列表中的实体包含:include
- 否则,实体列表中的排除:exclude
- 否则,实体匹配通配符包含:include
- 否则,实体匹配通配符排除:exclude
- 否则,实体匹配域包含:include
- 否则:排除
- 域和/或通配符排除(没有域和/或通配符包含)
- 实体列表中的实体包含:include
- 否则,实体列表中的排除:exclude
- 否则,实体匹配通配符排除:exclude
- 否则,实体匹配域排除:exclude
- 否则:包含
- 没有域和/或通配符的包含或排除
- 实体列表中的实体包含:include
- 否则:排除
以下字符可用于实体通配符:
*
- 星号表示零个、一个或多个字符
?
- 问号表示零个或一个字符
Common filtering examples
If you want to exclude messages of some entities or domains from the logbook
just add the exclude
parameter like:
# Example of excluding domains and entities from the logbook
logbook:
exclude:
entities:
- sensor.last_boot
- sensor.date
entity_globs:
- sensor.weather_*
domains:
- sun
In case you just want to see messages from some specific entities or domains use
the include
configuration:
# Example to show how to include only the listed domains and entities in the logbook
logbook:
include:
domains:
- sensor
- switch
- media_player
You can also use the include
list and filter out some entities or domains with
an exclude
list. Usually this makes sense if you define domains on the include
side and filter out some specific entities.
# Example of combining include and exclude configurations
logbook:
include:
domains:
- sensor
- switch
- media_player
exclude:
entities:
- sensor.last_boot
- sensor.date
entity_globs:
- sensor.weather_*
Exclude events
If you have sensor.date
to show the current date in the UI,
but you do not want a logbook entry for that sensor every day it can be excluded.
To exclude these entities just add them to the exclude
> entities
list in
the configuration of the logbook.
To exclude all events from a whole domain add it to the exclude
> domain
list. For instance you use the sun
domain only to trigger automations on the
azimuth
attribute, then you possible are not interested in the logbook entries
for sun rise and sun set.
Excluded entities still take up space in the database. It may be advisable to
exclude them in recorder
instead.
Custom entries
It is possible to add custom entries to the logbook by using the script integration to fire an event.
# Example configuration.yaml entry
script:
add_logbook_entry:
alias: "Add Logbook"
sequence:
- action: logbook.log
data:
name: Kitchen
message: is being used
# Optional
entity_id: light.kitchen
domain: light
When calling the logbook.log
action without a domain
or entity_id
, entries will be added with the logbook
domain. Ensure that the logbook
domain is not filtered away if you want these entries to appear in your logbook.
Sensor entities that have been assigned units (i.e., have a unit_of_measurement
attribute) are assumed to change frequently and those sensors are automatically excluded from the logbook.