Request all shared attributes
Hello everyone,
Is it possible to request all shared attributes and not just only 1 key?
It is not possible to request all keys, at least to my knowledge.
But this limitation is not from this library, but instead the ThingsBoard API. See the official MQTT Documentaion for more info.
Alternatively, you can use the Shared_Attribute_Subscribe method, which subscribes to any changes or creation of new shared attributes.
For that simply pass the Shared_Attribute_Callback instance, but keep the 2nd parameter empty. Because if no keys are configured you are subscribed to all key changes.
Yeah i see now, thnx. Shared_Attribute_Subscribe without keys is not very useful right? Because if the device is offline it cant know that it was created to later request it.
Yes that is the case updates in between states of being offline will be lost. I'll check the API again to really ensure if it isn't possible to request all keys, because with REST it is.
But if it were it would be an undocumented feature, which would definetly need to be changed.
Will update this thread once I tested it, but I dont have high hopes.
@JellevanKraaij Check this example: https://thingsboard.io/docs/pe/devices-library/esp32-dev-kit-v1/
Using Shared_Attributes_Request() method you can request attributes from the server once the device is connected. But you have to set attributes on the callback level.
Thanks for tip @skokovsergey, it is unfortunately required to list the attributes, you can't request all attributes without knowing their names