Skip to content
Robert J WallaceOld magician who likes old cars, and old whisky

From the personal collection

My Smart Home Got Its Buttons Back: Using ChatGPT to Fix and Build Home Assistant Automations

In my previous post, I used Claude Code to clean up my Home Assistant configuration and refresh a dashboard. This time, I used ChatGPT in Codex to solve a more immediate problem. I’d reinstalled a couple of Aqara switches, and the buttons that used to turn off the lights no longer did anything.

I could have rebuilt the automations one at a time in Home Assistant. The trouble was remembering what I’d set up in the first place. One of those buttons had a double-tap action buried in an automation named for an entirely different switch.

Same SSHFS connection, different job

Home Assistant runs on a dedicated mini PC. On my workstation, I use sshfs to mount its configuration directory so I can work with it like a local folder. I opened that folder in Codex and asked ChatGPT to take a look.

A reminder from the previous post is worth repeating. Make a Home Assistant backup before editing through SSHFS. The files in that folder are the files on the Home Assistant machine. When ChatGPT saves an edit to automations.yaml, it’s saving it directly to the system that runs the house.

My first prompt was essentially, “I’m trying to add two Aqara two-button switches, one in the bedroom and one in the entry. Look at my setup and see what’s going on.”

Finding the automations I already had

Both switches had already paired through ZHA, Home Assistant’s Zigbee integration. The old automations were still pointing at the switches’ former HomeKit device IDs. ChatGPT matched those IDs against an older copy of the device registry and found six automations with seven triggers to update.

That’s how we found the hidden double tap. The automation was called Entry 2 gang button 1 single press, which sounds specific enough. But it had a second trigger. Double-tapping button 1 in the bedroom also ran the downstairs shutdown. That let me turn off the downstairs lights and stop the music without going back downstairs.

ChatGPT changed the triggers to look for the new switches’ ZHA events and kept the existing actions. I reloaded automations in Home Assistant and tested the physical buttons.

The double tap still left the entry light on. ChatGPT checked the Zigbee database and found that Home Assistant had received the double press. The entry light was already included in the downstairs shutdown. Digging a little further turned up an action that referenced a track-light switch I’d removed from Home Assistant. ChatGPT removed the stale reference, I reloaded again, and this time the entry light went off.

That back-and-forth was the useful part. I could report something as simple as “I double-tapped it and the entry light stayed on,” and ChatGPT could follow the chain from the button event to the automation to the devices it controlled.

Giving an old button a new job

I also reinstalled the Aqara mini switch beside the bed. I remembered using it to turn things off at night, and I vaguely remembered a rule about 9 p.m.

It turned out I was remembering two automations. Holding the mini switch ran a bedtime routine that shut off lights, started music on the bedroom Echo, and announced the garage door status. The 9 p.m. condition belonged to a separate automation triggered when the master bathroom light turned off while my phone was in the bedroom zone.

ChatGPT reconnected the bedtime routine to the new mini switch. When I tested it with a quick tap, Home Assistant showed an event, but the track lights stayed on. The event was single. The bedtime routine was waiting for hold. Once I held the button down, it worked.

That left the quick tap available, so I asked ChatGPT to make it toggle the bedroom track lights. It added the mini switch as another trigger for the existing track-light automation. Now I can tap the mini switch to turn the lights on or off, or hold it to shut things down for the night.

Creating an automation from scratch

The same approach works when there’s no old automation to repair. I can describe what I want in plain English and ask ChatGPT to look up the devices and events in my own Home Assistant configuration.

For example, the Entry switch’s second button currently has no action assigned to a long press. I could ask:

Create a new automation that turns on just the stairway light when I hold button 2 on the Entry gang switch after 9 p.m. Use the existing stairway switch entity. Show me the trigger, condition, and action before editing.

ChatGPT can look up the stairway entity, use the Entry remote’s Zigbee address, and write a separate automation with the button hold as the trigger, the time as the condition, and the stairway light as the target. If there’s any doubt about what the button sends, I can listen for zha_event in Home Assistant’s Tools → Events panel, hold the button, and share the event that comes back.

I’d use the same workflow for a new automation as I did for the repairs. Review the change, validate the YAML, reload automations, and try it at the switch. If the light stays on or goes off at the wrong time, Home Assistant’s Traces can show whether the automation ran and which step it reached.

The part I appreciate most is being able to start with how I want the house to behave. “Tap this for the track lights, hold it for bedtime” is easy to say. Finding the right device, matching the event, and fitting it into years of existing automations is where having ChatGPT work alongside me saves time.

Leave a Reply

Your email address will not be published. Required fields are marked *