maximum demand electrical MyGit

Maximum Demand Electrical Link

"timestamp": "2026-04-14T10:15:00Z", "demand_kw": 134.7, "limit_kw": 150.0, "demand_percent": 89.8, "peak_kw": 148.2, "peak_timestamp": "2026-04-13T18:30:00Z", "warning_level": "none", "shedding_active": false

Two‑stage shedding + restoration.

# Calculate total kWh in complete window total_kwh = sum(self.buffer) demand_kw = total_kwh / (self.window_size / 60.0) maximum demand electrical

# Store in circular buffer self.buffer[self.index] = delta_kwh self.index = (self.index + 1) % self.num_blocks "timestamp": "2026-04-14T10:15:00Z", "demand_kw": 134

+---------------------+------------------+ | Period | Peak Demand (kW) | +---------------------+------------------+ | 2026-04-01 to 07 | 142.3 | | 2026-03-25 to 31 | 138.9 | +---------------------+------------------+ | Condition | Handling | |-----------|----------| | Power loss | Persist buffer & peak to EEPROM. On restart, wait for full window before reliable demand. | | Incomplete window at startup | Use partial window average with a flag. | | Meter rollover | Detect by comparing readings; adjust delta with max meter reading. | | Communication delay | Timestamp each reading; interpolate if needed. | 9. Sample API / Interface (for system integration) // GET /api/max_demand/current | | Incomplete window at startup | Use

# Update peak if demand_kw > self.peak_demand_kw: self.peak_demand_kw = demand_kw self.peak_timestamp = now_timestamp

For kVA demand (common for utilities), measure voltage and current, then: