Overview
An n8n workflow checks Home Assistant presence sensors every few minutes, and an AI Agent node picks a brightness for occupied rooms by time of day, within limits you set, and calls the light service.
Problem or Objective
- Which assistants control smart-home devices by voice or text?
- Which agents run multi-step workflows across your apps?
More in Home and Devices
AI Agents and Models
Tools and Integrations
- Tools
- n8n · Home Assistant
- Prerequisites
- A running Home Assistant with presence or motion sensors and dimmable lights, an n8n instance with Home Assistant credentials, and an API key for a chat model.
How It Works
In n8n, add Home Assistant credentials and start a workflow with a Schedule Trigger set to a short minutes interval. Use the Home Assistant node to get the state of each room's presence or motion sensor and the current time in your workflow timezone. Pass these to an AI Agent node with a chat model and the Home Assistant node attached as its tool, limited to calling the light service for the lights you list. Tell the agent the brightness range allowed for each room and time band, to switch lights off only after a room has been empty for a set time, and to leave any light alone that someone changed by hand recently. For the first days, replace the service call with a log entry that records what the agent would have done; read that log, adjust the rules, and only then let the agent call the light service.
Implementation Workflow
Steps assembled from the agents, tools and prompt of this entry. Adapt them to your own setup.
- Choose the agentSet up n8n, Home Assistant.
- Connect the toolsConnect the tools this workflow relies on: n8n, Home Assistant.
- Check the prerequisitesA running Home Assistant with presence or motion sensors and dimmable lights, an n8n instance with Home Assistant credentials, and an API key for a chat model.
- Gather your detailsCollect what the prompt asks for: Rooms and their lights, Brightness range per time band, Minutes a room must be empty before lights go off, Lights someone changed by hand recently, Log only, without changing lights (yes or no).
- Run the starter promptPaste the starter prompt below into n8n and adapt it to your case.
- Check against the documentationCompare what you get with the documentation at docs.n8n.io before you rely on it.
Practical Starter Prompt: Choose light levels for occupied rooms
Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].
You control lighting for these rooms: [Rooms and their lights]. Each run you receive the presence sensor state for each room and the current local time. For an occupied room, choose a brightness inside the range in [Brightness range per time band] for the current time band. Turn a room's lights off only after it has been empty for [Minutes a room must be empty before lights go off] minutes. Do not touch any light listed in [Lights someone changed by hand recently]. Only call the light service for the lights listed for these rooms. While [Log only, without changing lights (yes or no)] is yes, do not call any service: write the action you would take to the log so a person can review it and approve going live.Start with dry run set to yes and read the log for a few days. A person reviews the logged choices and approves before you switch dry run to no and let the agent call the light service. Keep wall switches and Home Assistant controls working as a manual override.
Expected Results and Benefits
This is a suggested workflow, not a reported result. The points below are what the cited documentation says the tools can do.
This is a suggested workflow, not a reported outcome. The n8n docs say the AI Agent node lets a chat model decide which connected tools to call, that the Home Assistant node can get an entity's state and call a service within a domain, and that it can be used as an AI tool. The Schedule Trigger docs cover runs at minute intervals. None of these pages describes lighting by occupancy specifically, and comfort or energy effects were not measured.
Limitations and Considerations
Lights should keep working without n8n: keep your wall switches and Home Assistant's own controls, and decide what happens when n8n or the model is down. Give the agent the narrowest Home Assistant access you can, and test the brightness limits so nobody is left in the dark at night. The Home Assistant credentials in n8n can control your home, so store them only in n8n's credential store. n8n's Schedule Trigger docs say a schedule runs only once the workflow is published and follows the workflow or instance timezone. Each run calls a model, so check the cost of a run every few minutes. Results depend on your setup and were not independently reproduced by Top 200 Repos.
GitHub Repositories
AI Agent Repository
Source code of the agent that does the work.
Related Videos
About n8n-io/n8n
Give Your Agent Tools (n8n Agents Course 5/7) (opens in a new tab)
Walkthrough of n8n by n8n: it is on the project’s own channel.
Watch on YouTube (opens in a new tab)About n8n-io/n8n
n8n AI Nodes: Connect OpenAI, Claude, and Local Models (opens in a new tab)
Walkthrough of n8n by AI Daily Lab: its description links the GitHub repository.
Watch on YouTube (opens in a new tab)Independent creators. Listing a video implies no endorsement, sponsorship or partnership.
Sources
- AI Agent | Nodes | n8n Docs (opens in a new tab)
Project documentation · docs.n8n.io · Undated · Source checked 26 Nov 2026, 17:27 UTC
What this source supports
- The AI Agent node lets you build an AI agent in n8n: connect a chat model and one or more tools, and the agent decides which tools to call to complete a task.
- Home Assistant | Nodes | n8n Docs (opens in a new tab)
Project documentation · docs.n8n.io · Undated · Source checked 27 Nov 2026, 06:30 UTC
What this source supports
- The Home Assistant node can get a state for a specific entity and call a service within a specific domain.
- This node can be used as an AI tool.
- Schedule Trigger | Nodes | n8n Docs (opens in a new tab)
Project documentation · docs.n8n.io · Undated · Source checked 25 Nov 2026, 12:10 UTC
What this source supports
- Use the Schedule Trigger node to run workflows at fixed intervals and times, including a minutes trigger interval.
- The node relies on the timezone setting: the workflow timezone, if set, or the n8n instance timezone.
- home-assistant/core README (opens in a new tab)
Project documentation · github.com · Undated · Source checked 26 Nov 2026, 23:34 UTC
What this source supports
- Open source home automation that puts local control and privacy first.

