This commit is contained in:
Mateusz Gruszczyński
2026-09-16 09:04:43 +02:00
parent 3d69e74319
commit 0437ef7b6f
28 changed files with 1254 additions and 221 deletions
+37
View File
@@ -26,6 +26,43 @@ function outdoorHistorySeries(devices, rows) {
}));
}
async function openOutdoorHistory() {
const host = $('#outdoorHistoryChartHost');
const current = $('#outdoorHistoryCurrent');
if (!host || !current) return;
current.textContent = app.outdoorTemperature == null ? tr('common.unavailable') : fmtTemp(app.outdoorTemperature);
host.innerHTML = `<div class="panel outdoor-history-loading">${esc(tr('common.loading'))}</div>`;
$$('#outdoorHistoryDialog [data-history-route]').forEach(link => {
const hours = link.dataset.historyHours;
link.href = withBase(`/history/overview${hours ? `?hours=${encodeURIComponent(hours)}` : ''}`);
});
openDialog('outdoorHistoryDialog');
try {
const data = await api('/api/history?scope=overview&hours=24&limit=20000');
const deviceRows = data.devices || [];
const outdoorDeviceSeries = outdoorHistorySeries(app.devices, deviceRows).map(item => ({
...item,
label: item.label.includes(' · ') ? item.label : `${item.label} · ${tr('history.greeOutdoor')}`,
}));
const sensorRows = (data.sensors || []).filter(row => row.kind === 'outdoor');
const outdoorEntities = [...new Set(sensorRows.map(row => row.entity_id))];
const outdoorHaSeries = outdoorEntities.map((entity, index) => ({
label: `HA · ${haSensorLabel(entity)}`,
color: historySeriesColor(index + outdoorDeviceSeries.length),
dash: [6, 4],
value: row => row.entity_id === entity ? historyNumber(row.temperature) : NaN,
}));
const series = [...outdoorDeviceSeries, ...outdoorHaSeries];
const rows = [...deviceRows, ...sensorRows];
host.innerHTML = historyChartMarkup('outdoorHistoryModalChart', tr('history.allOutdoor'), tr('house.outdoorHistoryHint'));
drawLineChart($('#outdoorHistoryModalChart'), series, rows, { height: 350 });
renderLegend($('#outdoorHistoryModalChartLegend'), series);
} catch (error) {
host.innerHTML = `<div class="empty"><strong>${esc(tr('history.noData'))}</strong><span>${esc(error.message)}</span></div>`;
toast(error.message, true);
}
}
function renderHistorySummary() {
const host = $('#historySummary'); if (!host) return;
if (app.historyTab === 'energy') { renderEnergyHistorySummary(); return; }