Closed JacksonBowe closed 3 years ago
Did some digging, below is the problem
File _apiclient.py line 333ish. Looking for the below line
if sorted(list(found_class.attribute_map.values())) == sorted(list(data.keys())):
Printing these out shows the following
print(sorted(list(found_class.attribute_map.values())))
> ['additionalInfo', 'configuration', 'createdTime', 'edgeGroupAll', 'groupAll', 'id', 'name', 'ownerId', 'ownerIds', 'type']
print(sorted(list(data.keys())))
> ['additionalInfo', 'configuration', 'createdTime', 'groupAll', 'id', 'name', 'ownerId', 'ownerIds', 'type']
The only key different is edgeGroupAll. This is possibly because I'm trying to pull data from an installation of TB3.1.1PE.
To resolve this issue I tried uncommenting the following lines (see <<<<<<)
found_class = getattr(tb_rest_client.models.models_pe, klass)
if sorted(list(found_class.attribute_map.values())) == sorted(list(data.keys())):
klass = found_class
print('here')
# if all(attr in list(found_class.attribute_map.values()) for attr in list(data.keys())): <<<<<<<<<<
# klass = found_class <<<<<<<<<<
else:
found_class = getattr(tb_rest_client.models.models_ce, klass)
# if sorted(list(found_class.attribute_map.values())) == sorted(list(data.keys())):
klass = found_class
Uncommenting the above lines worked. Is there a reason that they were commented out? I don't want to be introducing errors back into my code that have already been handled, but for now I think I will keep it. When I upgrade my deployment to TB3.3PE I will revert back.
Hi @JacksonBowe, the latest version of rest-client is for ThingsBoard v.3.3-v.3.X, for this reason, attributes can be different. Please update your ThingsBoard to the latest version.
Version 1.3.2
Running method
dashboard_groups = rest_client.get_entity_groups_by_type('DASHBOARD')
Resulting error
I'm noticing this error is fairly common, where the CE and PE clients are so intertwined that some methods are defaulting to CE without being possible. E.g. same issue happens with get_integrations_get() method.