google-cloud-platformgoogle-cloud-iot

How to get the device metadata info from google cloud iot core?


I am quite new to google cloud services and I'm trying to get the device metadata that I have added to devices under a registry, but it doesn't seem to work.

device.firebase_id

is unknown where the device is my device and firebase_id is the added attribute to metadata. and device.metadata.firebase_id throws this exception:

'google.protobuf.pyext._message.ScalarMapContainer' object has no attribute 'firebase_id'

Thanks in advance.


Solution

  • device.metadata is a map, so I think you can retrieve the value with:

    device.metadata['firebase_id']