I want to print value of entity_id and attribute for type which is String e.g,
entities = [{'id': 'Room1',
'temperature': {'value': '10', 'type': 'String'},
'pressure': {'value': '12', 'type': 'Number'},
'type': 'Room',
'time_index': '2020-08-24T06:23:37.346348'},
{'id': 'Room2',
'temperature': {'value': '10', 'type': 'Number'},
'pressure': {'value': '12', 'type': 'Number'},
'type': 'Room',
'time_index': '2020-08-24T06:23:37.346664'}]
ngsi_type = ( 'Array', 'Boolean')
This is the actual definition of code where i want to print value of id and attribute ie, temperature , pressure for type which is not ngsi_type for e.g, for type : String i want value of its entity_id and attribute to be printed
def _insert_entities_of_type(self,
entity_type,
entities,
fiware_service=None,
fiware_servicepath=None):
for e in entities:
if e[NGSI_TYPE] != entity_type:
msg = "Entity {} is not of type {}."
raise ValueError(msg.format(e[NGSI_ID], entity_type))
Any help on it as i am new to python not able to print value of id and attribute:temperature , pressure other than ngsi type with msg
isinstance, for exampleisinstance('abc', str), will return true. This will work for user defined class and its instance too. You can use it to check the instance'type'keys er inner data, I see no field'entity_id'(only'id') and I do not see any'attribute'field. Please be more specific what the outputs should be. Neither of your"type"are"Array"or"Boolean"so currently this should print "as is" ?temperature , Pressure. Also, iftypeisStringi want it to printidandattributewith respect to its ` type :String` inmsg.format.Thanks