Home Assistant runs a lot of my house: lights, radiator heads per room, presence. Under the dashboards it is a simple machine. This page uses an invented house with three rooms and one invented evening. Nothing here connects to a real home.
01 · States
Everything in the house is a state.
A temperature sensor's state is a number, a window sensor is open or closed, and the number of people at home is a state too. Home Assistant keeps the latest state of everything, notes when it last changed and remembers every change. Move the evening clock.
19:30the evening clock
1 tick is 1 change: 11 since 17:00
The house at 19:30
What Home Assistant keeps
| State | Value | Last changed |
|---|---|---|
| Living room temperature | 18.5 °C | 19:00 |
| Bedroom temperature | 17.6 °C | 18:40 |
| Living room window | closed | 19:20 |
| People at home | 1 | 18:05 |
| Living room heating | set to 17 °C | 08:20 |
| Front door | locked | 08:20 |
Newest change: 19:20: living room window becomes closed.
Show as text
| Time | What changed | Living room | Bedroom | Window | People home |
|---|---|---|---|---|---|
| 17:00 | Start of the evening (heating set to 17 °C, front door locked) | 19.4 °C | 18.0 °C | closed | 0 |
| 17:15 | Living room temperature | 19.2 °C | 18.0 °C | closed | 0 |
| 17:25 | Living room temperature (drops below 19 °C, nobody home) | 18.9 °C | 18.0 °C | closed | 0 |
| 17:45 | Bedroom temperature | 18.9 °C | 17.8 °C | closed | 0 |
| 18:05 | People at home (someone comes home) | 18.9 °C | 17.8 °C | closed | 1 |
| 18:20 | Living room temperature (cooking warms the room) | 19.1 °C | 17.8 °C | closed | 1 |
| 18:35 | Living room temperature | 19.3 °C | 17.8 °C | closed | 1 |
| 18:40 | Bedroom temperature | 19.3 °C | 17.6 °C | closed | 1 |
| 18:45 | Living room window (window opened for air) | 19.3 °C | 17.6 °C | open | 1 |
| 18:50 | Living room temperature (drops below 19 °C again, window open) | 18.8 °C | 17.6 °C | open | 1 |
| 19:00 | Living room temperature | 18.5 °C | 17.6 °C | open | 1 |
| 19:20 | Living room window (window closed) | 18.5 °C | 17.6 °C | closed | 1 |
Before 17:00 the window last changed at 07:50, and the heating and the front door at 08:20. Neither the heating nor the front door changes this evening.
Automations never look at devices. They look at states and react when a state changes.
02 · Your automation
An automation is: when, only if, then.
Build one. Pick a trigger, a condition and an action. You get the automation as one sentence, the moments it would have fired on this evening, and below the drawing the YAML that Home Assistant would store.
Your automation
When the living room drops below 19 °C
only if someone is home
then set the living room heating to 20.5 °C
This evening, 17:00 to 19:30
Fires once, at 18:50.
- 17:25: blocked, nobody home
- 18:50: fires
Show as text
Every trigger and condition on this evening. The action does not change when it fires.
| When | Only if | On this evening |
|---|---|---|
| the living room drops below 19 °C | no condition | Fires 2 times: at 17:25 and 18:50. |
| the living room drops below 19 °C | someone is home | Fires once, at 18:50. Blocked at 17:25: nobody home. |
| the living room drops below 19 °C | the window is closed | Fires once, at 17:25. Blocked at 18:50: window open. |
| someone comes home | no condition | Fires once, at 18:05. |
| someone comes home | someone is home | Fires once, at 18:05. |
| someone comes home | the window is closed | Fires once, at 18:05. |
| it is 17:30 | no condition | Fires once, at 17:30. |
| it is 17:30 | someone is home | Never fires this evening. Blocked at 17:30: nobody home. |
| it is 17:30 | the window is closed | Fires once, at 17:30. |
Your automation as YAML, the way Home Assistant stores it
alias: "Living room below 19 °C, someone home, heat to 20.5 °C"
description: "Example from jasperhaynes.com/lab: change the entity ids to your own"
triggers:
- trigger: numeric_state
entity_id: sensor.living_room_temperature
below: 19
conditions:
- condition: numeric_state
entity_id: zone.home # its state is the number of people at home
above: 0
actions:
- action: climate.set_temperature
target:
entity_id: climate.living_room
data:
temperature: 20.5
mode: single
The entity ids are examples: change them to your own before you paste this in Home Assistant (Settings, Automations, Edit in YAML).
Three example automations as text and YAML
1. When the living room drops below 19 °C, only if someone is home, then set the living room heating to 20.5 °C. Fires once, at 18:50.
alias: "Living room below 19 °C, someone home, heat to 20.5 °C"
description: "Example from jasperhaynes.com/lab: change the entity ids to your own"
triggers:
- trigger: numeric_state
entity_id: sensor.living_room_temperature
below: 19
conditions:
- condition: numeric_state
entity_id: zone.home # its state is the number of people at home
above: 0
actions:
- action: climate.set_temperature
target:
entity_id: climate.living_room
data:
temperature: 20.5
mode: single 2. When someone comes home, with no condition, then set the living room heating to 20.5 °C. Fires once, at 18:05.
alias: "Someone comes home, always, heat to 20.5 °C"
description: "Example from jasperhaynes.com/lab: change the entity ids to your own"
triggers:
- trigger: numeric_state
entity_id: zone.home # its state is the number of people at home
above: 0
actions:
- action: climate.set_temperature
target:
entity_id: climate.living_room
data:
temperature: 20.5
mode: single 3. When it is 17:30, only if someone is home, then send a message to your phone. Never fires this evening.
alias: "At 17:30, someone home, message my phone"
description: "Example from jasperhaynes.com/lab: change the entity ids to your own"
triggers:
- trigger: time
at: "17:30:00"
conditions:
- condition: numeric_state
entity_id: zone.home # its state is the number of people at home
above: 0
actions:
- action: notify.send_message
target:
entity_id: notify.my_phone # your phone
data:
message: "It is 17:30"
mode: single The trigger decides the moment, the condition guards it. Most surprises come from a missing condition.
03 · Replay
Test it on a replay of one evening.
Here is the evening again, drawn to scale: the living room temperature, who is home and the window. Every version starts from the same trigger (the living room drops below 19 °C) and does the same thing (heat it); the last version adds a second trigger. Pick a version and watch which moments it lets through.
When the living room drops below 19 °C or the window closes, only if someone is home, the window is closed and it is below 19 °C, heat it.
Trigger moments
Living room temperature
Someone home
Window open
What happens
- 117:25 drops below 19 °Cblocked: nobody home
- 218:50 drops below 19 °Cblocked: window open
- 319:20 the window closesall conditions met: fires
Fires once, at 19:20: someone is home, the window has just closed and the room is at 18.5 °C.
Show as text
| Version | Trigger moments | Result |
|---|---|---|
| When the living room drops below 19 °C, heat it. | 17:25 (drops below 19 °C): no condition: fires; 18:50 (drops below 19 °C): no condition: fires | Fires twice: at 17:25 it heats an empty house, at 18:50 it heats with the window open. |
| When the living room drops below 19 °C, only if someone is home, heat it. | 17:25 (drops below 19 °C): blocked: nobody home; 18:50 (drops below 19 °C): all conditions met: fires | Fires once, at 18:50: someone is home, but the window is open. |
| When the living room drops below 19 °C, only if the window is closed, heat it. | 17:25 (drops below 19 °C): all conditions met: fires; 18:50 (drops below 19 °C): blocked: window open | Fires at 17:25 for an empty house. When the window closes at 19:20 nothing happens: the condition was checked at 18:50, and the room stays at 18.5 °C. |
| When the living room drops below 19 °C or the window closes, only if someone is home, the window is closed and it is below 19 °C, heat it. | 17:25 (drops below 19 °C): blocked: nobody home; 18:50 (drops below 19 °C): blocked: window open; 19:20 (the window closes): all conditions met: fires | Fires once, at 19:20: someone is home, the window has just closed and the room is at 18.5 °C. |
The temperature scale runs from 18.2 to 19.6 °C. Someone is home from 18:05, and the window is open from 18:45 to 19:20.
A condition is only checked at the moment the trigger fires. A replay shows you those moments before your house does.
04 · AI on top
An assistant may read and suggest; some things need your yes.
With an AI assistant connected to Home Assistant you can ask questions in plain language. At 19:30 on the same evening, three requests and the rule I use at home for each. The replies are written for this page; nothing is sent to a model.
It is 17.6 °C in the bedroom.
Read: bedroom temperature, 17.6 °C
The living room is 18.5 °C and the heating is set to 17 °C. Shall I set it to 20.5 °C?
You: Yes.
Living room heating: 17 → 20.5 °C
I do not unlock doors or switch off alarms from a chat. Use the Home Assistant app and your own code.
Front door: still locked
Show as text
"How warm is the bedroom?" It reads one state, so the rule is: answer straight away. Assistant: "It is 17.6 °C in the bedroom." Result: Read: bedroom temperature, 17.6 °C.
"Make the living room warmer." It changes the heating, so the rule is: ask you first. Assistant: "The living room is 18.5 °C and the heating is set to 17 °C. Shall I set it to 20.5 °C?" You: "Yes." Result: Living room heating: 17 → 20.5 °C.
"Unlock the front door." It opens a lock, so the rule is: never from a chat. Assistant: "I do not unlock doors or switch off alarms from a chat. Use the Home Assistant app and your own code." Result: Front door: still locked.
Reading is cheap and safe. Acting on heating, locks and alarms needs a person in the loop.