File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,8 @@ def _record_data_to_ts_collection(
140
140
if value is not None :
141
141
if key == "unit" :
142
142
doc_to_insert [column_name + "_unit" ] = value
143
+ elif key == "relays" :
144
+ doc_to_insert [column_name ] = json .dumps (value )
143
145
else :
144
146
doc_to_insert [column_name ] = str (value )
145
147
@@ -580,11 +582,14 @@ def sample_and_paginate_collection(
580
582
relays = []
581
583
for item in raw_data :
582
584
for relay in item ["relays" ]:
583
- if isinstance (relay , str ):
584
- relay = json .loads (relay )
585
- if isinstance (relay , list ):
586
- relay = relay [0 ]
587
- relays .append (RelayStatus (** relay ))
585
+ try :
586
+ if isinstance (relay , str ):
587
+ relay = json .loads (relay )
588
+ if isinstance (relay , list ):
589
+ relay = relay [0 ]
590
+ relays .append (RelayStatus (** relay ))
591
+ except Exception :
592
+ pass # Ignore invalid relay data
588
593
relay_board = RelayBoard (relays = relays )
589
594
data .append (relay_board )
590
595
else :
You can’t perform that action at this time.
0 commit comments