Fix slow OBD value load on dashboard (BUG-19)

This commit is contained in:
Mathieu Moran
2026-08-13 16:57:16 -04:00
parent e873db918d
commit c2462356e1
5 changed files with 141 additions and 4 deletions
+17
View File
@@ -314,9 +314,26 @@ async function refreshObdStatus() {
if (el) el.textContent = status.adapter_present
? (status.car_connected ? 'Connected' : 'Adapter only')
: 'Not detected';
// Fill the value cards from the REST snapshot so they appear immediately
// on load, even if the socket connection is slow to establish. Socket
// events keep updating them live afterward.
if (status.car_connected) {
fillObdValueCard('obd-speed', status.speed, 'km/h');
fillObdValueCard('obd-rpm', status.rpm, 'rpm');
fillObdValueCard('obd-coolant', status.coolant_temp, '°C');
fillObdValueCard('obd-fuel', status.fuel_level, '%');
fillObdValueCard('obd-throttle', status.throttle_position, '%');
}
} catch (e) {
// Socket events will eventually update it
}
}
function fillObdValueCard(id, value, unit) {
if (value == null) return;
const el = document.getElementById(id);
if (el) el.textContent = value + ' ' + unit;
}
refreshObdStatus();
window.setInterval(refreshObdStatus, 15000);