SwitchBot Air Conditioner MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
SwitchBot Air Conditioner MCP Server
Control your air conditioner through SwitchBot Hub 2 using the Model Context Protocol (MCP). Enables natural language control of AC units in AI assistants like Claude Desktop and Cursor.
Features
🔌 Power Control: Turn AC on/off
🌡️ Temperature Control: Set temperature (16-30°C)
🔄 Mode Selection: Auto, Cool, Dry, Fan, Heat
💨 Fan Speed Control: Auto, Low, Medium, High
🎮 Custom Commands: Access advanced features (swing, turbo, sleep, etc.)
📊 Room Monitoring: Get current temperature and humidity from Hub 2
🔍 Device Discovery: List all infrared devices
Related MCP server: Nature Remo MCP Server
Night Automation
This project includes an automated night-time AC control system that runs via GitHub Actions. It uses AI to make smart decisions based on:
Current room temperature & humidity
Outside weather conditions
Sleep science research
Your personal preferences
Sleep Science Research
The automation is based on peer-reviewed sleep research:
Temperature Range | With Blanket | Without Cover |
16-18°C (60-65°F) | Optimal | Too cold |
18-20°C (65-68°F) | Excellent | Cool |
20-24°C (68-75°F) | Warm (light sheet) | Comfortable |
>24°C (>75°F) | Too hot | Too hot |
Key Findings:
The Sleep Foundation recommends 18.3°C (65°F) as the ideal sleep temperature
Cleveland Clinic suggests 15-19°C (60-67°F) for optimal sleep
Research shows sleeping with a blanket in a cool room (16-18°C) creates the best "microclimate" for deep sleep
A room that is too hot causes more sleep disturbance than one that is too cold
Sources:
Sleep Foundation: Best Temperature for Sleep
Healthline: Best Temperature to Sleep
Cleveland Clinic: Ideal Sleeping Temperature
Medical News Today: Best AC Temperature for Sleeping
How It Works
Cron runs hourly (22:00-07:00 Israel time)
Gathers data: room temp, humidity, outside weather
AI decides: based on sleep science + your preferences
Executes action: via MCP server on FastMCP Cloud
Logs to Supabase: for history and learning
See cron/config.yaml to customize your preferences.
Quick Start
Prerequisites
SwitchBot Hub 2 with your AC remote configured
SwitchBot API Credentials (Token and Secret)
Python 3.8+
Installation
Clone the repository:
git clone https://github.com/yourusername/AirConditionMcp.git cd AirConditionMcpInstall dependencies:
pip install -r requirements.txtConfigure environment variables:
cp env.example .envEdit
.envand add your credentials:SWITCHBOT_TOKEN=your_token_here SWITCHBOT_SECRET=your_secret_here SWITCHBOT_AC_DEVICE_ID=your_device_id_hereTest the connection:
python test_connection.py
MCP Configuration
Add to your MCP settings file:
Cursor (%APPDATA%\.cursor\mcp.json on Windows):
{
"mcpServers": {
"switchbot-ac": {
"command": "python",
"args": ["path/to/AirConditionMcp/server.py"],
"env": {
"SWITCHBOT_TOKEN": "your_token_here",
"SWITCHBOT_SECRET": "your_secret_here",
"SWITCHBOT_AC_DEVICE_ID": "your_device_id_here"
}
}
}
}Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json on Mac):
{
"mcpServers": {
"switchbot-ac": {
"command": "python",
"args": ["/path/to/AirConditionMcp/server.py"],
"env": {
"SWITCHBOT_TOKEN": "your_token_here",
"SWITCHBOT_SECRET": "your_secret_here",
"SWITCHBOT_AC_DEVICE_ID": "your_device_id_here"
}
}
}
}Restart your AI assistant after configuration.
Usage
Once configured, use natural language to control your AC:
"Turn on the AC at 24 degrees"
"Set AC to 22 degrees in cool mode"
"What's the room temperature?"
"Turn off the air conditioner"
"Toggle AC swing mode"
"Activate turbo cooling"Available Tools
Basic Controls
turn_ac_on(temperature, mode, fan_speed)- Turn on AC with settingsturn_ac_off()- Turn off ACset_ac_temperature(temperature)- Change temperatureset_ac_mode(mode)- Change operating modeset_ac_fan_speed(fan_speed)- Change fan speedset_ac_all_settings(power, temperature, mode, fan_speed)- Set everything at once
Advanced Features
send_custom_ac_command(command, parameter)- Send custom commands (swing, turbo, sleep, etc.)list_common_ac_commands()- List all available custom commandsget_room_temperature()- Get current room temperature and humidityget_ac_devices()- List all infrared devicesget_ac_status()- Get current AC status (if supported)
Getting SwitchBot Credentials
Open the SwitchBot app on your phone
Go to Profile → Preferences
Tap "App Version" 10 times rapidly
Go back and select Developer Options
Copy your Token and Secret
See SETUP_GUIDE.md for detailed instructions.
Finding Your AC Device ID
Run the test script:
python test_connection.pyOr use the MCP tool after setup:
"List my SwitchBot devices"Custom Commands
Access advanced AC features beyond basic controls:
"Toggle AC swing mode" # Oscillate air direction
"Activate turbo mode" # Maximum cooling power
"Enable sleep mode" # Quiet night operation
"Toggle display light" # Turn off AC displaySee CUSTOM_COMMANDS.md for full list.
Deployment
Option 1: Self-Hosted
Run the server directly:
python server.pyOption 2: Docker (Coming Soon)
docker build -t switchbot-ac-mcp .
docker run -e SWITCHBOT_TOKEN=xxx -e SWITCHBOT_SECRET=xxx -e SWITCHBOT_AC_DEVICE_ID=xxx switchbot-ac-mcpOption 3: Cloud Hosting
Deploy to your preferred cloud platform. Set environment variables in your hosting service:
SWITCHBOT_TOKENSWITCHBOT_SECRETSWITCHBOT_AC_DEVICE_ID
Troubleshooting
"No infrared devices found"
Add your AC remote to SwitchBot Hub 2 via the app first
"401 Unauthorized"
Check that your token and secret are correct
No extra spaces at beginning or end
"AC doesn't respond"
Verify device ID is correct
Ensure Hub 2 has clear line of sight to AC (5-10 meters)
Test in SwitchBot app first
"Status shows wrong information"
Status reflects last command sent, not actual AC state
Enable IR Decoding in SwitchBot app (if supported)
See TROUBLESHOOTING.md for more help.
API Rate Limits
10,000 requests per day per token
About 7 requests per minute
Consider caching status if making frequent queries
Security
⚠️ Important:
Never commit your
.envfile to version controlStore credentials securely
Use environment variables in production
Rotate credentials periodically
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Fork the repository
Create your feature branch (
git checkout -b feature/AmazingFeature)Commit your changes (
git commit -m 'Add some AmazingFeature')Push to the branch (
git push origin feature/AmazingFeature)Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
SwitchBot for the API
FastMCP for the MCP framework
Model Context Protocol by Anthropic
Support
Issues: GitHub Issues
SwitchBot Support: https://support.switch-bot.com/
SwitchBot API Docs: https://github.com/OpenWonderLabs/SwitchBotAPI
Made with ❄️ for smart home automation
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Control your Tesla from your AI assistant - climate, charging, access, and security.
Control and query Heiman smart home devices: lights, AC, curtains, climate, logs and scenes.
Home energy for AI assistants: live Power flow, Energy history, solar forecast, and device control.
Japanese catalog of physical devices AI agents can control: connectivity ratings, APIs, sources.
Related MCP Servers
- AlicenseCqualityFmaintenanceEnables AI assistants to control SwitchBot devices, providing functionalities like device management, scene execution, and sensor information monitoring through the SwitchBot API.37ISC
- AlicenseCqualityDmaintenanceEnables you to manage and automate interactions with Nature Remo devices, including listing devices and appliances, and operating TVs and air conditioners through natural language commands.46 npm8MIT
- AlicenseNot gradedqualityDmaintenanceEnables control of TV and air conditioner through natural language commands via Cursor or Claude Desktop.MIT
- AlicenseAqualityDmaintenanceEnables control of SwitchBot devices by name, reducing the risk of AI misidentifying device IDs.512 npm1MIT