v0.14.8
This commit is contained in:
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user