Skip to content

Commit

Permalink
Document HA event entity triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
mundschenk-at committed Oct 18, 2024
1 parent 6b4f6bb commit b8f0d90
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions docs/guide/usage/integrations/home_assistant.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,29 @@ The device specific configuration allows you to modify the discovery payload. He

To respond to button clicks (e.g. WXKG01LM) you can use one of the following three Home Assistant configurations.

### Via MQTT device trigger (recommended)
### Via Home Assistant `event` entity (recommended)

[MQTT device trigger](https://www.home-assistant.io/integrations/device_trigger.mqtt/) is the recommended way to respond to button clicks.
The MQTT device triggers are discovered by Zigbee2MQTT **once the event is triggered on the device at least once**.
This method work by responding to the state change of an [`event` entity](https://www.home-assistant.io/integrations/event). The specific event can be targetted via the `event_type` attribute.

```yaml
automation:
- alias: Respond to button click
triggers:
- trigger: state
entity_id: event.my_switch_click
attribute: event_type
to: 'single'
actions:
- action: light.toggle
target:
entity_id: light.bedroom
```
If you only plan to use this (or MQTT device triggers) and want to disable the _Via Home Assistant entity_ integration below, set `homeassistant: {legacy_triggers: false}` (see [Configuration](../../configuration/homeassistant.md) for more info).

### Via MQTT device trigger

The [MQTT device triggers](https://www.home-assistant.io/integrations/device_trigger.mqtt/) are discovered by Zigbee2MQTT **once the event is triggered on the device at least once**.

```yaml
automation:
Expand All @@ -59,11 +78,11 @@ automation:
entity_id: light.bedroom
```

If you only plan to use this and want to disable the _Via Home Assistant entity_ integration below, set `homeassistant: {legacy_triggers: false}` (see [Configuration](../../configuration/homeassistant.md) for more info).
If you only plan to use this (or Home Assistant `event` entities) and want to disable the _Via Home Assistant `sensor` entity_ integration below, set `homeassistant: {legacy_triggers: false}` (see [Configuration](../../configuration/homeassistant.md) for more info).

### Via Home Assistant entity
### Via Home Assistant `sensor` entity (deprecated)

This method work by responding to the state change event of a sensor.
This method work by responding to the state change event of a legacy `sensor` entity. These entities will be removed in Zigbee2MQTT 2.x. Please migrate your automations to use `event` entities before then.

```yaml
automation:
Expand Down Expand Up @@ -290,7 +309,7 @@ automation:
metadata: {}
data:
options: |
{%- set find_integration = 'mqtt' %}
{%- set find_integration = 'mqtt' %}
{%- set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
{%- set ns = namespace(entities = []) %}
{%- for device in devices if device_attr(device, 'identifiers') %}
Expand Down

0 comments on commit b8f0d90

Please sign in to comment.