Apache Kafka

The Apache Kafka integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] sends all state changes to a Apache Kafka topic.

Apache Kafka is a real-time data pipeline that can read and write streams of data. It stores its data safely in a distributed, replicated, fault-tolerant cluster.

To use the Apache Kafka integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] in your installation, add the following to your configuration.yaml file:

apache_kafka:
  ip_address: localhost
  port: 9092
  topic: home_assistant_1

Configuration Variables

ip_address string Required

The IP address or hostname of an Apache Kafka cluster.

port integer Required

The port to use.

username string (Optional)

The username of Apache Kafka cluster for SASL authentication. Required with SASL_SSL security protocol only.

password string (Optional)

The password of Apache Kafka cluster for SASL authentication. Required with SASL_SSL security protocol only.

security_protocol string (Optional, default: PLAINTEXT)

The security protocol used to communicate with brokers. Use SSL for secure or SASL_SSL for secure with SASL authentication. (only SASL_PLAINTEXT SASL mechanism is supported)

topic string Required

The Kafka topic to send data to.

filter map (Optional)

Filters for entities to be included/excluded. (Configure Filter)

include_domains list (Optional)

Domains to be included.

include_entity_globs list (Optional)

Include all entities matching a listed pattern.

include_entities list (Optional)

Entities to be included.

exclude_domains list (Optional)

Domains to be excluded.

exclude_entity_globs list (Optional)

Exclude all entities matching a listed pattern.

exclude_entities list (Optional)

Entities to be excluded.

Configure filter

By default, no entity will be excluded. To limit which entities are being exposed to Apache Kafka, you can use the filter parameter.

# Example filter to include specified domains and exclude specified entities
apache_kafka:
  ip_address: localhost
  port: 9092
  topic: home_assistant_1
  filter:
    include_domains:
      - alarm_control_panel
      - light
    include_entity_globs:
      - binary_sensor.*_occupancy
    exclude_entities:
      - light.kitchen_light

Filters are applied as follows:

  1. 不使用过滤器
    • 包含所有实体
  2. 仅包含
    • 实体列表中的实体包含:include
    • 否则,实体匹配域包含:include
    • 否则,实体匹配通配符包含:include
    • 否则:排除
  3. 仅排除
    • 实体列表中的实体排除:exclude
    • 否则,实体匹配域排除:exclude
    • 否则,实体匹配通配符排除:exclude
    • 否则:包含
  4. 域和/或通配符包含(还可能有排除)
    • 实体列表中的实体包含:include
    • 否则,实体列表中的排除:exclude
    • 否则,实体匹配通配符包含:include
    • 否则,实体匹配通配符排除:exclude
    • 否则,实体匹配域包含:include
    • 否则:排除
  5. 域和/或通配符排除(没有域和/或通配符包含)
    • 实体列表中的实体包含:include
    • 否则,实体列表中的排除:exclude
    • 否则,实体匹配通配符排除:exclude
    • 否则,实体匹配域排除:exclude
    • 否则:包含
  6. 没有域和/或通配符的包含或排除
    • 实体列表中的实体包含:include
    • 否则:排除

以下字符可用于实体通配符:

* - 星号表示零个、一个或多个字符
? - 问号表示零个或一个字符