Skip to content

Commit 2656edd

Browse files
authored
Merge pull request #35 from bcmi-labs/intfloat_workaround
ucloud: Add workaround for int/float conversion bug.
2 parents 6eab8ce + 67954e2 commit 2656edd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arduino_iot_cloud/ucloud.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ def runnable(self):
110110
def value(self, value):
111111
if value is not None:
112112
if self.value is not None:
113+
# This is a workaround for the cloud float/int conversion bug.
114+
if isinstance(self.value, float) and isinstance(value, int):
115+
value = float(value)
113116
if not isinstance(self.value, type(value)):
114117
raise TypeError(
115-
f"record: {self.name} invalid data type. Expected {type(self.value)} not {type(value)}"
118+
f"{self.name} set to invalid data type, expected: {type(self.value)} got: {type(value)}"
116119
)
117120
self._updated = True
118121
self.timestamp = timestamp()
@@ -375,5 +378,6 @@ async def run(self, user_main=None):
375378
logging.error(f"task: {name} raised exception: {str(task_except)}.")
376379
if name == "mqtt_task":
377380
self.create_task("conn_task", self.conn_task)
381+
break # Break after the first task is removed.
378382
except (CancelledError, InvalidStateError):
379383
pass

0 commit comments

Comments
 (0)