diff --git a/app.py b/app.py index 62be46a..307f907 100644 --- a/app.py +++ b/app.py @@ -18,20 +18,25 @@ def get_inverter_data(): verbose=False ) - # Reading two main blocks: - # Block 1: 150 - 216 (67 registers) - Covers Voltages, Currents, Battery, PV, Control - # Block 2: 600 - 627 (28 registers) - Covers BMS Data + # 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 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) def to_signed(val): return val if val < 32768 else val - 65536 data = {} - # Block 1 Parsing - # Offsets relative to 150 + # 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 @@ -45,7 +50,7 @@ def get_inverter_data(): 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 (Raw for now) + data["batt_charge_status"] = block1[35] # 185 data["pv1_power"] = block1[36] # 186 data["pv2_power"] = block1[37] # 187 @@ -59,24 +64,34 @@ def get_inverter_data(): data["max_discharge_current"] = block1[61] # 211 data["batt_charge_efficiency"] = block1[66] # 216 - # Block 2 Parsing (BMS) - # Offsets relative to 600 - # BMS 1 (600-613) + # Block 2 Parsing (BMS 600-627) data["bms1_soc"] = block2[3] # 603 - data["bms1_voltage"] = round(block2[6] * 0.01, 2) # 606 (Charge Voltage?) - Wait, PDF says 606 Charge Voltage. - # Let's stick to the PDF labels from extraction if possible, or generic BMS fields. - # Extracted: 606 Charge Voltage 0.01V. - # Actually commonly 600+ are BMS specific. - # Let's just map them raw or with simple scaling as per PDF. - data["bms1_charge_voltage"] = round(block2[6] * 0.01, 2) # 606 data["bms1_charge_current"] = round(block2[7] * 0.1, 1) # 607 - # BMS 2 (614-627) 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() data["status"] = "success" diff --git a/templates/index.html b/templates/index.html index 115fc6f..16d145d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -18,19 +18,6 @@ body { background-color: var(--bg-color); color: var(--text-color); - font-family: var(--font-family); - margin: 0; - padding: 20px; - 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 { @@ -120,7 +107,6 @@ -

Deye Inverter Monitor

@@ -281,268 +267,309 @@
-
- - Connecting... +

Advanced Control & Limits

+
+
+

Max Grid Output

+
+ --W +
+
+
+

Gen Peak Shaving

+
+ --W +
+
+
+

Grid Peak Shaving

+
+ --W +
+
+
+

Discharge Voltage

+
+ --V +
+
+
+

Charge I Limit

+
+ --A +
+
+
+

Discharge I Limit

+
+ --A +
+
+
+

Real Time Cap

+
+ --% +
+
+
+

Real Time Voltage

+
+ --V +
+
+
+

Max Charge I Limit

+
+ --A +
+
+
+

Max Discharge I Limit

+
+ --A +
+
+
+

Lithium Type

+
+ -- +
+
- 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; - } - - - - - -

Deye Inverter Monitor

- -
-
-

Grid Voltage (Input)

-
- --V -
-
- -
-

Output Voltage

-
- --V -
-
- -
-

Load Voltage

-
- --V -
-
- -
-

Grid Current

-
- --A -
-
- -
-

Grid Clamp Current

-
- --A -
-
- -
-

Output Current

-
- --A -
+
+ +
+

Battery SOC

+
--%
- -

Battery & PV

-
-
-

Battery SOC

-
- --% -
-
-
-

Battery Voltage

-
- --V -
-
-
-

Battery Current

-
- --A -
-
-
-

Battery Power

-
- --W -
-
-
-

Battery Temp

-
- --°C -
-
-
-

PV1 Power

-
- --W -
-
-
-

PV2 Power

-
- --W -
+
+

Battery Voltage

+
--V
+
+
+

Battery Current

+
--A
+
+
+

Battery Power

+
--W
+
+
+

Battery Temp

+
--°C
+
+
+

PV1 Power

+
--W
- -

Control Status

-
-
-

Grid Relay

-
- -- -
-
-
-

Gen Relay

-
- -- -
-
-
-

Max Charge I

-
- --A -
-
-
-

Max Discharge I

-
- --A -
+
+

PV2 Power

+
--W
- -

BMS Data

-
-
-

BMS1 SOC

-
- --% -
-
-
-

BMS1 Voltage

-
- --V -
-
-
-

BMS1 Current

-
- --A -
-
-
-

BMS2 SOC

-
- --% -
-
-
-

BMS2 Voltage

-
- --V -
-
-
-

BMS2 Current

-
- --A -
+
+

Control Status

+
+
+

Grid Relay

+
--
+
+
+

Gen Relay

+
--
+
+
+

Max Charge I

+
--A
+
+
+

Max Discharge I

+
--A
+
+
+

BMS Data

+
+
+

BMS1 SOC

+
--%
- -
- - Connecting... +
+

BMS1 Voltage

+
--V
+
+

BMS1 Current

+
--A
+
+
+

BMS2 SOC

+
--% +
+
+
+

BMS2 Voltage

+
--V
+
+
+

BMS2 Current

+
--A
+
+
+

Advanced Control & Limits

+
+
+

Max Grid Output

+
--W
+
+
+

Gen Peak Shaving

+
--W
+
+
+

Grid Peak Shaving

+
--W
+
+
+

Discharge Voltage

+
--V
+
+
+

Charge I Limit

+
--A
+
+
+

Discharge I Limit

+
--A
+
+
+

Real Time Cap

+
--%
+
+
+

Real Time Voltage

+
--V
+
+
+

Max Charge I Limit

+
--A
+
+
+

Max Discharge I Limit

+
--A
+
+
+

Lithium Type

+
--
+
+
+
Connecting...
+ - + catch (error) { + console.error('Error fetching data:', error); + statusDot.className = 'status-indicator error'; + statusText.textContent = 'Error: ' + error.message; + } + } + + // Fetch immediately, then every 5 seconds + fetchData(); + setInterval(fetchData, 5000); + + \ No newline at end of file