Skip to content
Merged
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
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/motion-activated-lights-clear.gif
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.
Binary file added docs/assets/motion-activated-lights-detected.gif
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
title: Motion-Activated Room Lights
description: >-
Use your ESPHome Starter Kit's motion sensor to turn the real lights in a room
on and off through a Home Assistant automation.
---
# Motion-Activated Room Lights

This is where the kit stops being a learning toy and starts earning its keep. Your Starter Kit's motion sensor reports into Home Assistant, so it can switch on the actual lights in a room, a smart bulb, a wall switch, a lamp on a plug, then switch them back off once the room goes quiet.

<div class="annotate" markdown>

This automation lives in **Home Assistant** and controls *other* lights in your home, not the kit's own LED. (1)

</div>

1. Don't confuse it with the on-device [Turn On a Light with Motion](../automations/motion-activated-light.md) automation, which runs on the kit itself and only controls the kit's RGB LED. Use that one to learn ESPHome, use this one to actually light up a room.

!!! note "Before you start"

* Your kit is added to Home Assistant. If it isn't yet, work through [Connect to Home Assistant](../tutorials/connect-to-home-assistant.md) first.
* The [Motion module](../modules/motion-module.md) is connected, so the kit reports a **Motion Module** sensor that reads `on` when it sees movement.
* You have at least one light Home Assistant can already control, and you know its name.

## Place the sensor first

The automation is only as good as what the sensor can see, so aim it before you build anything. The kit's MH-SR602 sensor has about a 100&deg; cone and picks up movement out to roughly 5 meters (16 feet), and it's most reliable inside 3.5 meters (11 feet).

* Point it across the path people walk, like a doorway or hallway, not straight at a couch where they sit still. A PIR sensor fires on movement crossing its cone, so foot traffic trips it far more reliably than someone barely moving.
* Set it about 1.5 to 2 meters (5 to 6.5 feet) off the floor and tilt it slightly downward so the cone covers the room rather than the far wall.
* Keep it away from sunny windows, heating vents, and radiators. A fast change in heat can trip a PIR sensor on its own and leave your lights flicking on with no one there.

Pick one path below, or do both. Level 1 uses Home Assistant's built-in blueprint and takes about two minutes. Level 2 builds the same behavior by hand so you can see how it works and grow it later.

## Level 1: Use the built-in blueprint

<span class="difficulty lvl-1">Difficulty: Level 1</span>

A blueprint is a fill-in-the-blanks automation. Home Assistant ships one called **Motion-activated Light** that does exactly this job: light on when a sensor sees motion, off after a set quiet period.

<div class="annotate" markdown>

