Skip to content

Commit 521a490

Browse files
committed
Update relays condition to be an array returend
1 parent 4887783 commit 521a490

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

opensensor/collection_apis.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import logging
23
from datetime import datetime, timedelta, timezone
34
from typing import Generic, List, Optional, Type, TypeVar, get_args, get_origin
@@ -579,6 +580,10 @@ def sample_and_paginate_collection(
579580
relays = []
580581
for item in raw_data:
581582
for relay in item["relays"]:
583+
if isinstance(relay, str):
584+
relay = json.loads(relay)
585+
if isinstance(relay, list):
586+
relay = relay[0]
582587
relays.append(RelayStatus(**relay))
583588
relay_board = RelayBoard(relays=relays)
584589
data.append(relay_board)

0 commit comments

Comments
 (0)