Realtime endpoint was summing ALL device power readings, causing
double-counting when multiple devices share the same Sungrow station.
E.g. 10 devices × station-level power = 5x inflated total.
Fix: GROUP BY station prefix (first 3 chars of device name) and
take MAX per station. Same fix applied to KPI daily_generation.
Result: 5,550 kW → 1,931 kW (matches iSolarCloud's 2,049 kW
within the 15-min collection timing window).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Carbon overview: fallback to compute from energy_data × emission_factors
when carbon_emissions table is empty
- Energy history: parse start_time/end_time as datetime (was raw string → 500)
- Dashboard generation: dedup by station prefix to prevent inflated totals
(93K → 14.8K kWh)
- Realtime window: already at 20min to cover 15min collector interval
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Migration adds tables that existed in models/ but were never
included in alembic history:
- ai_ops: device_health_scores, anomaly_detections, diagnostic_reports,
maintenance_predictions, ops_insights
- energy_strategy: tou_pricing, tou_pricing_periods, energy_strategies,
strategy_executions, monthly_cost_reports
- weather: weather_data, weather_config
- prediction: prediction_tasks, prediction_results, optimization_schedules
Without this migration, fresh deploys would 500 on these endpoints:
- /api/v1/ai-ops/health, /ai-ops/dashboard
- /api/v1/strategy/pricing
- /api/v1/prediction/forecast
- /api/v1/weather/current
Discovered during Z-Park demo deployment on xie_openclaw1.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New endpoints:
- GET /api/v1/version — returns VERSIONS.json (no auth required)
For field engineers to check platform version from login page
- GET /api/v1/kpi/solar — returns PR, self-consumption rate,
equivalent utilization hours, and daily revenue
Handles station-level vs device-level data deduplication
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace all hardcoded Tianpu/天普 defaults with generic "EMS Platform"
- Add energy_today fallback: query raw energy_data when daily summary empty
- Fix PV device filter to include sungrow_inverter device type
- Update APP_NAME, CUSTOMER default, SECRET_KEY, SMTP, Celery, email templates
BREAKING: CUSTOMER default changed from "tianpu" to "default"
Existing deployments with CUSTOMER=tianpu in .env are unaffected.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>