How to Build an OpenClaw Smart Thermostat Agent on Raspberry Pi
Heating and cooling consume 52% of residential energy in the US, but most smart thermostats follow rigid schedules that ignore occupancy and weather. An OpenClaw agent on a Raspberry Pi controls thermostats through Home Assistant with code-level safety bounds, making energy-aware decisions based on who is actually home. This walkthrough covers the hardware, ha-mcp skill setup, and occupancy patterns that reduce HVAC waste.
Why HVAC Is the Highest-Value Smart Home Automation
Space heating and air conditioning make up 52% of energy consumption in the average US household, according to the EIA's 2020 Residential Energy Consumption Survey. That translates to roughly $1,000 to $1,250 per year in HVAC costs alone for most homes. No other category of home automation touches this much spending.
Most programmable and smart thermostats attack this cost with schedules: heat to 70°F at 7 AM, drop to 62°F at 10 PM, reduce to 58°F while the house is empty. Schedules work when your life is predictable. They fall apart the moment it isn't. You work from home on Tuesday. Guests arrive a day early. A cold front moves through at 3 PM instead of overnight. The thermostat doesn't know any of this, so it heats an empty house all morning or lets the temperature drop before the overnight setback was supposed to begin.
An AI agent operating your thermostat changes the control model. Instead of following a fixed timetable, an OpenClaw agent connected to Home Assistant can observe occupancy sensor data, check external conditions, review recent patterns, and adjust the thermostat in response. The OpenClaw blog demonstrates this directly: an agent can process commands like "set the temperature to 68°F" and also flag inefficiency by identifying situations like "HVAC running 18 hours/day, thermostat set to 75°F when nobody home."
The difference between a schedule and an agent is reasoning. A schedule says "at 8 AM, heat to 70." An agent says "nobody has been home since 6 AM, the forecast high is 65°F, so hold at 62 until someone arrives." That distinction compounds over a heating season. You are not just shaving a degree or two. You are eliminating entire periods of unnecessary runtime.
This guide covers building that agent on a Raspberry Pi with OpenClaw and Home Assistant. You will connect the agent to your thermostat entities, configure safety-bounded temperature limits, and build occupancy-aware control logic that adapts to how your household actually operates.
How OpenClaw Controls Thermostats Through Home Assistant
OpenClaw connects to Home Assistant through the ha-mcp skill, which translates natural language into Home Assistant service calls using the Model Context Protocol. When you tell the agent "set the bedroom to 21 degrees," the ha-mcp skill resolves that to the correct climate entity in Home Assistant and issues the appropriate API call. The agent does not interact with thermostats directly. Home Assistant handles all device communication, whether your thermostat uses Zigbee, Z-Wave, Wi-Fi, or MQTT.
This architecture separates the reasoning layer from the device layer. The Raspberry Pi runs Home Assistant for device control and the OpenClaw gateway for agent orchestration. A cloud LLM (Claude, GPT-4, Gemini, or another supported provider) handles the natural language processing. Your device data stays on your local network. The only traffic leaving your home is the LLM API call.
For HVAC specifically, the integration includes hardcoded safety bounds. The control script enforces a temperature range of 15°C to 28°C (59°F to 82°F). These limits are implemented at the code level in Python, not in prompt instructions. That matters because prompt-based constraints can be lost during context compaction or overridden by creative phrasing. Code-level bounds persist through updates, model changes, and agent reconfigurations. The lower bound prevents pipes from freezing in winter. The upper bound prevents dangerous overheating, which is especially important for rooms with limited ventilation or elderly residents.
The ha-mcp skill also supports entity filtering. For a thermostat-focused agent, you expose only climate entities and relevant sensors (temperature, humidity, occupancy) while blocking access to locks, alarms, and other security-critical devices. The OpenClaw documentation recommends limited access for climate control rather than full device access, since even settings within the safety bounds can create discomfort or waste if applied carelessly.
You can also restrict the agent's actions by domain. Allowing climate.set_temperature and climate.set_hvac_mode while blocking lock.unlock and alarm_control_panel.disarm means the agent controls your comfort without touching your security. This defense-in-depth approach, combining temperature bounds with entity filtering and domain restrictions, makes the HVAC agent safe to run unattended.
Hardware and Setup for a Pi-Based Thermostat Agent
The hardware side of this project is straightforward if you already run Home Assistant. If you are starting from scratch, budget about an hour for initial setup and under $100 for parts.
Hardware you need:
- Raspberry Pi 5 with 8GB RAM (recommended). The Pi 4 with 8GB also works, but the Pi 5 offers faster CPU throughput and better NVMe I/O for a device running around the clock
- NVMe SSD via a HAT+ adapter. An SD card works for initial testing, but SSDs are far more reliable for 24/7 operation
- USB-C power supply (27W official Pi 5 supply recommended)
- A thermostat compatible with Home Assistant. Zigbee thermostats work through a coordinator dongle like the SONOFF ZBDongle-P. Z-Wave thermostats work through a Z-Wave USB stick. Wi-Fi thermostats from Ecobee, Honeywell, or Nest connect through their respective Home Assistant integrations
- Occupancy sensors for presence-aware scheduling: motion sensors, door sensors, or phone-based presence detection through the Home Assistant companion app
Connecting OpenClaw to your thermostat:
- Flash Home Assistant OS to your Pi's storage and complete onboarding at
http://homeassistant.local:8123 - Add your thermostat to Home Assistant through the appropriate integration (ZHA for Zigbee, Z-Wave JS for Z-Wave, or the manufacturer's cloud integration for Wi-Fi models)
- Open Developer Tools in Home Assistant and verify the thermostat appears as a climate entity (for example,
climate.living_room) - Create a Long-Lived Access Token: click your profile icon, scroll to Security, click Long-Lived Access Tokens, and create a token named "OpenClaw Agent." Copy it immediately since Home Assistant only shows the token once
- Install OpenClaw on the Pi by running
curl -fsSL https://openclaw.ai/install.sh | bashin a terminal - Configure the ha-mcp skill with your Home Assistant URL and the access token you created
- Test the connection by asking the agent "What is the current temperature in the living room?" and verify it returns the correct reading from your thermostat
If you already run Home Assistant, skip to step 4. The full OpenClaw Home Assistant integration guide covers each step in greater detail, including gateway hardening and network security.
Store your HVAC configs and sensor logs where agents can reach them
Free 50GB workspace with built-in AI search and MCP server access. Upload thermostat schedules, automation configs, and energy data. No credit card required.
Energy-Aware Scheduling with Occupancy Detection
The real value of an AI thermostat agent over a programmable thermostat is its ability to break from the schedule when conditions change. Here are the patterns that matter most for cutting HVAC costs.
Occupancy-based setbacks. Connect presence detection to your agent through Home Assistant. The HA companion app on family members' phones reports home or away status. Motion sensors in common areas add a second signal. When the agent sees that everyone has left and no motion has been detected for 30 minutes, it sets back the thermostat to the lower bound of the comfort range. When someone returns, the agent brings the temperature back up. Unlike a simple geofence trigger, the agent can factor in lead time: if you are 20 minutes from home and the house is at 62°F, it starts heating now so you walk into a warm house rather than waiting 40 minutes after you arrive.
Weather-responsive preheating. On a mild October morning, the house might hold 68°F until noon with no heating at all. On a January morning with a windchill of negative 10°F, the furnace needs a 45-minute head start to hit the target by 7 AM. A static schedule picks one start time for the entire season. An agent that reads weather data adjusts the preheat window day by day, starting earlier on frigid mornings and skipping the furnace entirely on warm ones.
Time-of-use rate awareness. If your utility charges more during peak hours (typically 4 PM to 9 PM), the agent can pre-cool the house in the afternoon before rates spike, then coast through the expensive window without running the compressor. The same logic applies to demand response events, where utilities offer credits for reducing consumption during grid stress.
Room-by-room control. If your Home Assistant instance manages multiple climate zones (common in homes with ductless mini-splits or zone dampers), the agent can prioritize the rooms where people actually are. Heating an empty guest bedroom to 70°F all day is pure waste. An agent with access to per-room occupancy sensors and per-zone thermostats targets comfort where it matters and lets unoccupied rooms float.
Seasonal adaptation. Traditional thermostats require manual schedule changes when seasons shift. An agent adapts continuously. As spring arrives and afternoons warm up, it reduces heating during the day without being told. When summer hits and the mode switches from heating to cooling, the agent applies the same occupancy and weather logic to air conditioning. No reprogramming needed.
None of these patterns require you to write YAML automations in Home Assistant. The agent reasons about the inputs (occupancy, temperature, weather, time, utility rates) and adjusts the thermostat within its hardcoded safety bounds of 15°C to 28°C.
Storing HVAC Configs and Sensor Logs in a Cloud Workspace
Home Assistant stores device states and history locally on the Pi's storage. That covers day-to-day operation, but creates limitations when you need to search historical data, share configurations across properties, or hand off a working setup to someone else.
You could sync configs to Google Drive or Dropbox, but neither platform indexes the content for semantic search or exposes an API that an agent can read and write through natively. An S3 bucket handles storage but offers no built-in way to ask questions about what you stored.
A Fast.io workspace fills that gap. Upload your ha-mcp skill configuration, thermostat schedules, sensor export CSVs, and automation scripts to a shared workspace. The agent reads config files through the Fast.io MCP server and writes back updated schedules or logs as needed. Humans view the same files through the web interface, with no special client or sync tool required.
Intelligence Mode is useful here. Once enabled on a workspace, it auto-indexes every uploaded file for semantic search. Six months from now, you can ask "What was the overnight setback temperature last December?" and get a cited answer pulled from your stored config history. No tagging or folder structure needed, just upload the file and it becomes searchable by meaning.
For multi-property setups, each property gets its own workspace with granular permissions. A property manager sees all workspaces. Individual tenants see only their own HVAC data. If the agent adjusts a schedule, that action appears in the workspace audit log with a timestamp. Fast.io's ownership transfer fits the handoff pattern common in HVAC projects: an installer configures the agent and workspace, then transfers ownership to the homeowner while retaining admin access for ongoing support.
The free tier handles most residential setups: 50GB of storage, 5,000 credits per month, five workspaces, and no credit card required. Point your agent at fast.io/llms.txt to get started, or visit the pricing page to compare plans.
Frequently Asked Questions
Can a Raspberry Pi control a thermostat?
A Raspberry Pi running Home Assistant can control smart thermostats from Ecobee, Honeywell, Sinopé, and dozens of other manufacturers through Zigbee, Z-Wave, Wi-Fi, or MQTT. Adding OpenClaw gives the Pi natural language control, so you can adjust temperatures by typing or speaking commands instead of navigating the Home Assistant dashboard.
How do I set up OpenClaw with Home Assistant?
Install Home Assistant OS on your Raspberry Pi, create a Long-Lived Access Token in your HA profile under Security, then install OpenClaw using the official installer. Configure the ha-mcp skill with your Home Assistant URL and the access token. The skill gives the agent structured access to all exposed entities, including thermostats and climate sensors.
What is the cheapest smart thermostat option?
A Raspberry Pi with a Zigbee thermostat and a ZBDongle-P coordinator costs under $100 total and gives you both manual and AI-based control through Home Assistant and OpenClaw. If you already own a Pi running Home Assistant, the only additional cost is the thermostat itself, which starts around $30 for basic Zigbee models.
Does OpenClaw work with any thermostat brand?
OpenClaw controls thermostats through Home Assistant, not directly. Any thermostat that Home Assistant supports is accessible to the agent, including Zigbee devices, Z-Wave devices, Wi-Fi thermostats from Ecobee and Honeywell, and MQTT-connected hardware. Check the Home Assistant integrations page for compatibility with your specific model.
How much energy can an AI thermostat agent save?
The Department of Energy estimates that setting back your thermostat by 7°F to 10°F for 8 hours a day can reduce heating and cooling costs by up to 10% per year. An AI agent applies those setbacks more precisely than a static schedule by reacting to actual occupancy instead of assumed patterns. Homes that frequently deviate from their thermostat schedule, such as remote workers or families with irregular hours, see the largest benefit.
Is it safe to let an AI agent control my HVAC system?
OpenClaw's Home Assistant integration enforces temperature safety bounds of 15°C to 28°C (59°F to 82°F) at the code level, not in the prompt. These limits prevent pipe-freezing lows and dangerous overheating regardless of what the agent is asked to do. You can further restrict the agent's access to only climate entities, blocking it from touching locks, alarms, or other security devices.
Related Resources
Store your HVAC configs and sensor logs where agents can reach them
Free 50GB workspace with built-in AI search and MCP server access. Upload thermostat schedules, automation configs, and energy data. No credit card required.