Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
B
bmon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
energy
bmon
Commits
f0980708
Commit
f0980708
authored
Aug 13, 2019
by
Alan Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Fuel and Electric structures to the version 2 API.
parent
9512a3db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
bmsapp/views_api_v2.py
bmsapp/views_api_v2.py
+17
-1
No files found.
bmsapp/views_api_v2.py
View file @
f0980708
...
...
@@ -305,7 +305,8 @@ def buildings(request):
-------
A JSON response containing an indicator of success or failure, a list of
buildings including building properties and sensor association information
if available.
if available. For fuel_rate and electric_rate fields, associated objects
are substituted for the IDs.
"""
try
:
...
...
@@ -353,6 +354,21 @@ def buildings(request):
else
:
b
[
'current_mode'
]
=
''
# Add the fuel and elecric rate objects
fuel_rate_id
=
b
.
pop
(
'fuel_rate_id'
)
if
fuel_rate_id
:
b
[
'fuel_rate'
]
=
models
.
FuelRate
.
objects
.
get
(
pk
=
fuel_rate_id
).
__dict__
b
[
'fuel_rate'
].
pop
(
'_state'
)
else
:
b
[
'fuel_rate'
]
=
None
electric_rate_id
=
b
.
pop
(
'electric_rate_id'
)
if
electric_rate_id
:
b
[
'electric_rate'
]
=
models
.
ElectricRate
.
objects
.
get
(
pk
=
electric_rate_id
).
__dict__
b
[
'electric_rate'
].
pop
(
'_state'
)
else
:
b
[
'electric_rate'
]
=
None
# Add a list of sensors that this building is associated with.
# Note that the Sensor ID here is not the Django model primay key; it
# is the sensor_id field of the Sensor object, to be consistent with the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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