Compare commits
3 Commits
a6b1010650
...
9f96a3e534
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f96a3e534 | ||
|
|
0b377db6c2 | ||
|
|
e75f7222a0 |
91
README.md
91
README.md
@@ -1,7 +1,90 @@
|
||||
# deyeChargeSpeed
|
||||
# Deye Charge Speed Monitor
|
||||
|
||||
https://github.com/jmccrohan/pysolarmanv5
|
||||
A Flask-based application for monitoring Deye Inverters (and compatible models) using the Solarman V5 protocol. This tool connects directly to the inverter via Modbus over TCP to read real-time data including voltages, currents, battery status, and BMS information.
|
||||
|
||||
https://pysolarmanv5.readthedocs.io/en/stable/
|
||||
## Features
|
||||
|
||||
https://pysolarmanv5.readthedocs.io/en/stable/examples.html
|
||||
- **Real-time Monitoring**: Reads critical data such as Input/Output Voltage, Grid/Load Currents, Battery SOC, Temperature, and Power.
|
||||
- **BMS Integration**: Retrieves detailed Battery Management System (BMS) data for up to two battery packs.
|
||||
- **Web Interface**: Provides a user-friendly dashboard to view inverter status (served at `/`).
|
||||
- **JSON API**: Exposes raw data via a RESTful endpoint (`/api/data`) for integration with other systems.
|
||||
- **PDF Utility**: Includes a tool to extract register information from Deye Modbus PDF manuals.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Python 3.x
|
||||
- A Deye Inverter (or compatible) connected to the network.
|
||||
- Inverter IP address, Serial Number, and Modbus Slave ID.
|
||||
|
||||
## Installation
|
||||
|
||||
1. **Clone the repository:**
|
||||
|
||||
```bash
|
||||
git clone <repository-url>
|
||||
cd deyeChargeSpeed
|
||||
```
|
||||
|
||||
2. **Create and activate a virtual environment:**
|
||||
|
||||
```bash
|
||||
python -m venv venv
|
||||
# Windows
|
||||
.\venv\Scripts\activate
|
||||
# Linux/Mac
|
||||
source venv/bin/activate
|
||||
```
|
||||
|
||||
3. **Install dependencies:**
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
4. **Configuration:**
|
||||
|
||||
Copy the example configuration file and update it with your inverter details:
|
||||
|
||||
```bash
|
||||
cp config.py.example config.py
|
||||
```
|
||||
|
||||
Edit `config.py`:
|
||||
```python
|
||||
INVERTER_IP = "192.168.x.x"
|
||||
INVERTER_SERIAL = 1234567890
|
||||
INVERTER_PORT = 8899
|
||||
INVERTER_SLAVE_ID = 1
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
1. **Start the application:**
|
||||
|
||||
```bash
|
||||
python app.py
|
||||
```
|
||||
|
||||
2. **Access the dashboard:**
|
||||
|
||||
Open your web browser and navigate to `http://localhost:5000`.
|
||||
|
||||
## Utilities
|
||||
|
||||
### PDF Register Extractor
|
||||
|
||||
Located in `docs/extract_pdf.py`, this script helps identify Modbus registers from Deye PDF manuals.
|
||||
|
||||
**Usage:**
|
||||
1. Place your PDF manual in the `docs/` folder.
|
||||
2. Update the filename in `docs/extract_pdf.py` if necessary (defaults to `Modbus储能-组串-微逆宁波德业V118-1.pdf`).
|
||||
3. Run the script:
|
||||
```bash
|
||||
python docs/extract_pdf.py
|
||||
```
|
||||
4. Check `pdf_output.txt` for the extracted register locations and context.
|
||||
|
||||
## Resources
|
||||
|
||||
- [PySolarmanV5 Documentation](https://pysolarmanv5.readthedocs.io/en/stable/)
|
||||
- [PySolarmanV5 GitHub](https://github.com/jmccrohan/pysolarmanv5)
|
||||
92
app.py
92
app.py
@@ -18,34 +18,84 @@ def get_inverter_data():
|
||||
verbose=False
|
||||
)
|
||||
|
||||
# Registers to read:
|
||||
# 150: Grid Voltage (Input Voltage) - 0.1V
|
||||
# 154: Output Voltage - 0.1V
|
||||
# 157: Load Voltage - 0.1V
|
||||
# Reading blocks:
|
||||
# Block 1: 150 - 216 (67 registers) - Voltages, Currents, Battery, PV, Control
|
||||
# Block 2: 600 - 627 (28 registers) - BMS Data
|
||||
# Block 3: 245 (1 register) - Max Grid Output
|
||||
# Block 4: 292 - 293 (2 registers) - Peak Shaving
|
||||
# Block 5: 314 - 325 (12 registers) - Advanced Limits
|
||||
|
||||
# Reading individually for simplicity, though block read is more efficient if contiguous
|
||||
# But these are slightly apart (150, 154, 157).
|
||||
# We can read a block from 150 to 157 (8 registers) and parse.
|
||||
block1 = inverter.read_holding_registers(register_addr=150, quantity=67)
|
||||
block2 = inverter.read_holding_registers(register_addr=600, quantity=28)
|
||||
block3 = inverter.read_holding_registers(register_addr=245, quantity=1)
|
||||
block4 = inverter.read_holding_registers(register_addr=292, quantity=2)
|
||||
block5 = inverter.read_holding_registers(register_addr=314, quantity=12)
|
||||
|
||||
# Let's read block starting at 150, length 8.
|
||||
# 150 -> Index 0
|
||||
# 154 -> Index 4
|
||||
# 157 -> Index 7
|
||||
def to_signed(val):
|
||||
return val if val < 32768 else val - 65536
|
||||
|
||||
raw_data = inverter.read_holding_registers(register_addr=150, quantity=8)
|
||||
data = {}
|
||||
|
||||
input_voltage = raw_data[0] * 0.1
|
||||
output_voltage = raw_data[4] * 0.1
|
||||
load_voltage = raw_data[7] * 0.1
|
||||
# Block 1 Parsing (150-216)
|
||||
data["input_voltage"] = round(block1[0] * 0.1, 1) # 150
|
||||
data["output_voltage"] = round(block1[4] * 0.1, 1) # 154
|
||||
data["load_voltage"] = round(block1[7] * 0.1, 1) # 157
|
||||
|
||||
data["grid_current"] = round(to_signed(block1[10]) * 0.01, 2) # 160
|
||||
data["grid_clamp_current"] = round(to_signed(block1[12]) * 0.01, 2) # 162
|
||||
data["output_current"] = round(to_signed(block1[14]) * 0.01, 2) # 164
|
||||
|
||||
data["load_current"] = round(to_signed(block1[29]) * 0.01, 2) # 179
|
||||
|
||||
data["batt_temp"] = round(to_signed(block1[32]) * 0.1, 1) # 182
|
||||
data["batt_voltage"] = round(block1[33] * 0.01, 2) # 183
|
||||
data["batt_soc"] = block1[34] # 184
|
||||
data["batt_charge_status"] = block1[35] # 185
|
||||
data["pv1_power"] = block1[36] # 186
|
||||
data["pv2_power"] = block1[37] # 187
|
||||
|
||||
data["batt_power"] = to_signed(block1[40]) # 190
|
||||
data["batt_current"] = round(to_signed(block1[41]) * 0.01, 2) # 191
|
||||
|
||||
data["grid_relay_status"] = block1[44] # 194
|
||||
data["gen_relay_status"] = block1[45] # 195
|
||||
|
||||
data["max_charge_current"] = block1[60] # 210
|
||||
data["max_discharge_current"] = block1[61] # 211
|
||||
data["batt_charge_efficiency"] = block1[66] # 216
|
||||
|
||||
# Block 2 Parsing (BMS 600-627)
|
||||
data["bms1_soc"] = block2[3] # 603
|
||||
data["bms1_charge_voltage"] = round(block2[6] * 0.01, 2) # 606
|
||||
data["bms1_charge_current"] = round(block2[7] * 0.1, 1) # 607
|
||||
|
||||
data["bms2_soc"] = block2[17] # 617
|
||||
data["bms2_charge_voltage"] = round(block2[20] * 0.01, 2) # 620
|
||||
data["bms2_charge_current"] = round(block2[21] * 0.1, 1) # 621
|
||||
|
||||
# Block 3 Parsing (245)
|
||||
data["max_grid_output_power"] = block3[0] # 245
|
||||
|
||||
# Block 4 Parsing (292-293)
|
||||
data["gen_peak_shaving_power"] = block4[0] # 292
|
||||
data["grid_peak_shaving_power"] = block4[1] # 293
|
||||
|
||||
# Block 5 Parsing (314-325)
|
||||
data["discharge_voltage"] = round(block5[0] * 0.01, 2) # 314
|
||||
data["charge_current_limit"] = block5[1] # 315
|
||||
data["discharge_current_limit"] = block5[2] # 316
|
||||
data["real_time_capacity"] = block5[3] # 317
|
||||
data["real_time_voltage"] = round(block5[4] * 0.01, 2) # 318
|
||||
# 319 skipped
|
||||
data["max_charge_current_limit"] = block5[6] # 320
|
||||
data["max_discharge_current_limit"] = block5[7] # 321
|
||||
# 322-324 skipped
|
||||
data["lithium_battery_type"] = block5[11] # 325
|
||||
|
||||
inverter.disconnect()
|
||||
|
||||
return {
|
||||
"input_voltage": round(input_voltage, 1),
|
||||
"output_voltage": round(output_voltage, 1),
|
||||
"load_voltage": round(load_voltage, 1),
|
||||
"status": "success"
|
||||
}
|
||||
data["status"] = "success"
|
||||
return data
|
||||
|
||||
except Exception as e:
|
||||
return {
|
||||
|
||||
39
docs/extract_pdf.py
Normal file
39
docs/extract_pdf.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
import pypdf
|
||||
import re
|
||||
|
||||
pdf_path = os.path.join(os.path.dirname(__file__), "Modbus储能-组串-微逆宁波德业V118-1.pdf")
|
||||
|
||||
def extract_text_from_pdf(pdf_path):
|
||||
reader = pypdf.PdfReader(pdf_path)
|
||||
text = ""
|
||||
for page in reader.pages:
|
||||
text += page.extract_text() + "\n"
|
||||
return text
|
||||
|
||||
full_text = extract_text_from_pdf(pdf_path)
|
||||
|
||||
# Registers to look for
|
||||
registers = [94, 245, 320]
|
||||
|
||||
print("Searching for registers...")
|
||||
|
||||
# Split text into lines for easier processing
|
||||
lines = full_text.split('\n')
|
||||
|
||||
found_registers = {}
|
||||
|
||||
with open("pdf_output.txt", "w", encoding="utf-8") as f:
|
||||
for i, line in enumerate(lines):
|
||||
for reg in registers:
|
||||
if re.search(r'\b' + str(reg) + r'\b', line):
|
||||
f.write(f"MATCH {reg}: {line.strip()}\n")
|
||||
# Write context
|
||||
start = max(0, i - 5)
|
||||
end = min(len(lines), i + 6)
|
||||
for j in range(start, end):
|
||||
if i != j:
|
||||
f.write(f" CTX: {lines[j].strip()}\n")
|
||||
f.write("-" * 20 + "\n")
|
||||
|
||||
print("Done. Check pdf_output.txt")
|
||||
@@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@@ -17,47 +18,6 @@
|
||||
body {
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-color);
|
||||
font-family: var(--font-family);
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 40px;
|
||||
font-weight: 300;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
background: linear-gradient(45deg, var(--accent-color), var(--secondary-accent));
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.dashboard {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 20px;
|
||||
width: 100%;
|
||||
max-width: 1000px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background-color: var(--card-bg);
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
text-align: center;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
|
||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.card::before {
|
||||
@@ -118,19 +78,35 @@
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% { opacity: 1; }
|
||||
50% { opacity: 0.5; }
|
||||
100% { opacity: 1; }
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.loading .value {
|
||||
animation: pulse 1.5s infinite;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.dashboard {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 20px;
|
||||
width: 100%;
|
||||
max-width: 1000px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<body>
|
||||
<h1>Deye Inverter Monitor</h1>
|
||||
|
||||
<div class="dashboard">
|
||||
@@ -154,17 +130,370 @@
|
||||
<span class="value" id="load-voltage">--</span><span class="unit">V</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" id="card-grid-current">
|
||||
<h2>Grid Current</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="grid-current">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" id="card-clamp-current">
|
||||
<h2>Grid Clamp Current</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="grid-clamp-current">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" id="card-output-current">
|
||||
<h2>Output Current</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="output-current">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Battery & PV</h2>
|
||||
<div class="dashboard">
|
||||
<div class="card">
|
||||
<h2>Battery SOC</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="batt-soc">--</span><span class="unit">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Battery Voltage</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="batt-voltage">--</span><span class="unit">V</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Battery Current</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="batt-current">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Battery Power</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="batt-power">--</span><span class="unit">W</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Battery Temp</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="batt-temp">--</span><span class="unit">°C</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>PV1 Power</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="pv1-power">--</span><span class="unit">W</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>PV2 Power</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="pv2-power">--</span><span class="unit">W</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Control Status</h2>
|
||||
<div class="dashboard">
|
||||
<div class="card">
|
||||
<h2>Grid Relay</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="grid-relay">--</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Gen Relay</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="gen-relay">--</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Max Charge I</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="max-charge">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Max Discharge I</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="max-discharge">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>BMS Data</h2>
|
||||
<div class="dashboard">
|
||||
<div class="card">
|
||||
<h2>BMS1 SOC</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="bms1-soc">--</span><span class="unit">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>BMS1 Voltage</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="bms1-voltage">--</span><span class="unit">V</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>BMS1 Current</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="bms1-current">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>BMS2 SOC</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="bms2-soc">--</span><span class="unit">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>BMS2 Voltage</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="bms2-voltage">--</span><span class="unit">V</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>BMS2 Current</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="bms2-current">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Advanced Control & Limits</h2>
|
||||
<div class="dashboard">
|
||||
<div class="card">
|
||||
<h2>Max Grid Output</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="max-grid-output">--</span><span class="unit">W</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Gen Peak Shaving</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="gen-peak-shaving">--</span><span class="unit">W</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Grid Peak Shaving</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="grid-peak-shaving">--</span><span class="unit">W</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Discharge Voltage</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="discharge-voltage">--</span><span class="unit">V</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Charge I Limit</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="charge-i-limit">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Discharge I Limit</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="discharge-i-limit">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Real Time Cap</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="real-time-cap">--</span><span class="unit">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Real Time Voltage</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="real-time-voltage">--</span><span class="unit">V</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Max Charge I Limit</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="max-charge-i-limit">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Max Discharge I Limit</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="max-discharge-i-limit">--</span><span class="unit">A</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Lithium Type</h2>
|
||||
<div class="value-container loading">
|
||||
<span class="value" id="lithium-type">--</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-bar">
|
||||
<span class="status-indicator" id="status-dot"></span>
|
||||
<span id="status-text">Connecting...</span>
|
||||
<div class="card">
|
||||
<h2>Battery SOC</h2>
|
||||
<div class="value-container loading"><span class="value" id="batt-soc">--</span><span class="unit">%</span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const inputVoltageEl = document.getElementById('input-voltage');
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Battery Voltage</h2>
|
||||
<div class="value-container loading"><span class="value" id="batt-voltage">--</span><span
|
||||
class="unit">V</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Battery Current</h2>
|
||||
<div class="value-container loading"><span class="value" id="batt-current">--</span><span
|
||||
class="unit">A</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Battery Power</h2>
|
||||
<div class="value-container loading"><span class="value" id="batt-power">--</span><span
|
||||
class="unit">W</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Battery Temp</h2>
|
||||
<div class="value-container loading"><span class="value" id="batt-temp">--</span><span
|
||||
class="unit">°C</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>PV1 Power</h2>
|
||||
<div class="value-container loading"><span class="value" id="pv1-power">--</span><span class="unit">W</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>PV2 Power</h2>
|
||||
<div class="value-container loading"><span class="value" id="pv2-power">--</span><span class="unit">W</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h2>Control Status</h2>
|
||||
<div class="dashboard">
|
||||
<div class="card">
|
||||
<h2>Grid Relay</h2>
|
||||
<div class="value-container loading"><span class="value" id="grid-relay">--</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Gen Relay</h2>
|
||||
<div class="value-container loading"><span class="value" id="gen-relay">--</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Max Charge I</h2>
|
||||
<div class="value-container loading"><span class="value" id="max-charge">--</span><span
|
||||
class="unit">A</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Max Discharge I</h2>
|
||||
<div class="value-container loading"><span class="value" id="max-discharge">--</span><span
|
||||
class="unit">A</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<h2>BMS Data</h2>
|
||||
<div class="dashboard">
|
||||
<div class="card">
|
||||
<h2>BMS1 SOC</h2>
|
||||
<div class="value-container loading"><span class="value" id="bms1-soc">--</span><span class="unit">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>BMS1 Voltage</h2>
|
||||
<div class="value-container loading"><span class="value" id="bms1-voltage">--</span><span
|
||||
class="unit">V</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>BMS1 Current</h2>
|
||||
<div class="value-container loading"><span class="value" id="bms1-current">--</span><span
|
||||
class="unit">A</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>BMS2 SOC</h2>
|
||||
<div class="value-container loading"><span class="value" id="bms2-soc">--</span><span class="unit">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>BMS2 Voltage</h2>
|
||||
<div class="value-container loading"><span class="value" id="bms2-voltage">--</span><span
|
||||
class="unit">V</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>BMS2 Current</h2>
|
||||
<div class="value-container loading"><span class="value" id="bms2-current">--</span><span
|
||||
class="unit">A</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<h2>Advanced Control & Limits</h2>
|
||||
<div class="dashboard">
|
||||
<div class="card">
|
||||
<h2>Max Grid Output</h2>
|
||||
<div class="value-container loading"><span class="value" id="max-grid-output">--</span><span
|
||||
class="unit">W</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Gen Peak Shaving</h2>
|
||||
<div class="value-container loading"><span class="value" id="gen-peak-shaving">--</span><span
|
||||
class="unit">W</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Grid Peak Shaving</h2>
|
||||
<div class="value-container loading"><span class="value" id="grid-peak-shaving">--</span><span
|
||||
class="unit">W</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Discharge Voltage</h2>
|
||||
<div class="value-container loading"><span class="value" id="discharge-voltage">--</span><span
|
||||
class="unit">V</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Charge I Limit</h2>
|
||||
<div class="value-container loading"><span class="value" id="charge-i-limit">--</span><span
|
||||
class="unit">A</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Discharge I Limit</h2>
|
||||
<div class="value-container loading"><span class="value" id="discharge-i-limit">--</span><span
|
||||
class="unit">A</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Real Time Cap</h2>
|
||||
<div class="value-container loading"><span class="value" id="real-time-cap">--</span><span
|
||||
class="unit">%</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Real Time Voltage</h2>
|
||||
<div class="value-container loading"><span class="value" id="real-time-voltage">--</span><span
|
||||
class="unit">V</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Max Charge I Limit</h2>
|
||||
<div class="value-container loading"><span class="value" id="max-charge-i-limit">--</span><span
|
||||
class="unit">A</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Max Discharge I Limit</h2>
|
||||
<div class="value-container loading"><span class="value" id="max-discharge-i-limit">--</span><span
|
||||
class="unit">A</span></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Lithium Type</h2>
|
||||
<div class="value-container loading"><span class="value" id="lithium-type">--</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status-bar"><span class="status-indicator" id="status-dot"></span><span
|
||||
id="status-text">Connecting...</span></div>
|
||||
<script>const inputVoltageEl = document.getElementById('input-voltage');
|
||||
const outputVoltageEl = document.getElementById('output-voltage');
|
||||
const loadVoltageEl = document.getElementById('load-voltage');
|
||||
const gridCurrentEl = document.getElementById('grid-current');
|
||||
const gridClampCurrentEl = document.getElementById('grid-clamp-current');
|
||||
const outputCurrentEl = document.getElementById('output-current');
|
||||
const statusDot = document.getElementById('status-dot');
|
||||
const statusText = document.getElementById('status-text');
|
||||
const valueContainers = document.querySelectorAll('.value-container');
|
||||
@@ -175,23 +504,65 @@
|
||||
const data = await response.json();
|
||||
|
||||
if (data.status === 'success') {
|
||||
// Basic
|
||||
inputVoltageEl.textContent = data.input_voltage;
|
||||
outputVoltageEl.textContent = data.output_voltage;
|
||||
loadVoltageEl.textContent = data.load_voltage;
|
||||
gridCurrentEl.textContent = data.grid_current;
|
||||
gridClampCurrentEl.textContent = data.grid_clamp_current;
|
||||
outputCurrentEl.textContent = data.output_current;
|
||||
|
||||
// Battery & PV
|
||||
document.getElementById('batt-soc').textContent = data.batt_soc;
|
||||
document.getElementById('batt-voltage').textContent = data.batt_voltage;
|
||||
document.getElementById('batt-current').textContent = data.batt_current;
|
||||
document.getElementById('batt-power').textContent = data.batt_power;
|
||||
document.getElementById('batt-temp').textContent = data.batt_temp;
|
||||
document.getElementById('pv1-power').textContent = data.pv1_power;
|
||||
document.getElementById('pv2-power').textContent = data.pv2_power;
|
||||
|
||||
// Control Status
|
||||
document.getElementById('grid-relay').textContent = data.grid_relay_status;
|
||||
document.getElementById('gen-relay').textContent = data.gen_relay_status;
|
||||
document.getElementById('max-charge').textContent = data.max_charge_current;
|
||||
document.getElementById('max-discharge').textContent = data.max_discharge_current;
|
||||
|
||||
// BMS Data
|
||||
document.getElementById('bms1-soc').textContent = data.bms1_soc;
|
||||
document.getElementById('bms1-voltage').textContent = data.bms1_charge_voltage;
|
||||
document.getElementById('bms1-current').textContent = data.bms1_charge_current;
|
||||
document.getElementById('bms2-soc').textContent = data.bms2_soc;
|
||||
document.getElementById('bms2-voltage').textContent = data.bms2_charge_voltage;
|
||||
document.getElementById('bms2-current').textContent = data.bms2_charge_current;
|
||||
|
||||
// Advanced Control
|
||||
document.getElementById('max-grid-output').textContent = data.max_grid_output_power;
|
||||
document.getElementById('gen-peak-shaving').textContent = data.gen_peak_shaving_power;
|
||||
document.getElementById('grid-peak-shaving').textContent = data.grid_peak_shaving_power;
|
||||
document.getElementById('discharge-voltage').textContent = data.discharge_voltage;
|
||||
document.getElementById('charge-i-limit').textContent = data.charge_current_limit;
|
||||
document.getElementById('discharge-i-limit').textContent = data.discharge_current_limit;
|
||||
document.getElementById('real-time-cap').textContent = data.real_time_capacity;
|
||||
document.getElementById('real-time-voltage').textContent = data.real_time_voltage;
|
||||
document.getElementById('max-charge-i-limit').textContent = data.max_charge_current_limit;
|
||||
document.getElementById('max-discharge-i-limit').textContent = data.max_discharge_current_limit;
|
||||
document.getElementById('lithium-type').textContent = data.lithium_battery_type;
|
||||
|
||||
statusDot.className = 'status-indicator active';
|
||||
statusText.textContent = 'Connected';
|
||||
|
||||
valueContainers.forEach(el => el.classList.remove('loading'));
|
||||
} else {
|
||||
}
|
||||
|
||||
else {
|
||||
throw new Error(data.message || 'Unknown error');
|
||||
}
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
console.error('Error fetching data:', error);
|
||||
statusDot.className = 'status-indicator error';
|
||||
statusText.textContent = 'Error: ' + error.message;
|
||||
// Don't reset values to '--' immediately to avoid flickering if it's just a transient network blip,
|
||||
// but maybe indicate stale data if needed. For now, keep last known values.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,4 +571,5 @@
|
||||
setInterval(fetchData, 5000);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user