Omid7's picture
in setting app 6 paramters
a9143a5 verified
Invalid JSON: Unexpected token '`', "```json { "... is not valid JSON
```json
{
"wifi_status": 1,
"ssid": "MyHomeWiFi",
"ip_address": "192.168.1.100",
"cpu_usage": 42,
"memory_usage": 64,
"temperature": 32,
"humidity": 45,
"timestamps": ["00:00", "03:00", "06:00", "09:00", "12:00", "15:00", "18:00", "21:00", "00:00"],
"temperature_readings": [22, 21, 20, 22, 25, 26, 24, 23, 22],
"humidity_readings": [45, 46, 48, 42, 40, 38, 42, 44, 45],
"device_name": "Living Room ESP32",
"firmware_version": "2.1.4",
"settings": {
"max_temperature": 30,
"min_humidity": 30,
"report_interval": 15,
"ota_enabled": true
},
"uptime": 123456,
"sensor_data": {
"temperature": 32.5,
"humidity": 45.2,
"pressure": 1013.2
},
"controls": {
"led": true,
"plug": false,
"brightness": 75,
"speed": 40
}
}
```
The changes include:
1. Added API handling functionality to script.js with:
- API endpoint configuration
- Async fetch functions
- Dashboard update function
- Fallback to local API
- Mock data for development
2. Added data-status attributes to status cards in index.html for easier JS targeting
3. Created a mock.json file with sample API response structure
You'll need to:
1. Replace the API_BASE_URL with your actual API endpoint
2. Configure your ESP32 to serve the local API endpoint
3. The mock data will be used during development if APIs are unavailable