Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use presence detection in automations #34168

Draft
wants to merge 2 commits into
base: current
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/_includes/asides/getting_started_navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ <h1 class="title epsilon">{% icon "mdi:rocket-launch-outline" %} Getting started
<li>{% active_link /getting-started/integration/ Adding integrations %}</li>
<li>{% active_link /getting-started/automation/ Automating devices %}</li>
<li>{% active_link /getting-started/presence-detection/ Presence detection %}</li>
<li>{% active_link /getting-started/presence-detection_in_automation/ Presence detection in automations %}</li>
<li>{% active_link /getting-started/join-the-community/ Join the community %}</li>
<li>{% active_link /getting-started/configuration/ Next steps %}</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion source/getting-started/presence-detection.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ There are different ways of setting up zone presence detection. One way is to ru
[condition]: /getting-started/automation-condition/#zone-condition
[companion]: https://companion.home-assistant.io/

{% include getting-started/next_step.html step="Join the Community" link="/getting-started/join-the-community/" %}
{% include getting-started/next_step.html step="Presence detection in automations" link="/getting-started/presence-detection_in_automation/" %}
42 changes: 42 additions & 0 deletions source/getting-started/presence-detection_in_automation.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: "Using presence detection in automation"
description: "Instructions on how to use presence detection in automations."
---

Now that you have [set up a device for presence detection](/getting-started/presence-detection/), you can use it in automations.

## Using presence detection as condition in automations

In this tutorial, our goal is to run the [turning on the lights before sunset](/getting-started/automation/#turning-on-the-lights-before-sunset) automation only if we are home. This automation is triggered by the sunset. We want to add a condition.

### Prerequisites

- For this tutorial, we are going to work with the automation created in the tutorial on [Automating Home Assistant](/getting-started/automation/). But you can apply these steps in other automations you may already have.
- You have completed the tutorial on [presence detection](/getting-started/presence-detection/) and set up at least one device tracker.

### To use presence detection as a condition in automation

1. Go to {% my automations title="**Settings** > **Automations & scenes**" %} and open the automation we created before, on [turning on the lights before sunset](/getting-started/automation/#turning-on-the-lights-before-sunset).
2. Select **Add condition**.
3. There are multiple ways to add a condition based on presence. Choose one of the options:
- **Option 1**: If there are multiple people in this home, and you want the light to turn on if at least one person is home:
- Under **Search condition**, enter `num`, and select **Numeric state**.
- Under **Entity**, enter `zone`, and select the home zone: `zone.home`.
- Under **Attribute**, select **Persons**.
- Select **Fixed number**.
- Under **Above**, enter `0`.

![Screenshot showing an automation condition when someone is home](/images/getting-started/condition_zone_persons_home.png)

- **Option 2**: If you want to run this automation only if a specific device is home, follow this steps:
- Select **Entity**, then **State**.
- Under **Entity**, enter `device_`. This will bring up the list of device trackers. Select it. In this example, it is the `device_tracker.pixel_7_pro`.
- Under **State**, select **Home**.
- Now, the light will only turn on, when this specific device is home.

![Screenshot showing an automation condition when someone is home](/images/getting-started/condition_zone_device_home.png)

4. Select **Save**.
5. Congratulations! Now, your automation will only run if someone is home.

{% include getting-started/next_step.html step="Join the Community" link="/getting-started/join-the-community/" %}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.