How to Build an EV Charger Monitoring Agent with OpenClaw on Raspberry Pi
Most Raspberry Pi EV charger projects stop at the protocol layer: read OCPP data, display it on a dashboard, done. This guide adds an AI reasoning layer. An OpenClaw agent running on the same Pi connects to your charger through Home Assistant's OCPP integration, monitors sessions in real time, and makes cost-optimized scheduling decisions based on electricity rates and solar generation.
Why EV Charging Needs an Intelligence Layer
Home EV charging accounts for roughly 80% of all EV charging sessions, according to U.S. Department of Energy data. That makes your home charger the single largest controllable electrical load in most households, often drawing 7.2kW or more for hours at a stretch. The difference between plugging in at 6 PM (peak rates) and waiting until 11 PM (off-peak) can be significant: utilities like PG&E and SCE offer super off-peak rates as low as $0.07-0.12 per kWh, compared to peak rates that can exceed $0.50 per kWh in California.
The standard Raspberry Pi EV charger project uses the Open Charge Point Protocol (OCPP) to communicate with the charger, reads session data like energy consumed and charging status, and displays it on a Grafana dashboard or Home Assistant panel. That setup tells you what happened. It does not tell you when to charge, whether tonight's rate schedule favors a 2 AM start over an 11 PM start, or whether your solar panels are producing enough excess to charge for free right now.
An OpenClaw agent running on the same Pi changes the charger from a passive appliance into an active participant in your home energy system. The agent reads charger status through Home Assistant, checks current electricity rates, compares them against your charging needs (how much range you need by morning), and decides when to start and stop sessions. If you have solar panels, it can prioritize daytime charging when generation exceeds household demand. The hardware cost is the Pi you already own. The intelligence layer is what turns raw OCPP data into money saved.
How the Architecture Fits Together
This setup combines three open-source components, each handling a distinct job. Understanding the data flow before you start building saves troubleshooting time later.
Home Assistant runs on the Pi and acts as the device integration hub. The community-maintained OCPP integration (github.com/lbbrhzn/ocpp) turns your HA instance into an OCPP central system. Your charger connects to it over WebSocket and reports status, energy consumption, and session events. The integration supports OCPP 1.6j, 2.0.1, and experimental 2.1 support. It exposes charger data as standard HA entities: sensors for voltage, current, and energy consumed, plus switches for starting and stopping charge sessions and a slider for setting maximum charge current.
OpenClaw runs alongside Home Assistant on the same Pi. It connects to HA through the ha-mcp skill, which gives the agent structured access to every entity in your Home Assistant instance via the Model Context Protocol. The agent reads charger sensor values, calls HA services to start or stop charging, and adjusts charge current. OpenClaw handles the reasoning: when should charging start, at what rate, and under what conditions should it pause or resume.
Your EV charger sits at the bottom of the stack. Any OCPP-compatible charger works. The Home Assistant OCPP integration has confirmed compatibility with chargers from ABB (Terra AC), Wallbox (Pulsar Plus, Commander 2), Grizzl-E, CTEK (Chargestorm Connected 2), EVBox, Alfen, and dozens of others. If your charger speaks OCPP 1.6 or later, it can connect. For DIY builders, the open-source ChargePi project provides a full Raspberry Pi-based charge point framework with OCPP support, relay control, and power metering.
The data flows in one direction for monitoring (charger sends OCPP messages to HA, HA exposes entities, OpenClaw reads them) and reverses for control (OpenClaw decides to act, calls HA services, HA sends OCPP commands to the charger). The Pi handles all orchestration at under 5W of power draw.
Setting Up the OCPP Bridge in Home Assistant
The OCPP integration turns Home Assistant into a central system that your charger reports to. Installation goes through HACS (Home Assistant Community Store), which you should already have if you are running HA on a Pi.
After installing the OCPP integration through HACS, add it via the HA integrations page. The integration starts a WebSocket server on port 9000 by default. You then configure your charger to point its OCPP central system URL to ws://[pi-ip-address]:9000/[charger-id], where charger-id is any identifier you choose. Most chargers expose this setting in their local web interface or companion app.
Once connected, the integration auto-detects your charger's supported measurands and creates entities for each one. A typical setup produces sensors for current power draw (W), cumulative energy (kWh), voltage (V), and current (A), plus binary sensors for charger availability and connector status. You also get a number entity for maximum charge current, which is the primary control lever for smart charging.
What to verify after connection:
- Check the charger's connection status entity in HA. It should show "Connected"
- Confirm energy and power sensors are updating. Plug in your vehicle and watch the values change
- Test the charge current slider. Adjust it and verify the charger responds by changing its actual output
- If your charger supports OCPP 2.0.1, verify that the transaction events (Started, Updated, Ended) are logging correctly in the HA logbook
The OCPP integration also supports automation triggers. You can fire automations when a vehicle plugs in, when charging starts or stops, or when energy consumption crosses a threshold. These triggers become the hooks that OpenClaw uses to make decisions.
Store and query your EV charging session data
Free 50GB workspace for charging logs, rate schedules, and agent configs. Intelligence Mode indexes everything for natural-language queries. No credit card required.
Connecting OpenClaw for Charger Control
With Home Assistant reading your charger's OCPP data, the next step is giving OpenClaw access to those entities. If you have already set up the OpenClaw Home Assistant integration using the ha-mcp skill (covered in our Home Assistant integration guide), you can skip the basic configuration and jump to the charger-specific setup.
The ha-mcp skill gives OpenClaw structured access to Home Assistant entities. Once connected, the agent can read any sensor value and call any service that your HA user has permission to access. For EV charging, the relevant operations are:
- Reading charger power draw, cumulative energy, and session status
- Setting the maximum charge current to throttle or boost charging speed
- Starting and stopping charge sessions through HA service calls
- Reading solar production sensors if you have a PV system integrated with HA
- Querying weather forecast entities that affect solar generation predictions
The power of the agent layer becomes clear when you combine these inputs. A traditional HA automation can say "start charging at 11 PM." An OpenClaw agent can say "the vehicle needs 35 kWh to reach the target state of charge, off-peak rates start at 11 PM and end at 7 AM, the cheapest window within that period is 1 AM to 5 AM based on the tiered rate schedule, and tomorrow's weather forecast shows clear skies so deferring some charge to solar hours saves an additional $1.20." The agent evaluates multiple variables simultaneously and explains its reasoning, which makes it easier to trust and adjust.
For messaging, OpenClaw supports Telegram and Discord notifications out of the box. Configure either one to receive session summaries: when charging started, how much energy was delivered, what it cost, and whether the agent shifted any load to cheaper windows.
Building Cost-Optimized Charging Schedules
The economic case for smart EV charging rests on time-of-use (TOU) rate structures. Most US utilities offer EV-specific rate plans with dramatic price differences between peak and off-peak hours. PG&E's EV2-A plan, for example, charges $0.36/kWh during summer peak hours (4-9 PM) but drops to $0.24/kWh off-peak and $0.12/kWh during super off-peak periods (midnight to 3 PM on weekends). Shifting a daily 10 kWh charge from peak to super off-peak saves roughly $2.40 per day, or about $870 per year.
An OpenClaw agent can implement several charging strategies based on your utility's rate structure and your daily driving patterns.
Basic off-peak scheduling is the simplest strategy. The agent monitors when you plug in, checks the current time against your utility's rate tiers, and defers charging to the cheapest available window. If you plug in at 6 PM and the cheapest rates start at midnight, the agent waits. If you plug in at 1 AM and rates are already at their lowest, charging starts immediately.
Solar-first charging works when your Home Assistant instance also tracks solar production, either through a dedicated solar integration (SolarEdge, Enphase, Fronius) or a CT clamp on your solar inverter's output. The agent compares current solar generation against household consumption. When generation exceeds consumption by more than the charger's minimum draw (usually 1.4kW at 6A on a 240V circuit), the agent starts a low-power charge session using only the excess. As clouds pass and generation fluctuates, it adjusts the charge current up or down via the OCPP max-current control. This approach is sometimes called "solar surplus charging" and can deliver genuinely free fuel during sunny months.
Departure-aware scheduling adds a time constraint. If you tell the agent (via Telegram, Discord, or a Home Assistant input) that you need the car ready by 7 AM with at least 80% charge, it works backward from that deadline. It calculates how many kWh are needed, estimates how long charging will take at the available current, and finds the cheapest contiguous window that finishes before your departure time. If no single off-peak window is long enough, it splits the session across multiple cheap periods.
These strategies compound. An agent running solar-first during the day and off-peak scheduling overnight captures savings from both directions. The residential EV charger market is growing at a 27% CAGR according to Mordor Intelligence, and as more homes add both solar and EVs, this kind of coordinated energy management becomes increasingly valuable.
Logging Sessions and Sharing Data with Fast.io
Charging session data is useful beyond the immediate cost savings. Monthly summaries help you verify utility bills, track total transportation energy costs, and quantify how much solar energy went to driving instead of grid export. The challenge is that Home Assistant stores data in a local SQLite database that is not designed for long-term analytics or sharing.
For session logging, the agent can write structured summaries to a Fast.io workspace after each charging session ends. Each summary includes the session start and end time, total energy delivered, average and peak power draw, estimated cost based on the applicable rate tier, and the percentage of energy that came from solar (if tracked). With Intelligence Mode enabled, these files are automatically indexed, so you can later ask questions like "what was my average charging cost per kWh last month?" or "how many sessions used solar surplus charging?" and get cited answers from your own data.
Fast.io's free agent tier provides 50GB of storage, 5,000 credits per month, and five workspaces with no credit card required, which is more than enough for years of charging logs. The MCP server lets OpenClaw upload session files directly, and the workspace's built-in Metadata Views can extract structured fields from session logs into a sortable, filterable table without writing any parsing code.
If you manage multiple EVs or charging locations, separate workspaces keep each one organized while letting you query across them. You can also share a workspace with your household so everyone can see charging patterns and costs. When you eventually hand the system off, whether to a property buyer, a fleet manager, or a family member, Fast.io's ownership transfer feature lets you pass full workspace control while retaining admin access during the transition.
For configuration backup, store your Home Assistant OCPP configuration, OpenClaw skill configs, and rate schedule files in the same workspace. Version history tracks every change, so if an automation update breaks your charging schedule, you can diff against the previous version and roll back.
Frequently Asked Questions
Can I monitor my EV charger with a Raspberry Pi?
Yes. A Raspberry Pi running Home Assistant with the OCPP integration acts as a central system that your OCPP-compatible charger connects to over WebSocket. The integration exposes sensors for power draw, energy consumed, voltage, current, and session status. Adding OpenClaw on the same Pi gives you an AI agent that can read this data, make scheduling decisions, and control the charger. Compatible chargers include models from Wallbox, ABB, Grizzl-E, CTEK, EVBox, and others that support OCPP 1.6 or later.
How do I schedule EV charging for off-peak hours?
The simplest approach is a Home Assistant automation that starts charging at a fixed time, but this does not adapt to changing rate schedules or your actual energy needs. An OpenClaw agent can check your utility's time-of-use rate tiers, calculate how much energy your vehicle needs, and find the cheapest window that finishes before your departure time. The agent controls charging through OCPP commands via Home Assistant, adjusting start time and charge current to minimize cost.
What is the OCPP protocol?
OCPP (Open Charge Point Protocol) is an open standard for communication between EV chargers and central management systems. It is maintained by the Open Charge Alliance and is manufacturer-neutral, so chargers from different vendors can connect to the same management system. OCPP 1.6 is the most widely deployed version, supporting smart charging and JSON messaging. OCPP 2.0.1 added improved security, unified transaction handling, and vehicle-to-grid support. OCPP 2.1, released in January 2025, introduced backward compatibility and V2X (Vehicle-to-Everything) support.
Does this setup work with any EV charger?
It works with any charger that supports OCPP 1.6 or later. The Home Assistant OCPP integration has confirmed compatibility with chargers from ABB, Wallbox, Grizzl-E, CTEK, EVBox, Alfen, and many others. Check the integration's supported devices list for specific firmware requirements. Chargers that use proprietary cloud-only protocols (no local OCPP endpoint) will not work with this setup.
How much can I save by scheduling EV charging off-peak?
Savings depend on your utility's rate spread between peak and off-peak periods. In regions with aggressive time-of-use pricing, like California, the difference can be $0.20-0.40 per kWh. For a typical EV that consumes 300-400 kWh per month, shifting all charging to off-peak hours can save $60-160 per month. Adding solar surplus charging during daytime hours increases savings further by using self-generated electricity that would otherwise be exported at a lower feed-in rate.
Can this agent integrate with solar panels?
Yes, if your solar inverter is integrated with Home Assistant (through SolarEdge, Enphase, Fronius, or a generic CT clamp integration), the OpenClaw agent can read real-time solar production alongside household consumption. When excess generation exceeds the charger's minimum draw, the agent starts a charge session and adjusts current to match available surplus. This is sometimes called solar surplus or solar diversion charging.
Related Resources
Store and query your EV charging session data
Free 50GB workspace for charging logs, rate schedules, and agent configs. Intelligence Mode indexes everything for natural-language queries. No credit card required.