Skip to content

Commit 0569f58

Browse files
authored
Update OCPP.md
1 parent 54c80eb commit 0569f58

File tree

1 file changed

+166
-1
lines changed
  • docs/Software_and_control/Software/OCPP

1 file changed

+166
-1
lines changed

docs/Software_and_control/Software/OCPP/OCPP.md

Lines changed: 166 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,169 @@ parent: Software
44
layout: minimal
55
---
66

7-
# OCPP
7+
# OCPP
8+
9+
<img src="https://r2cdn.perplexity.ai/pplx-full-logo-primary-dark%402x.png" class="logo" width="120"/>
10+
11+
## User Guide: Integrating OCPP EV Chargers with EMHASS for Home Assistant
12+
13+
This guide explains how to connect OCPP-compatible EV chargers to EMHASS for smart charging and vehicle-to-grid (V2G) optimization. Learn to automate charging schedules, align EV usage with solar production, and reduce energy costs using EMHASS’s predictive algorithms.
14+
15+
---
16+
17+
### **1. Prerequisites**
18+
19+
- **Hardware**:
20+
- OCPP 1.6J/2.0.1-compatible EV charger (e.g., Wallbox, Zappi, ABB Terra).
21+
- EV supporting bidirectional charging (V2G) if applicable (e.g., Nissan Leaf, Ford F-150 Lightning).
22+
- **Software**:
23+
- Home Assistant (OS/Supervised recommended).
24+
- [OCPP Integration](https://github.com/lbbrhzn/ocpp) via HACS.
25+
- EMHASS add-on installed and configured for solar/battery optimization.
26+
27+
---
28+
29+
### **2. OCPP Integration Setup**
30+
31+
#### **A. Install and Configure OCPP**
32+
33+
1. **Install via HACS**:
34+
- Add `https://github.com/lbbrhzn/ocpp` to HACS repositories.
35+
- Install the **OCPP** integration and restart Home Assistant.
36+
2. **Add Central System**:
37+
- Go to **Settings > Devices \& Services > Add Integration > OCPP**.
38+
- Set **Host** to `0.0.0.0` and **Port** to `9000`.
39+
- Note the WebSocket URL (e.g., `ws://192.168.1.100:9000`).
40+
3. **Connect Your Charger**:
41+
- Configure the charger’s OCPP Central System URL to match the WebSocket URL.
42+
- Key entities will auto-populate:
43+
- Charger status: `sensor.charger_status`
44+
- Charging power: `sensor.charger_power`
45+
- Control switch: `switch.charger_charge_control`
46+
47+
---
48+
49+
### **3. EMHASS Configuration for OCPP Chargers**
50+
51+
#### **A. Define Charger as a Deferrable Load**
52+
53+
In EMHASS’s `config.json` or web UI:
54+
55+
```json
56+
{
57+
"deferrable_loads": {
58+
"ev_charger": {
59+
"entity_id": "switch.charger_charge_control",
60+
"max_power": 11000, // Charger’s max power (Watts)
61+
"soc_entity": "sensor.ev_battery_soc", // Required for V2G
62+
"soc_min": 20, // Minimum battery % for discharge
63+
"soc_max": 80 // Maximum battery % for charging
64+
}
65+
}
66+
}
67+
```
68+
69+
70+
#### **B. For V2G (Bidirectional Charging)**
71+
72+
Add the EV as a battery asset in EMHASS:
73+
74+
```json
75+
{
76+
"batteries": [
77+
{
78+
"name": "ev_battery",
79+
"sensor_power": "sensor.charger_power", // Negative = discharging
80+
"sensor_soc": "sensor.ev_battery_soc",
81+
"capacity_kwh": 40,
82+
"max_discharge_rate": 5000 // 5kW max discharge
83+
}
84+
]
85+
}
86+
```
87+
88+
89+
---
90+
91+
### **4. Automating with EMHASS and OCPP**
92+
93+
#### **A. Daily Optimization Workflow**
94+
95+
1. **Run EMHASS Optimization**:
96+
- EMHASS calculates charging/discharging schedules using solar forecasts and tariffs.
97+
2. **Apply Schedule via OCPP TxProfile**:
98+
99+
```yaml
100+
automation:
101+
- alias: "Set Daily Charging Schedule"
102+
trigger:
103+
- platform: time
104+
at: "04:00:00" // Run before peak solar
105+
action:
106+
- service: rest_command.emhass_optimize
107+
- delay: "00:05:00"
108+
- service: ocpp.set_tx_profile
109+
data:
110+
charger_id: "EVSE1"
111+
tx_profile:
112+
schedule:
113+
- start_period: "2025-06-10T10:00:00Z"
114+
limit: 11000 // Charge at 11kW during solar surplus
115+
- start_period: "2025-06-10T17:00:00Z"
116+
limit: -5000 // Discharge 5kW during peak tariff
117+
```
118+
119+
120+
#### **B. Solar-Powered Charging Automation**
121+
122+
```yaml
123+
automation:
124+
- alias: "Charge Only on Solar Surplus"
125+
trigger:
126+
- platform: numeric_state
127+
entity_id: sensor.pv_power
128+
above: >
129+
{{ states("sensor.house_load") | float + 1000 }} // 1kW surplus
130+
action:
131+
- service: switch.turn_on
132+
target:
133+
entity_id: switch.charger_charge_control
134+
```
135+
136+
137+
---
138+
139+
### **5. Key Entities and Services**
140+
141+
| **Function** | **Home Assistant Entity/Service** | **EMHASS Parameter** |
142+
| :-- | :-- | :-- |
143+
| Charger Control | `switch.charger_charge_control` | `deferrable_loads.ev_charger` |
144+
| Charger Power | `sensor.charger_power` | Used in automations |
145+
| EV Battery SOC | `sensor.ev_battery_soc` | `batteries.ev_battery.sensor_soc` |
146+
| Set Schedule | `service: ocpp.set_tx_profile` | Linked to EMHASS outputs |
147+
148+
149+
---
150+
151+
### **6. Troubleshooting**
152+
153+
- **Charger Not Responding**:
154+
- Check firewall rules for port `9000`.
155+
- Verify the charger’s OCPP URL matches the Home Assistant WebSocket address.
156+
- **Incorrect Charging Power**:
157+
- Confirm `max_power` in EMHASS matches the charger’s rating.
158+
- Check `sensor.charger_power` unit (Watts vs. kilowatts).
159+
- **V2G Not Working**:
160+
- Ensure the charger and EV support bidirectional charging.
161+
- Validate `sensor.charger_power` shows negative values during discharge.
162+
163+
---
164+
165+
### **7. Resources**
166+
167+
- **OCPP Integration Docs**: [home-assistant-ocpp.readthedocs.io](https://home-assistant-ocpp.readthedocs.io)
168+
- **EMHASS Configuration**: [emhass.readthedocs.io](https://emhass.readthedocs.io)
169+
- **OCPP 2.0.1 Specification**: [openchargealliance.org](https://www.openchargealliance.org)
170+
171+
By integrating OCPP with EMHASS, you unlock precise control over EV charging, turning your vehicle into a dynamic asset for solar optimization, grid cost reduction, and energy resilience.
172+

0 commit comments

Comments
 (0)