Skip to content

Commit

Permalink
Update relay storage considerations
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius committed Oct 6, 2024
1 parent 66ef15c commit 9e337e4
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions opensensor/collection_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,17 +579,15 @@ def sample_and_paginate_collection(
data = [VPD(**item) for item in raw_data]
elif response_model is RelayBoard:
data = []
relays = []
for item in raw_data:
relays = []
for relay in item["relays"]:
try:
if isinstance(relay, str):
relay = json.loads(relay)
relays.append(RelayStatus(**relay))
except Exception as e:
logger.error(f"Error creating RelayStatus: {e}")
pass # Ignore invalid relay data
relay_board = RelayBoard(relays=relays)
relay_board = RelayBoard(relays=relays, timestamp=item["timestamp"])
data.append(relay_board)
else:
data = [create_model_instance(response_model, item, unit) for item in raw_data]
Expand Down

0 comments on commit 9e337e4

Please sign in to comment.