Skip to content

Commit

Permalink
Update relays condition to be an array returend
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius committed Oct 6, 2024
1 parent 4887783 commit 521a490
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions opensensor/collection_apis.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
from datetime import datetime, timedelta, timezone
from typing import Generic, List, Optional, Type, TypeVar, get_args, get_origin
Expand Down Expand Up @@ -579,6 +580,10 @@ def sample_and_paginate_collection(
relays = []
for item in raw_data:
for relay in item["relays"]:
if isinstance(relay, str):
relay = json.loads(relay)
if isinstance(relay, list):
relay = relay[0]
relays.append(RelayStatus(**relay))
relay_board = RelayBoard(relays=relays)
data.append(relay_board)
Expand Down

0 comments on commit 521a490

Please sign in to comment.