Top 200 ReposEXPLORER
Browse agents, categories and pages
Back to results
Planned, not doneThe source describes an intention, not a finished result.

Adjust Lighting Automatically from Room Occupancy

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

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.

  1. Choose the agentSet up n8n, Home Assistant.
  2. Connect the toolsConnect the tools this workflow relies on: n8n, Home Assistant.
  3. 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.
  4. 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).
  5. Run the starter promptPaste the starter prompt below into n8n and adapt it to your case.
  6. 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].

Preview
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

About n8n-io/n8n

Independent creators. Listing a video implies no endorsement, sponsorship or partnership.

Sources

  1. 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.
  2. 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.
  3. 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.
  4. 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.
Report a problem

More with n8n

Planned, not done

Support Customers Through Telegram Messages

An n8n workflow turns new customer emails and contact-form messages into tasks with draft replies, and sends each draft to the owner in Telegram with Approve and Decline buttons before anything goes out.

docs.n8n.ion8n-io/n8n
Planned, not done

Capture Restaurant Orders With a Conversational Agent

Build an n8n chat that takes a customer's food order from your menu, reads it back, and records it in a data table only after a staff member approves it in Slack.

docs.n8n.ion8n-io/n8n
Reported by source

Build a self-hosted AI agent workflow with human approval

Use n8n's visual canvas to wire an LLM agent to your apps, add tools and memory, and pause for human approval before it acts.

github.comn8n-io/n8n

View all: n8n