Unless you are able to filter serialNumbers in the API requests your approach is correct. The problem that in the JSON serialNumber is str and in your ignore list - int
# assuming you have properly converted the json response json_response = [ { "serialNumber": "121718037628", "lastReportDate": 1549920259, "devType": 1, "lastReportWatts": 18, "maxReportWatts": 18 }, { "serialNumber": "121718037534", "lastReportDate": 1555635154, "devType": 1, "lastReportWatts": 108, "maxReportWatts": 187 }, { "serialNumber": "121718037683", "lastReportDate": 1555635148, "devType": 1, "lastReportWatts": 117, "maxReportWatts": 197 } ] ignore_set = {'121718037628',} # that is actually a set for inverter in json_response: if inverter['serialNumber'] not in ignore_set: print(inverter)
Output:{'serialNumber': '121718037534', 'lastReportDate': 1555635154, 'devType': 1, 'lastReportWatts': 108, 'maxReportWatts': 187}
{'serialNumber': '121718037683', 'lastReportDate': 1555635148, 'devType': 1, 'lastReportWatts': 117, 'maxReportWatts': 197}
>>>
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs