Hello everyone,
I need some help using a CloudLocation variable in a Python script running on an Arduino Uno Q (App Lab).
On the Arduino Cloud, I created a CloudLocation variable called gpsLocation, which is correctly updated using my iPhone.
However, I’m unable to retrieve the value of this gpsLocation variable from my Python script.
I’ve tried several approaches without success.
Here are some relevant excerpts from my code:
from arduino.app_bricks.arduino_cloud import ArduinoCloud
# Variable declaration
_last_location: Dict = {"lat":"0.0","lon":"0.0"}
# Cloud initialization
iot_cloud = ArduinoCloud()
# Display function
def debugGeoloc(client, value):
lat = value.get("lat", 0.0)
lon = value.get("lon", 0.0)
print(f"lat: {lat} - lon {lon}")
# Cloud synchronization
iot_cloud.register("gpsLocation", value=_last_location, on_write=debugGeoloc)
The problem occurs on the register call:
Traceback (most recent call last):
File "/app/python/main.py", line 291, in <module>
iot_cloud.register("gpsLocation", value=_last_location, on_write=debugGeoloc)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/arduino/app_bricks/arduino_cloud/arduino_cloud.py", line 70, in register
self._client.register(aiotobj, coro=None, **kwargs)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/arduino_iot_cloud/ucloud.py", line 286, in register
if not aiotobj.initialized and "r:m" not in self.records:
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/arduino_iot_cloud/ucloud.py", line 121, in __getattr__
raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{attr}'")
AttributeError: 'ArduinoCloudObject' object has no attribute 'initialized'
exited with code 1
It seems that the ArduinoCloudObject class used internally does not contain the initialized attribute expected by the Cloud client, which causes the exception as soon as register() is called.
Has anyone already encountered this issue with CloudLocation variables or with the Python Cloud API?
Is there a workaround or a specific way to declare/register a CloudLocation variable from Python?
Any help would be greatly appreciated!
Thanks in advance
Yves