1. Open [Settings → Automations & scenes → Blueprints](https://my.home-assistant.io/redirect/blueprints/) and look for **Motion-activated Light**. If it's there, skip to step 3. (1)

![](../../../assets/motion-activated-lights-select-blueprint.gif)

2. If it's missing, click **Import Blueprint** in the bottom right, paste the URL below, then click **Preview** and **Import Blueprint**.

```text
https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
```

3. Click **Create Automation** on the blueprint, then fill in the three fields:
* **Motion Sensor** → your kit's **Motion Module** sensor.
* **Light Target** → the light you want to control.
* **Wait time** → seconds to leave the light on after the last movement. 120 is a sensible start. (2)

![](../../../assets/motion-activated-lights-configure-blueprint.gif)

</div>

1. Home Assistant lets you delete the default blueprints, so it's common for this one to be missing. The import in step 2 puts it back.
2. Reopen the automation and change this any time the light drops too soon or stays on too long.

Click **Save**, give the automation a name like `Motion Activated Lights`, and if you like, add a label such as `Lighting` to group it with your other light automations. Click **Save** to finish.

Walk into the room and the light comes on. Stand still past the wait time and it goes back off.

## Level 2: Build it by hand

<span class="difficulty lvl-2">Difficulty: Level 2</span>

The blueprint hides the moving parts. Building the automation yourself shows you the trigger-and-action pattern behind every Home Assistant automation, and it leaves you room to add more behavior later.

You could make two automations, one to turn the light on and one to turn it off. Instead you'll keep both in a single automation using **trigger IDs**, a label on each trigger, feeding a **Choose** action that runs a different branch depending on which trigger fired.

<div class="annotate" markdown>

1. Open [Settings → Automations & scenes](https://my.home-assistant.io/redirect/automations/), click **Create Automation**, then **Create new automation**.
2. Click **Add Trigger**, search **motion**, and click **Motion detected**. Set its target to your **Motion Module** sensor. Open the trigger's menu (the three dots), choose **Rename**, and set the **Trigger ID** to `Detected`. (1)

![](../../../assets/motion-activated-lights-detected.gif)

3. Add another trigger the same way, this time **Motion cleared** on the same **Motion Module**, with **For** → 2 minutes. Set its **Trigger ID** to `Clear`. (2)

![](../../../assets/motion-activated-lights-clear.gif)

4. Under **Then do**, add **Building Blocks → Choose**.
5. In **Option 1**, add a **Triggered by** condition set to `Detected`, then an action of **Light → Turn on** targeting your room light.

![](../../../assets/motion-activated-lights-choose-option-1.gif)

6. Add **Option 2** with a **Triggered by** condition of `Clear` and a **Light → Turn off** action on the same light.

![](../../../assets/motion-activated-lights-choose-option-2.gif)

7. Click the three dots in the top right, choose **Change mode**, select **Restart**, then click **Change mode** to confirm. (3)

![](../../../assets/motion-activated-lights-change-mode.gif)

</div>

1. The trigger ID is just a name. The **Choose** action reads it to decide which branch to run.
2. The **For** delay means **Clear** only fires after the room has been still for two full minutes, so the light doesn't drop the moment you hold still.
3. `restart` makes fresh motion reset the off-timer. The default `single` mode would ignore movement until the run finished.

??? note "The finished automation in YAML"

Paste this into **Edit in YAML** and swap in your own entity names.

```yaml
alias: Motion Activated Lights
description: ""
triggers:
- trigger: motion.detected
target:
entity_id: binary_sensor.esphome_starter_kit_motion_module # (1)!
options:
for: "00:00:00"
id: Detected
- trigger: motion.cleared
target:
entity_id: binary_sensor.esphome_starter_kit_motion_module
options:
for:
hours: 0
minutes: 2
seconds: 0
id: Clear
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- Detected
sequence:
- action: light.turn_on
metadata: {}
target:
entity_id: light.brandons_room # (2)!
data: {}
- conditions:
- condition: trigger
id:
- Clear
sequence:
- action: light.turn_off
metadata: {}
target:
entity_id: light.brandons_room
data: {}
mode: restart
```

1. Your sensor's entity ID may differ. Start typing in the editor and pick it from the list. It usually follows `binary_sensor.<device-name>_motion_module`.
2. Swap `light.brandons_room` for your own light in both branches.

Click **Save**, give the automation a name like `Motion Activated Lights`, and if you like, add a label such as `Lighting` to group it with your other light automations. Click **Save** to finish.

![](../../../assets/motion-activated-lights-name-and-label.gif)

Now walk in. The light comes on, the room goes still, and after the quiet period it turns off. From here you can add a [condition](https://www.home-assistant.io/docs/scripts/conditions/) so it only runs after sunset, or point the `Detected` branch at a whole scene.

--8<-- "_snippets/community-help.md"
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
title: Temperature on Your Dashboard
description: >-
Add your ESPHome Starter Kit's temperature and humidity readings to a Home
Assistant dashboard using built-in Tile and Gauge cards.
---
# Temperature on Your Dashboard

Your kit reads the temperature and humidity of whatever room it's in. Putting those readings on a Home Assistant dashboard turns it into a glanceable display you'll actually check. Everything here uses cards that ship with Home Assistant, so there's nothing to install.

!!! note "Before you start"

* Your kit is added to Home Assistant. If not, start with [Connect to Home Assistant](../tutorials/connect-to-home-assistant.md).
* The [Temperature and Humidity module](../modules/temperature-humidity-module.md) is connected, so Home Assistant has a **Temperature** sensor and a **Humidity** sensor from the kit.

Level 1 is the everyday display. Level 2 is an optional upgrade you can add on top. Open your dashboard, click the pencil in the top right to start editing, then follow whichever level you like.

## Level 1: Tile cards

<span class="difficulty lvl-1">Difficulty: Level 1</span>

A Tile card is the small, modern card you see across most Home Assistant dashboards: an icon, a name, and the current reading. You'll add one for temperature and one for humidity.

<div class="annotate" markdown>

1. With the dashboard in edit mode, click **Add Card** and open the **By entity** tab.
2. Search `starter kit` and check both the **Temperature** and **Humidity** sensors. (1)
3. Click **Tile** to lay them out as two tiles, then click **Save**.

![](../../../assets/temp-on-dashboard-select-temp-hum-tile-cards.gif)

</div>

1. The preview fills in with the live reading as soon as you pick an entity, so you can confirm you grabbed the right ones.

You now have a trustworthy temp and humidity sensor on your dashboard. Take it to the next level and set up alerts to notify you when your humidity gets high, or turn your AC on when your room gets over 75&deg;F!

## Level 2: A humidity gauge

<span class="difficulty lvl-2">Difficulty: Level 2</span>

A Gauge card shines when a higher reading really does mean worse, and indoor humidity is exactly that. Push past about 60% and you start inviting mold, musty air, and dust mites. The dial runs from green to red as the room gets muggy, so trouble is obvious at a glance.

<div class="annotate" markdown>

1. Click **Add Card** and search for **Gauge**.
2. Set **Entity** to your kit's **Humidity** sensor and give it a **Name** like `Kitchen Humidity`.
3. Set **Minimum** to `0` and **Maximum** to `100`, the full percentage range.
4. Toggle on **Display as needle gauge**, then turn on **Severity** and set green at `0`, yellow at `50`, and red at `60`. (1)

![](../../../assets/temp-on-dashboard-humidity-gauge-card.gif)

</div>

1. Indoor humidity is comfortable around 30 to 50%. Yellow from 50% is your cue to ventilate, and red past 60% is where mold and dust mites thrive.

Temperature and humidity now live on your dashboard. Drop the cards into a [Sections view](https://www.home-assistant.io/dashboards/sections/) next to the rest of a room's controls and you're off to building out a great dashboard!

??? note "Both cards in YAML"

Edit any card and choose **Show code editor** to paste these in. Swap in your own entity names; yours usually follow `sensor.<device-name>_temperature`.

```yaml
# Level 1: two Tile cards
type: tile
entity: sensor.esphome_starter_kit_temperature
---
type: tile
entity: sensor.esphome_starter_kit_humidity
```

```yaml
# Level 2: humidity Gauge with severity colors
type: gauge
entity: sensor.esphome_starter_kit_humidity
min: 0
max: 100
needle: true
severity:
green: 0
yellow: 50
red: 60
name: Kitchen Humidity
```

--8<-- "_snippets/community-help.md"
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ nav:
- Motion-Activated Light: products/ESPHome-Starter-Kit/automations/motion-activated-light.md
- Temp-Reactive LEDs: products/ESPHome-Starter-Kit/automations/temp-reactive-leds.md
- Press to Check Climate: products/ESPHome-Starter-Kit/automations/press-to-check-climate.md
- Everyday Use:
- Motion-Activated Room Lights: products/ESPHome-Starter-Kit/everyday-use/motion-activated-room-lights.md
- Temperature on Your Dashboard: products/ESPHome-Starter-Kit/everyday-use/temperature-on-your-dashboard.md
- Learn the Basics:
- Explaining ESPHome: products/ESPHome-Starter-Kit/learning-the-basics/explaining-esphome.md
- Device Builder Tour: products/ESPHome-Starter-Kit/learning-the-basics/device-builder-tour.md
Expand Down