↓Skip to main content

Agents Helping in My Home Automation Network

·820 words·4 mins·
Dark-mode technical illustration of an AI agent bridging wireless smart light switches and glowing lightbulbs on the left with a home automation hub and a circular wireless access point on the right, linked by a glowing padlock badge representing locked DHCP reservations.

My home automation environment had been having challenges at home for some time - where some of my lights were not responding in a reasonable amount of time. Specifically, my Kasa smart switches on the wireless network would take time to respond. I just hadn’t made it a priority enough for me to work on and dive into. Nor did I have the proper logging set up for me to visualize and see the events myself. So one day I brought it up with GrokBot, which I have connected to both my UniFi environment and Home Assistant. I originally chalked this up to the internet and service being slow. I was wrong.

GrokBot took a simple prompt, diagnosed what was going on and solved the issue - an IP address change for the lights. From there GrokBot suggested a change for me and applied the change - creating DHCP reservations for each of the light switches. That itself requires some sort of automation to apply, as I do have many of these devices.

The Issue #

When a light switch lags behind a tap or an automation, everyone in the house notices right away. My Kasa switches were still functioning, just not responding quickly. Because they run over Wi-Fi and integrate into Home Assistant, the slowdown could have been wireless interference, something inside Home Assistant, or a network issue underneath. Never would I have thought it to have been the Kasa device getting new IP addresses. But it was.

The GrokBot Prompt #

prompt · GrokBot

There are a lot of lights not showing up in HA via Kasa. Such as the Master Light. Can you dig into it

# tested

What I am really liking about AI agents these days is how productive that they are without having a huge prompt. This short of a prompt and just some later follow up and the agent was off and being helpful. I’m seeing this out of several of the agent systems including Claude’s Duet and Dots from ChatGPT.

Troubleshooting Across Home Assistant and UniFi #

Having an agent be connected to both systems is what made this incredibly helpful - and to the point that I write about it. I explained what was happening with the wireless Kasa switches, and GrokBot went to work researching what was going on inside Home Assistant while also checking the UniFi network side.

Looking across both systems showed what was actually happening. The switches were getting new DHCP addresses. On a home network, devices like smart switches usually renew the same lease over and over, so an IP change is something that rarely happens until it suddenly does. Once those addresses shifted, Home Assistant was left trying to talk to stale IPs, which led to the slow responses and missing lights.

Diagram showing GrokBot correlating Home Assistant and UniFi Wi-Fi: Home Assistant polls a stale IP address for the Kasa Master Light switch while UniFi shows the switch online on Wi-Fi with a new DHCP lease, resolved by applying DHCP reservations.

How DHCP renewals work

Under Dynamic Host Configuration Protocol (DHCP), defined in RFC 2131, a device does not own its IP address permanently. It gets a temporary lease (commonly 24 hours on a home network). Halfway through the lease (the T1 renewal timer, at 50%), the device sends a unicast DHCPREQUEST to the DHCP server asking to keep the same IP. Normally the server replies with a DHCPACK, resets the timer, and the address never changes.

If that renewal does not go through, the device waits until 87.5% of the lease has passed (the T2 rebinding timer) and broadcasts a DHCPREQUEST to any DHCP server on the network. If the lease still expires or the device reconnects after a drop or reboot and cannot reclaim its old address, it falls back to a fresh DHCPDISCOVER. Without a DHCP reservation tying the device’s Media Access Control (MAC) address to a specific IP, the server is free to hand it a different address from the pool.

Timeline of a 24-hour DHCP lease. The lease is granted at 0 hours. At 12 hours (T1, 50%) the device sends a unicast DHCPREQUEST, and in the normal case the server’s DHCPACK keeps the same IP and restarts the timer. At 21 hours (T2, 87.5%) a device that got no reply broadcasts a DHCPREQUEST to any server. If the lease expires, or the device drops off Wi-Fi or reboots, it starts over with DHCPDISCOVER. With a DHCP reservation it gets the same address back; without one it may get a different address from the pool, while Home Assistant still has the old one.
The RFC 2131 renewal timers on a 24-hour lease. Only a device that falls back to DHCPDISCOVER risks a new address.

The Fix and Monitoring #

Once GrokBot figured out that the IP addresses were changing, it recommended adding DHCP reservations so the switches would keep the same IP. I had 20 Kasa devices that needed reservations, which is not something I wanted to go click through by hand in UniFi. GrokBot went ahead and set up all 20 reservations for me in UniFi, then kept an eye on the environment afterward to make sure the switches held their addresses and the lights started responding normally again.

Summary #

Most of the time, home network issues sit on the back burner because digging through multiple tools to line everything up takes time I do not want to spend. Having GrokBot connected to both Home Assistant and UniFi made it easy to finally deal with this one. It found an IP change I would not have suspected, set up DHCP reservations for all 20 Kasa devices, and followed up to verify things stayed working.

-Josh

Josh VanDeraa
Author
Josh VanDeraa
Network automation leader who got his start as a network engineer. Author of Open Source Network Management, and co-author of Modern Network Observability and Network Automation with Nautobot.

Get the next post by email

Hands-on network automation, observability, and AI write-ups when they're ready. No spam.

No spam. Unsubscribe any time.