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(
140140                if  value  is  not None :
141141                    if  key  ==  "unit" :
142142                        doc_to_insert [column_name  +  "_unit" ] =  value 
143+                     elif  key  ==  "relays" :
144+                         doc_to_insert [column_name ] =  json .dumps (value )
143145                    else :
144146                        doc_to_insert [column_name ] =  str (value )
145147
@@ -580,11 +582,14 @@ def sample_and_paginate_collection(
580582        relays  =  []
581583        for  item  in  raw_data :
582584            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 
588593            relay_board  =  RelayBoard (relays = relays )
589594            data .append (relay_board )
590595    else :
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments