Fix numpy serialization and add comprehensive error logging
Some checks failed
Validate / validate (push) Failing after 9s
Some checks failed
Validate / validate (push) Failing after 9s
Server fixes: - Fix numpy uint8 JSON serialization by converting to Python int - Change WLED payload to flat array format [r,g,b,r,g,b,...] - Add payload debugging logs (size, LED count, sample data) Web UI improvements: - Add comprehensive console logging for device errors - Log actual error messages from state.errors array - Log device operations (start/stop/add) with details - Fix password field form validation warning The HTTP API may have payload size limitations for large LED counts. Consider UDP protocols (DDP/E1.31) for better real-time performance. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -392,6 +392,28 @@ async function loadDevices() {
|
||||
});
|
||||
const metrics = await metricsResponse.json();
|
||||
|
||||
// Log device info, especially if there are errors
|
||||
if (metrics.errors_count > 0) {
|
||||
console.warn(`[Device: ${device.name || device.id}] Has ${metrics.errors_count} error(s)`);
|
||||
|
||||
// Log recent errors from state
|
||||
if (state.errors && state.errors.length > 0) {
|
||||
console.error('Recent errors:');
|
||||
state.errors.forEach((error, index) => {
|
||||
console.error(` ${index + 1}. ${error}`);
|
||||
});
|
||||
}
|
||||
|
||||
// Log last error from metrics
|
||||
if (metrics.last_error) {
|
||||
console.error('Last error:', metrics.last_error);
|
||||
}
|
||||
|
||||
// Log full state and metrics for debugging
|
||||
console.log('Full state:', state);
|
||||
console.log('Full metrics:', metrics);
|
||||
}
|
||||
|
||||
return { ...device, state, metrics };
|
||||
} catch (error) {
|
||||
console.error(`Failed to load state for device ${device.id}:`, error);
|
||||
@@ -492,6 +514,7 @@ function attachDeviceListeners(deviceId) {
|
||||
|
||||
// Device actions
|
||||
async function startProcessing(deviceId) {
|
||||
console.log(`[Device: ${deviceId}] Starting processing...`);
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/devices/${deviceId}/start`, {
|
||||
method: 'POST',
|
||||
@@ -504,19 +527,22 @@ async function startProcessing(deviceId) {
|
||||
}
|
||||
|
||||
if (response.ok) {
|
||||
console.log(`[Device: ${deviceId}] Processing started successfully`);
|
||||
showToast('Processing started', 'success');
|
||||
loadDevices();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
console.error(`[Device: ${deviceId}] Failed to start:`, error);
|
||||
showToast(`Failed to start: ${error.detail}`, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to start processing:', error);
|
||||
console.error(`[Device: ${deviceId}] Failed to start processing:`, error);
|
||||
showToast('Failed to start processing', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function stopProcessing(deviceId) {
|
||||
console.log(`[Device: ${deviceId}] Stopping processing...`);
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/devices/${deviceId}/stop`, {
|
||||
method: 'POST',
|
||||
@@ -529,14 +555,16 @@ async function stopProcessing(deviceId) {
|
||||
}
|
||||
|
||||
if (response.ok) {
|
||||
console.log(`[Device: ${deviceId}] Processing stopped successfully`);
|
||||
showToast('Processing stopped', 'success');
|
||||
loadDevices();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
console.error(`[Device: ${deviceId}] Failed to stop:`, error);
|
||||
showToast(`Failed to stop: ${error.detail}`, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to stop processing:', error);
|
||||
console.error(`[Device: ${deviceId}] Failed to stop processing:`, error);
|
||||
showToast('Failed to stop processing', 'error');
|
||||
}
|
||||
}
|
||||
@@ -697,6 +725,8 @@ async function handleAddDevice(event) {
|
||||
const url = document.getElementById('device-url').value;
|
||||
const led_count = parseInt(document.getElementById('device-led-count').value);
|
||||
|
||||
console.log(`Adding device: ${name} (${url}, ${led_count} LEDs)`);
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/devices`, {
|
||||
method: 'POST',
|
||||
@@ -710,11 +740,14 @@ async function handleAddDevice(event) {
|
||||
}
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
console.log('Device added successfully:', result);
|
||||
showToast('Device added successfully', 'success');
|
||||
event.target.reset();
|
||||
loadDevices();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
console.error('Failed to add device:', error);
|
||||
showToast(`Failed to add device: ${error.detail}`, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user