Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel2
Web
Commits
ae3c6c7f
Commit
ae3c6c7f
authored
Jun 03, 2025
by
Gezer
Browse files
modified json format for room data
parent
434b1c37
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/app/views.py
View file @
ae3c6c7f
...
@@ -93,18 +93,20 @@ def room_data_range(request):
...
@@ -93,18 +93,20 @@ def room_data_range(request):
)
)
tables
=
client
.
get_room_data_in_range
(
room
,
start
,
stop
)
tables
=
client
.
get_room_data_in_range
(
room
,
start
,
stop
)
results
=
[]
data_by_time
=
{}
for
table
in
tables
:
for
table
in
tables
:
for
record
in
table
.
records
:
for
record
in
table
.
records
:
results
.
append
(
timestamp
=
str
(
record
.
get_time
())
{
field
=
record
.
get_field
()
"time"
:
str
(
record
.
get_
tim
e
()
),
value
=
record
.
get_
valu
e
()
"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"
:
results
},
status
=
200
)
return
JsonResponse
({
"room"
:
room
,
"data"
:
data_by_time
},
status
=
200
)
except
json
.
JSONDecodeError
:
except
json
.
JSONDecodeError
:
return
JsonResponse
(
return
JsonResponse
(
{
"success"
:
False
,
"message"
:
"Invalid JSON"
},
status
=
400
{
"success"
:
False
,
"message"
:
"Invalid JSON"
},
status
=
400
...
...
stream_processing/mac_to_room.json
View file @
ae3c6c7f
{
{
"AA:BB:CC:DD:EE:FF"
:
"
Wohnzimmer
"
,
"AA:BB:CC:DD:EE:FF"
:
"
1/121
"
,
"11:22:33:44:55:66"
:
"K
\u
00fcche"
,
"11:22:33:44:55:66"
:
"K
\u
00fcche"
,
"77:88:99:AA:BB:CC"
:
"Schlafzimmer"
,
"77:88:99:AA:BB:CC"
:
"Schlafzimmer"
,
"DE:AD:BE:EF:12:34"
:
""
,
"DE:AD:BE:EF:12:34"
:
""
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment