Dashboard: TUV křivka napojená na skutečnou telemetrii TČ
tuv_actual_c byl od vzniku grafu placeholder (null), TUV chart nikdy neukazoval data. Nové view vw_telemetry_heat_pump_15m_7d (15min agregace, R__101 + grant R__072) a plnění slotů v useDashboardData. Teploty avg přes přítomné řádky (idle-skip ok — není to výkon). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -217,6 +217,7 @@ export function useDashboardData(siteId: number | null) {
|
||||
telemetry15m7d,
|
||||
auditHourly,
|
||||
modeLog,
|
||||
hpRows,
|
||||
priceRows,
|
||||
] = await Promise.all([
|
||||
getCurrentPlan(siteId).catch((e: unknown) => {
|
||||
@@ -240,6 +241,15 @@ export function useDashboardData(siteId: number | null) {
|
||||
order: 'activated_at.asc',
|
||||
limit: '200',
|
||||
}),
|
||||
getJson<{ slot_start: string; avg_tuv_c: number | null }[]>(
|
||||
'/vw_telemetry_heat_pump_15m_7d',
|
||||
{
|
||||
site_id: `eq.${siteId}`,
|
||||
slot_start: `gte.${new Date(windowStart).toISOString()}`,
|
||||
order: 'slot_start.asc',
|
||||
limit: TELEMETRY_15M_LIMIT,
|
||||
},
|
||||
).catch(() => [] as { slot_start: string; avg_tuv_c: number | null }[]),
|
||||
// Ceny bereme přes FastAPI range endpoint (PostgREST /rest je u vás chráněné → 401).
|
||||
getSitePricesSlotsRange(
|
||||
siteId,
|
||||
@@ -312,6 +322,14 @@ export function useDashboardData(siteId: number | null) {
|
||||
}
|
||||
}
|
||||
|
||||
const hpBySlot = new Map<string, number>()
|
||||
if (Array.isArray(hpRows)) {
|
||||
for (const r of hpRows) {
|
||||
const v = r.avg_tuv_c
|
||||
if (v != null) hpBySlot.set(slotTimeKey(new Date(r.slot_start).getTime()), Number(v))
|
||||
}
|
||||
}
|
||||
|
||||
const auditMap = new Map<string, AuditTodayHourlyRow>()
|
||||
if (Array.isArray(auditHourly)) {
|
||||
for (const r of auditHourly) {
|
||||
@@ -338,6 +356,11 @@ export function useDashboardData(siteId: number | null) {
|
||||
base.soc_actual_pct = parseNum(tel.last_soc_pct) ?? base.soc_actual_pct
|
||||
}
|
||||
|
||||
const hpTuv = hpBySlot.get(k)
|
||||
if (hpTuv != null) {
|
||||
base.tuv_actual_c = hpTuv
|
||||
}
|
||||
|
||||
const aud = auditMap.get(pragueHourKey(startMs))
|
||||
if (aud) {
|
||||
if (base.pv_power_w == null && aud.avg_pv_kw != null) {
|
||||
|
||||
Reference in New Issue
Block a user