Skip to content

Instantly share code, notes, and snippets.

@jmcdice
Created January 1, 2026 19:40
Show Gist options
  • Select an option

  • Save jmcdice/8a6d1107c7b24b4838785bebc4178101 to your computer and use it in GitHub Desktop.

Select an option

Save jmcdice/8a6d1107c7b24b4838785bebc4178101 to your computer and use it in GitHub Desktop.
Home Automation Control with Claude via Mai-Tai - Complete Setup Guide

Home Automation Control with Claude via Mai-Tai

A complete setup guide for controlling your home automation devices through Claude in mai-tai mode using Home Assistant.

๐Ÿ  System Overview

This setup allows you to control your home devices by simply messaging Claude. No manual commands needed - just natural language requests like "turn on the living room lights" and Claude handles the rest.

Architecture

  • Home Assistant: Running in Docker, handles device discovery and control
  • WeMo Integration: Auto-discovers WeMo switches on your local network
  • Chromecast Integration: Auto-discovers Google Home speakers and Chromecasts
  • Python Control Script: API client for programmatic control
  • Claude Mai-Tai Mode: Async communication layer for remote control

๐Ÿ“ฆ What's Included

Hardware Devices Supported

  • โœ… 9 WeMo Smart Switches
  • โœ… 6 Google Home/Chromecast devices
  • โœ… MyQ Garage Door (via MyQ app - third-party blocked)

Controlable WeMo Switches

  1. Office Lamp
  2. Universe lights
  3. Living Room Light Two
  4. Pine Tree
  5. Tall Livingroom Light
  6. mini light
  7. Basement Lamp
  8. Living Room Light
  9. Front Room Lights

Media Players (Chromecast/Google Home)

  1. Basement TV
  2. Ava speaker
  3. Living room speaker
  4. Kitchen speaker
  5. living room speakers (group)
  6. Living room TV

๐Ÿš€ Initial Setup

Prerequisites

  • Docker & docker-compose installed
  • Python 3 with requests library
  • WeMo devices on the same network
  • Access to Home Assistant web interface

Installation Steps

  1. Clone or create the project directory:
mkdir ~/home_auto
cd ~/home_auto
  1. Create docker-compose.yml:
version: '3.8'

services:
  homeassistant:
    container_name: homeassistant
    image: homeassistant/home-assistant:latest
    restart: unless-stopped
    network_mode: host
    environment:
      - TZ=America/New_York
    volumes:
      - ./config:/config
    privileged: true
  1. Start Home Assistant:
docker-compose up -d
  1. Access Home Assistant:
  • Open http://192.168.86.39:8123 (or your server IP)
  • Complete the onboarding wizard
  • Create an account
  • Devices should auto-discover
  1. Generate API Token:
  • Click your profile (bottom left)
  • Scroll to "Long-Lived Access Tokens"
  • Create token named "Claude Control"
  • Save to .env file:
echo 'HA_TOKEN=your_token_here' > .env
  1. Install Python dependencies:
pip install requests

๐ŸŽฎ Usage with Claude Mai-Tai

Starting Mai-Tai Mode

You: start mai-tai mode
Claude: Mai-tai mode activated! What would you like me to work on while you're away?
You: I'd like you to control my home automation

Natural Language Commands

Lights:

  • "Turn on the living room lights"
  • "Turn off all switches"
  • "Turn on the office lamp"
  • "Toggle the pine tree"

Information:

  • "What devices do I have?"
  • "Show me what's currently on"
  • "List all my devices"

Media Players (future capabilities):

  • "Play music on the kitchen speaker"
  • "Pause the living room TV"
  • "Set volume to 50% on Ava speaker"

How It Works

  1. You send a message to Claude via mai-tai
  2. Claude interprets your request
  3. Claude executes the control.py script with the appropriate command
  4. Home Assistant API executes the command
  5. Your device responds
  6. Claude confirms the action

๐Ÿ› ๏ธ Technical Details

Files Structure

home_auto/
โ”œโ”€โ”€ docker-compose.yml          # Home Assistant Docker config
โ”œโ”€โ”€ control.py                  # Python API control script
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ .env                       # API token (gitignored)
โ”œโ”€โ”€ .env.example              # Token template
โ”œโ”€โ”€ README.md                 # Setup documentation
โ””โ”€โ”€ config/                   # Home Assistant data (auto-created)

Control Script Usage

The control.py script can be used manually or by Claude:

# List all devices
python3 control.py list

# Turn on a device
python3 control.py on "living room"
python3 control.py on switch.office_lamp

# Turn off a device
python3 control.py off "basement lamp"

# Toggle a device
python3 control.py toggle "pine tree"

API Endpoints Used

The control script uses Home Assistant's REST API:

  • GET /api/states - List all entities
  • POST /api/services/homeassistant/turn_on - Turn on device
  • POST /api/services/homeassistant/turn_off - Turn off device
  • POST /api/services/homeassistant/toggle - Toggle device

Environment Variables

HA_TOKEN=your_long_lived_access_token_here

๐Ÿ”ง Troubleshooting

Devices Not Discovered

  1. Ensure devices are on the same network
  2. Check network connectivity: ping <device_ip>
  3. Restart Home Assistant: docker-compose restart
  4. Manually add integration in Settings โ†’ Devices & Services

API Connection Issues

# Verify token is set
echo $HA_TOKEN

# Check Home Assistant is running
docker-compose ps

# Test API manually
curl -H "Authorization: Bearer $HA_TOKEN" \
  http://localhost:8123/api/states

Container Not Accessible

# Check logs
docker logs homeassistant --tail=50

# Verify port is listening
netstat -tuln | grep 8123

# Restart container
docker-compose restart

๐ŸŒŸ Future Enhancements

Potential Additions

  • Automation Rules: Time-based or condition-based automations
  • Scenes: Pre-configured device states (e.g., "Movie Mode", "Goodnight")
  • Zigbee/Z-Wave: Add USB dongle for more device types
  • Local Garage Control: ratgdo device for MyQ integration
  • Voice Control: Integration with Google Assistant/Alexa
  • Mobile Dashboard: Home Assistant mobile app access
  • Energy Monitoring: Track power usage of WeMo switches
  • Notifications: Push notifications for device state changes

Media Player Controls (To Implement)

Currently discovered but not yet fully integrated:

  • Play/Pause/Stop controls
  • Volume control
  • Media source selection
  • Speaker grouping
  • TTS announcements via Google Translate

๐Ÿ“ Notes

Network Configuration

  • Uses network_mode: host for UPnP/SSDP discovery
  • WeMo devices require same subnet for auto-discovery
  • Home Assistant accessible at http://SERVER_IP:8123

Security

  • API token is like a password - keep it secret
  • Token stored in .env (add to .gitignore)
  • Home Assistant runs on local network only
  • No cloud connection required

MyQ Limitation

Chamberlain (MyQ owner) blocked third-party integrations in late 2023. Options:

  1. Continue using MyQ iOS app
  2. Purchase ratgdo device (~$30) for local control
  3. Wait for community workarounds

๐Ÿ”— Resources

๐Ÿ“Š System Stats

Device Summary:

  • WeMo Switches: 9
  • Media Players: 6
  • Total Controllable Devices: 15
  • Platform: Docker on Linux
  • Network: 192.168.86.0/24
  • Access URL: http://192.168.86.39:8123

Created: January 1, 2026 Author: Claude (Anthropic) via Mai-Tai mode User: jmcdice (Joey) Status: โœ… Operational

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment