Update event automation tutorial to ignore unavailable/unknown states (#41536)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Abílio Costa 2025-10-31 04:25:28 +01:00 committed by GitHub
parent 500fb12205
commit 21f9acaa50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -118,7 +118,16 @@ This section shows a similar example to the example automation shown above in YA
- Type `event` and select your button entity.
- **Important**: Leave the other fields **empty**.
![Select button event as trigger](/images/integrations/event/matter_trigger_on_button_event.png)
4. Define the condition when something should happen.
4. Prevent the automation from running on unavailable or unknown states.
- Under **Conditions**, select **Add building block**, then, select **Not**.
- Inside the **Not** block, select **Add condition**, then, select **Entity** > **State**.
- Type `event` and select your button event entity.
- Under **State**, select **Unavailable**.
- **Important**: Leave the other fields **empty**.
- Add another condition inside the **Not** block, but this time select **Unknown** as the state.
- **Note** Alternatively, instead of conditions this can be done using the `not_state` attribute of the state trigger, in YAML.
![Condition - prevent unavailable or unknown states](/images/integrations/event/matter_condition_prevent_unavailable_unknown.png)
5. Define the condition when something should happen.
- Under **Then do**, select **Add action**.
- Type `choose` and select **Add condition**.
- Select **Entity** > **State** and select your button event entity from the list.
@ -126,12 +135,12 @@ This section shows a similar example to the example automation shown above in YA
- Under **State**, select the state change you want to act as trigger, for example **Pressed once**.
- **Pressed once** is the event type. But the state of this event is the timestamp of when the button was pressed. This is why we automate on the state change so that it is triggered every time the button is pressed.
![Condition - button pressed](/images/integrations/event/matter_condition_button_pressed.png)
5. Define what should happen when your automation is triggered (when the button is pressed, for example).
6. Define what should happen when your automation is triggered (when the button is pressed, for example).
- Select **Add action** and define your action.
6. Repeat these steps for each event type you want to monitor.
7. Repeat these steps for each event type you want to monitor.
- In this example, we want to do something else when the button was pressed twice.
![Condition - add another option when the button is pressed twice](/images/integrations/event/matter_button_option_2.png)
7. **Save** the automation.
8. **Save** the automation.
## Device class