Set lighting brightness with an AI agent on presence

Tired of manually adjusting your smart lights throughout the day? Task: Tired of manually adjusting your smart lights throughout the day? This n8n and Home Assistant integration creates the perfect ambient lighting automatically. When presence is detected, an AI determines the ideal brightness based on time of day - no more harsh lighting at night or dim lighting in the morning. Why Automate Lighting with AI? Manual light adjustment is one of those small daily frustrations that add up over time. You walk into a room at night and the lights blast at full brightness, or try to read in the afternoon with insufficient lighting. Traditional automations based on simple time schedules can't account for seasonal changes or personal preferences. By combining n8n's workflow automation with Home Assistant's device control and AI decision-making, we create a system that understands context. The AI considers not just the time of day, but can eventually incorporate factors like weather conditions, your calendar schedule, and even personal preferences learned over time. Studies show that properly tuned lighting can improve productivity by up to 20% during daytime hours while promoting better sleep when dimmed appropriately at night. This automation brings those benefits automatically. Setting Up n8n in Home Assistant While Home Assistant excels at device control, n8n brings powerful workflow automation capabilities. The first step is installing n8n as a Home Assistant add-on, which requires adding the n8n repository since it's not included in the default store. After adding the repository URL (available in the video description), you can install n8n like any other add-on. Before starting it, be sure to set your timezone in the configuration tab - this ensures time-based automations work correctly. The installation pulls down a Docker image and sets up all required components automatically. Pro Tip: Allocate sufficient memory to your Home Assistant instance before installing n8n. The combined system works best with at least 4GB RAM available. Configuring the Webhook Trigger The most challenging part of this integration is establishing communication between Home Assistant and n8n. Since n8n can't directly subscribe to Home Assistant sensor changes, we use webhooks as the bridge between the systems. In n8n, create a new webhook node and configure it to listen for POST requests. You'll need a long-lived access token from Home Assistant (created in your user profile's security section) to authenticate the connection. The webhook URL generated by n8n will be used in the Home Assistant automation later. At 3:45 in the video, you'll see the critical troubleshooting step - replacing the default hostname with your Home Assistant's actual IP address to ensure reliable connectivity between the systems on your local network. Adding AI Decision Making The magic happens in the AI agent node where we define rules for lighting based on time of day. The prompt instructs the AI to act as a lighting designer, analyzing the current time and determining appropriate brightness levels. For this implementation, we're using Deepseek's API (which recently reduced prices by 50%), but you could substitute OpenAI, Anthropic, or other providers. The AI node outputs a brightness percentage that flows into the next step of the workflow. Example AI Prompt: "Act as a professional lighting designer. Given the current time is {time}, recommend an appropriate brightness percentage (0-100) for ambient room lighting. Consider human circadian rhythms and typical daily activities at this hour." Controlling the Lights The final node in the n8n workflow uses Home Assistant's service call capability to actually adjust the lights. You'll need your light's entity ID from Home Assistant and will configure the service to "turn_on" with the brightness attribute set to the value determined by the AI. This separation of decision-making (in n8n) from device control (in Home Assistant) is powerful. It means you can change the AI logic or add new decision factors without modifying how the lights are controlled. The systems work together while maintaining their separate strengths. Creating the Home Assistant Automation With the n8n workflow ready, we need to create the Home Assistant automation that triggers it. This involves two parts: a REST command that knows how to call our n8n webhook, and an automation that fires when the presence sensor detects someone.; tools: n8n. Human role: The original post does not say how a person stayed involved.; limitations: Prerequisites include a Home Assistant instance with at least 4GB RAM and a presence sensor. Integration requires a long-lived access token and correct IP configuration for webhooks. Source reliability is secondary (blog post); it does not confirm real-world stability or latency. Proposed advice: Use static IPs for both systems to prevent webhook connection failures..

Tools

n8n

Published on Agent Work Atlas:

Overview

Tired of manually adjusting your smart lights throughout the day?

Workflow

Tired of manually adjusting your smart lights throughout the day? This n8n and Home Assistant integration creates the perfect ambient lighting automatically. When presence is detected, an AI determines the ideal brightness based on time of day - no more harsh lighting at night or dim lighting in the morning. Why Automate Lighting with AI? Manual light adjustment is one of those small daily frustrations that add up over time. You walk into a room at night and the lights blast at full brightness, or try to read in the afternoon with insufficient lighting. Traditional automations based on simple time schedules can't account for seasonal changes or personal preferences. By combining n8n's workflow automation with Home Assistant's device control and AI decision-making, we create a system that understands context. The AI considers not just the time of day, but can eventually incorporate factors like weather conditions, your calendar schedule, and even personal preferences learned over time. Studies show that properly tuned lighting can improve productivity by up to 20% during daytime hours while promoting better sleep when dimmed appropriately at night. This automation brings those benefits automatically. Setting Up n8n in Home Assistant While Home Assistant excels at device control, n8n brings powerful workflow automation capabilities. The first step is installing n8n as a Home Assistant add-on, which requires adding the n8n repository since it's not included in the default store. After adding the repository URL (available in the video description), you can install n8n like any other add-on. Before starting it, be sure to set your timezone in the configuration tab - this ensures time-based automations work correctly. The installation pulls down a Docker image and sets up all required components automatically. Pro Tip: Allocate sufficient memory to your Home Assistant instance before installing n8n. The combined system works best with at least 4GB RAM available. Configuring the Webhook Trigger The most challenging part of this integration is establishing communication between Home Assistant and n8n. Since n8n can't directly subscribe to Home Assistant sensor changes, we use webhooks as the bridge between the systems. In n8n, create a new webhook node and configure it to listen for POST requests. You'll need a long-lived access token from Home Assistant (created in your user profile's security section) to authenticate the connection. The webhook URL generated by n8n will be used in the Home Assistant automation later. At 3:45 in the video, you'll see the critical troubleshooting step - replacing the default hostname with your Home Assistant's actual IP address to ensure reliable connectivity between the systems on your local network. Adding AI Decision Making The magic happens in the AI agent node where we define rules for lighting based on time of day. The prompt instructs the AI to act as a lighting designer, analyzing the current time and determining appropriate brightness levels. For this implementation, we're using Deepseek's API (which recently reduced prices by 50%), but you could substitute OpenAI, Anthropic, or other providers. The AI node outputs a brightness percentage that flows into the next step of the workflow. Example AI Prompt: "Act as a professional lighting designer. Given the current time is {time}, recommend an appropriate brightness percentage (0-100) for ambient room lighting. Consider human circadian rhythms and typical daily activities at this hour." Controlling the Lights The final node in the n8n workflow uses Home Assistant's service call capability to actually adjust the lights. You'll need your light's entity ID from Home Assistant and will configure the service to "turn_on" with the brightness attribute set to the value determined by the AI. This separation of decision-making (in n8n) from device control (in Home Assistant) is powerful. It means you can change the AI logic or add new decision factors without modifying how the lights are controlled. The systems work together while maintaining their separate strengths. Creating the Home Assistant Automation With the n8n workflow ready, we need to create the Home Assistant automation that triggers it. This involves two parts: a REST command that knows how to call our n8n webhook, and an automation that fires when the presence sensor detects someone.

Reported result

Actual outcomes are not reported in the source; no specific success metrics or failure rates are provided. The text cites general studies claiming up to 20% productivity improvement from tuned lighting, but this is not attributed to this specific implementation. Proposed acceptance check: Verify that lights adjust to the AI-determined brightness within 5 seconds of presence detection across three different times of day.

Human role

The original post does not say how a person stayed involved.

Limitations

Prerequisites include a Home Assistant instance with at least 4GB RAM and a presence sensor. Integration requires a long-lived access token and correct IP configuration for webhooks. Source reliability is secondary (blog post); it does not confirm real-world stability or latency. Proposed advice: Use static IPs for both systems to prevent webhook connection failures.

Try it

I want to set up an AI-driven lighting automation using n8n and Home Assistant. My Home Assistant IP is [replaceable HA_IP], and my light entity ID is [replaceable LIGHT_ENTITY_ID]. I have a presence sensor named [replaceable SENSOR_NAME]. First, guide me through installing the n8n add-on and setting the timezone. Next, help me create an n8n workflow with a Webhook trigger, an AI Agent node using [replaceable AI_PROVIDER] to calculate brightness based on time, and a Home Assistant node to set the light. Before activating the automation, run a dry test: simulate a presence event at [replaceable TEST_TIME] and show me the AI's calculated brightness value. Do not enable the final automation until I confirm the test output is correct. If the webhook fails, check if I used the IP address instead of the hostname.

Original source

Source reports are not independently verified. Publication date is the catalog publication date, not the original article date.

More cases · Everyday life