api structure cleaning 1

This commit is contained in:
matt committed 2026-10-14 01:23:39 -07:00
1 parent a8eb4866eb
commit 87cd24234a
2 files changed
+7 -6

No files matched your search

+2 -1
View File
@@ -152,12 +152,13 @@ def get_sensor_details(friendly_date = False):
first_seen = ts_to_pst_string(sensor.first_seen)
last_seen = ts_to_pst_string(sensor.last_seen)
# print(f"Summary - {sensor.name}")
sensor_dict = sensor.to_dict()
new_sensor = {
"name": sensor.name,
"first_seen": first_seen,
"last_seen": last_seen,
"comment": sensor.comment,
"data": sensor.to_dict()
**sensor_dict
}
sensor_list.append(new_sensor)
+5 -5
View File
@@ -3,7 +3,7 @@ declare(strict_types=1);
# ---------- Settings ----------
date_default_timezone_set('America/Los_Angeles');
$api_host = 'http://172.17.0.1';
$api_host = 'http://172.20.20.51';
$api_port = 5001; // drive‑health API
$api_path = '/details'; // endpoint that returns the JSON you showed
@@ -24,7 +24,9 @@ function fetch_json(string $url): ?array
# ---------- Load data ----------
$api_url = "$api_host:$api_port$api_path";
$payload = fetch_json($api_url);
foreach ($payload['sensors'] as $s){
echo $s;
}
# ---------- Render ----------
?>
<!doctype html>
@@ -34,9 +36,7 @@ $payload = fetch_json($api_url);
<title>Sensor Dashboard</title>
<link rel="stylesheet" href="src/styles.css">
<style>
table{border-collapse:collapse;width:100%;margin:1rem 0}
th,td{border:1px solid #ddd;padding:.5rem;text-align:left}
th{background:#f4f4f4}
.card { max-width: 550px;}
</style>
</head>
<body>