Commit ae3c6c7f authored by Gezer's avatar Gezer
Browse files

modified json format for room data

parent 434b1c37
......@@ -93,18 +93,20 @@ def room_data_range(request):
)
tables = client.get_room_data_in_range(room, start, stop)
results = []
data_by_time = {}
for table in tables:
for record in table.records:
results.append(
{
"time": str(record.get_time()),
"field": record.get_field(),
"value": record.get_value(),
}
)
return JsonResponse({"room": room, "data": results}, status=200)
timestamp = str(record.get_time())
field = record.get_field()
value = record.get_value()
if timestamp not in data_by_time:
data_by_time[timestamp] = {}
data_by_time[timestamp][field] = value
return JsonResponse({"room": room, "data": data_by_time}, status=200)
except json.JSONDecodeError:
return JsonResponse(
{"success": False, "message": "Invalid JSON"}, status=400
......
{
"AA:BB:CC:DD:EE:FF": "Wohnzimmer",
"AA:BB:CC:DD:EE:FF": "1/121",
"11:22:33:44:55:66": "K\u00fcche",
"77:88:99:AA:BB:CC": "Schlafzimmer",
"DE:AD:BE:EF:12:34": "",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment